Skip to content

Commit e7ef4be

Browse files
trmalfuriousgitster
authored andcommitted
revision: fix --left/right-only use with unrelated histories
This is a similar fix as 023756f (revision walker: --cherry-pick is a limited operation), but for the --left-only and --right-only options. When computing a symmetric difference between two unrelated histories, no suitable merge base exists, and so no boundary commit is flagged as UNINTERESTING. Previously, we relied on the presence of such boundary to trigger limiting and thus consideration of either "revs->left_only" or "revs->right_only". A number of other entries in the option parser have started including overrides for "revs->limited = 1". Do the same for these options. Signed-off-by: Matt Hunter <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 683c54c commit e7ef4be

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

revision.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,10 +2488,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
24882488
die(_("options '%s' and '%s' cannot be used together"),
24892489
"--left-only", "--right-only/--cherry");
24902490
revs->left_only = 1;
2491+
revs->limited = 1;
24912492
} else if (!strcmp(arg, "--right-only")) {
24922493
if (revs->left_only)
24932494
die(_("options '%s' and '%s' cannot be used together"), "--right-only", "--left-only");
24942495
revs->right_only = 1;
2496+
revs->limited = 1;
24952497
} else if (!strcmp(arg, "--cherry")) {
24962498
if (revs->left_only)
24972499
die(_("options '%s' and '%s' cannot be used together"), "--cherry", "--left-only");

t/t6000-rev-list-misc.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,19 @@ test_expect_success 'rev-list --unpacked' '
182182
test_cmp expect actual
183183
'
184184

185+
test_expect_success 'rev-list one-sided unrelated symmetric diff' '
186+
test_tick &&
187+
git commit --allow-empty -m xyz &&
188+
git branch cmp &&
189+
git rebase --force-rebase --root &&
190+
191+
git rev-list --left-only HEAD...cmp >head &&
192+
git rev-list --right-only HEAD...cmp >cmp &&
193+
194+
sort head >head.sorted &&
195+
sort cmp >cmp.sorted &&
196+
comm -12 head.sorted cmp.sorted >actual &&
197+
test_line_count = 0 actual
198+
'
199+
185200
test_done

0 commit comments

Comments
 (0)