cherry: remove redundant check for merge commit
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>
Martin von Zweigbergk committed
Jul 29, 2012 at 16:25 UTC
51f4de3ac993b52c8a2fab9ca3acc665fca2d833
1 file changed
+2
-8
builtin/log.c
+2
-8
@@ -718,6 +718,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
718
719
/* given a range a..b get all patch ids for b..a */
720
init_revisions(&check_rev, rev->prefix);
721
+ check_rev.max_parents = 1;
722
o1->flags ^= UNINTERESTING;
723
o2->flags ^= UNINTERESTING;
724
add_pending_object(&check_rev, o1, "o1");
@@ -726,10 +727,6 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
727
die(_("revision walk setup failed"));
728
729
while ((commit = get_revision(&check_rev)) != NULL) {
729
- /* ignore merges */
730
- if (commit->parents && commit->parents->next)
731
- continue;
732
-
730
add_commit_patch_id(commit, ids);
731
}
732
@@ -1508,6 +1505,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
1505
}
1506
1507
init_revisions(&revs, prefix);
1508
+ revs.max_parents = 1;
1509
1510
if (add_pending_commit(head, &revs, 0))
1511
die(_("Unknown commit %s"), head);
@@ -1530,10 +1528,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
1528
if (prepare_revision_walk(&revs))
1529
die(_("revision walk setup failed"));
1530
while ((commit = get_revision(&revs)) != NULL) {
1533
- /* ignore merges */
1534
- if (commit->parents && commit->parents->next)
1535
- continue;
1536
-
1531
commit_list_insert(commit, &list);
1532
}
1533