aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-04-23 13:58:51 -0700
committerJunio C Hamano <gitster@pobox.com>2025-04-23 13:58:51 -0700
commit477209bd7fb1605d10be7c8eae9d215e265b4501 (patch)
tree5347b41f3ce6342766bacbf4d1325d29fbbcc07e
parent480ddc566fd68556bcf824a1141d5dbef3e0701f (diff)
parente7ef4be7c25c4968d8c5c51e6e748a1927f67194 (diff)
downloadgit-477209bd7fb1605d10be7c8eae9d215e265b4501.tar.gz
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
-rw-r--r--revision.c2
-rwxr-xr-xt/t6000-rev-list-misc.sh15
2 files changed, 17 insertions, 0 deletions
diff --git a/revision.c b/revision.c
index 3fb4c4adb7..550453ab70 100644
--- a/revision.c
+++ b/revision.c
@@ -2480,10 +2480,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
die(_("options '%s' and '%s' cannot be used together"),
"--left-only", "--right-only/--cherry");
revs->left_only = 1;
+ revs->limited = 1;
} else if (!strcmp(arg, "--right-only")) {
if (revs->left_only)
die(_("options '%s' and '%s' cannot be used together"), "--right-only", "--left-only");
revs->right_only = 1;
+ revs->limited = 1;
} else if (!strcmp(arg, "--cherry")) {
if (revs->left_only)
die(_("options '%s' and '%s' cannot be used together"), "--cherry", "--left-only");
diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh
index 33881274a4..fec16448cf 100755
--- a/t/t6000-rev-list-misc.sh
+++ b/t/t6000-rev-list-misc.sh
@@ -182,6 +182,21 @@ test_expect_success 'rev-list --unpacked' '
test_cmp expect actual
'
+test_expect_success 'rev-list one-sided unrelated symmetric diff' '
+ test_tick &&
+ git commit --allow-empty -m xyz &&
+ git branch cmp &&
+ git rebase --force-rebase --root &&
+
+ git rev-list --left-only HEAD...cmp >head &&
+ git rev-list --right-only HEAD...cmp >cmp &&
+
+ sort head >head.sorted &&
+ sort cmp >cmp.sorted &&
+ comm -12 head.sorted cmp.sorted >actual &&
+ test_line_count = 0 actual
+'
+
test_expect_success 'rev-list -z' '
test_when_finished rm -rf repo &&