Skip to content

Commit

Permalink
cherry_pick_list: quit early if one side is empty
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Rast authored and Junio C Hamano committed Feb 20, 2010
1 parent ea02eef commit 36c0797
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
right_count++;
}

if (!left_count || !right_count)
return;

left_first = left_count < right_count;
init_patch_ids(&ids);
if (revs->diffopt.nr_paths) {
Expand Down

0 comments on commit 36c0797

Please sign in to comment.