Skip to content

Commit 36c0797

Browse files
trastgitster
authored andcommitted
cherry_pick_list: quit early if one side is empty
The --cherry-pick logic starts by counting the commits on each side, so that it can filter away commits on the bigger one. However, so far it missed an opportunity for optimization: it doesn't need to do any work if either side is empty. This in particular helps the common use-case 'git rebase -i HEAD~$n': it internally uses --cherry-pick, but since HEAD~$n is a direct ancestor the left side is always empty. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea02eef commit 36c0797

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

revision.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
514514
right_count++;
515515
}
516516

517+
if (!left_count || !right_count)
518+
return;
519+
517520
left_first = left_count < right_count;
518521
init_patch_ids(&ids);
519522
if (revs->diffopt.nr_paths) {

0 commit comments

Comments
 (0)