Skip to content

Commit

Permalink
cherry: remove redundant check for merge commit
Browse files Browse the repository at this point in the history
While walking the revision list in get_patch_ids and cmd_cherry, we
check for each commit if there is more than one parent and ignore
the commit if that is the case. Instead, set rev_info.max_parents to
1 and let the revision traversal code handle it for us.

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Martin von Zweigbergk authored and Junio C Hamano committed Jul 30, 2012
1 parent 38a44bc commit 51f4de3
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)

/* given a range a..b get all patch ids for b..a */
init_revisions(&check_rev, rev->prefix);
check_rev.max_parents = 1;
o1->flags ^= UNINTERESTING;
o2->flags ^= UNINTERESTING;
add_pending_object(&check_rev, o1, "o1");
Expand All @@ -726,10 +727,6 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
die(_("revision walk setup failed"));

while ((commit = get_revision(&check_rev)) != NULL) {
/* ignore merges */
if (commit->parents && commit->parents->next)
continue;

add_commit_patch_id(commit, ids);
}

Expand Down Expand Up @@ -1508,6 +1505,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
}

init_revisions(&revs, prefix);
revs.max_parents = 1;

if (add_pending_commit(head, &revs, 0))
die(_("Unknown commit %s"), head);
Expand All @@ -1530,10 +1528,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
while ((commit = get_revision(&revs)) != NULL) {
/* ignore merges */
if (commit->parents && commit->parents->next)
continue;

commit_list_insert(commit, &list);
}

Expand Down

0 comments on commit 51f4de3

Please sign in to comment.