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 <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Feb 20, 2010 at 12:42 UTC
36c079756f9f3ad0bbbe2097550c62427670146b
1 file changed
+3
revision.c
+3
@@ -514,6 +514,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
514
right_count++;
515
}
516
517
+ if (!left_count || !right_count)
518
+ return;
519
+
520
left_first = left_count < right_count;
521
init_patch_ids(&ids);
522
if (revs->diffopt.nr_paths) {