Skip to content

Commit 023756f

Browse files
dschogitster
authored andcommitted
revision walker: --cherry-pick is a limited operation
We used to rely on the fact that cherry-pick would trigger the code path to set limited = 1 in handle_commit(), when an uninteresting commit was encountered. However, when cherry picking between two independent branches, i.e. when there are no merge bases, and there is only linear development (which can happen when you cvsimport a fork of a project), no uninteresting commit will be encountered. So set limited = 1 when --cherry-pick was asked for. Noticed by Martin Bähr. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e598c51 commit 023756f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

revision.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
10241024
}
10251025
if (!strcmp(arg, "--cherry-pick")) {
10261026
revs->cherry_pick = 1;
1027+
revs->limited = 1;
10271028
continue;
10281029
}
10291030
if (!strcmp(arg, "--objects")) {

t/t6007-rev-list-cherry-pick-file.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,18 @@ test_expect_success '--cherry-pick bar does not come up empty' '
4040
! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)"
4141
'
4242

43+
test_expect_success '--cherry-pick with independent, but identical branches' '
44+
git symbolic-ref HEAD refs/heads/independent &&
45+
rm .git/index &&
46+
echo Hallo > foo &&
47+
git add foo &&
48+
test_tick &&
49+
git commit -m "independent" &&
50+
echo Bello > foo &&
51+
test_tick &&
52+
git commit -m "independent, too" foo &&
53+
test -z "$(git rev-list --left-right --cherry-pick \
54+
HEAD...master -- foo)"
55+
'
56+
4357
test_done

0 commit comments

Comments
 (0)