Skip to content

Commit 477209b

Browse files
committed
Merge branch 'mh/left-right-limited'
"git log --{left,right}-only A...B", when A and B does not share any common ancestor, now behaves as expected. * mh/left-right-limited: revision: fix --left/right-only use with unrelated histories
2 parents 480ddc5 + e7ef4be commit 477209b

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
@@ -2480,10 +2480,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
24802480
die(_("options '%s' and '%s' cannot be used together"),
24812481
"--left-only", "--right-only/--cherry");
24822482
revs->left_only = 1;
2483+
revs->limited = 1;
24832484
} else if (!strcmp(arg, "--right-only")) {
24842485
if (revs->left_only)
24852486
die(_("options '%s' and '%s' cannot be used together"), "--right-only", "--left-only");
24862487
revs->right_only = 1;
2488+
revs->limited = 1;
24872489
} else if (!strcmp(arg, "--cherry")) {
24882490
if (revs->left_only)
24892491
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,6 +182,21 @@ 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_expect_success 'rev-list -z' '
186201
test_when_finished rm -rf repo &&
187202

0 commit comments

Comments
 (0)