Skip to content

Commit 51f4de3

Browse files
Martin von Zweigbergkgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38a44bc commit 51f4de3

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

builtin/log.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
718718

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

728729
while ((commit = get_revision(&check_rev)) != NULL) {
729-
/* ignore merges */
730-
if (commit->parents && commit->parents->next)
731-
continue;
732-
733730
add_commit_patch_id(commit, ids);
734731
}
735732

@@ -1508,6 +1505,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
15081505
}
15091506

15101507
init_revisions(&revs, prefix);
1508+
revs.max_parents = 1;
15111509

15121510
if (add_pending_commit(head, &revs, 0))
15131511
die(_("Unknown commit %s"), head);
@@ -1530,10 +1528,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
15301528
if (prepare_revision_walk(&revs))
15311529
die(_("revision walk setup failed"));
15321530
while ((commit = get_revision(&revs)) != NULL) {
1533-
/* ignore merges */
1534-
if (commit->parents && commit->parents->next)
1535-
continue;
1536-
15371531
commit_list_insert(commit, &list);
15381532
}
15391533

0 commit comments

Comments
 (0)