]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: fix --left/right-only use with unrelated histories
authorMatt Hunter <m@lfurio.us>
Sun, 30 Mar 2025 11:24:06 +0000 (07:24 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Apr 2025 09:57:26 +0000 (02:57 -0700)
This is a similar fix as 023756f4eb (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 <m@lfurio.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c
t/t6000-rev-list-misc.sh

index c4390f0938cbdeb3a08a310cf2ca5aaed944d377..e045445bc3cae38ae738d4052a3115fdba06cd01 100644 (file)
@@ -2488,10 +2488,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");
index 6289a2e8b03890ded5863f3472e469c28cb3034a..d338f7ecb467b379afb5124de41c2f70cbf9d99f 100755 (executable)
@@ -182,4 +182,19 @@ 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_done