From: Junio C Hamano <gitster@pobox.com>
To: Matt Hunter <m@lfurio.us>
Cc: git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>,
Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v2] revision: fix --left/right-only use with unrelated histories
Date: Fri, 11 Apr 2025 07:41:57 -0700 [thread overview]
Message-ID: <xmqqecxyoj4a.fsf@gitster.g> (raw)
In-Reply-To: <20250330112850.2477673-1-m@lfurio.us> (Matt Hunter's message of "Sun, 30 Mar 2025 07:24:06 -0400")
Matt Hunter <m@lfurio.us> writes:
> 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>
> ---
Thanks. As far as I can see, the whole patch looks sensible,
including its rewritten tests.
Let me mark the topic for 'next'.
Thanks, all.
> Range-diff against v1:
> 1: 1982f14d70 ! 1: 4f5b264b26 revision: fix --left/right-only use with unrelated histories
> @@ t/t6000-rev-list-misc.sh: test_expect_success 'rev-list --unpacked' '
> + git rev-list --left-only HEAD...cmp >head &&
> + git rev-list --right-only HEAD...cmp >cmp &&
> +
> -+ test $(comm -12 <(sort head) <(sort cmp) | wc -l) = "0"
> ++ sort head >head.sorted &&
> ++ sort cmp >cmp.sorted &&
> ++ comm -12 head.sorted cmp.sorted >actual &&
> ++ test_line_count = 0 actual
> +'
> +
> test_done
>
> base-commit: 683c54c999c301c2cd6f715c411407c413b1d84e
>
> revision.c | 2 ++
> t/t6000-rev-list-misc.sh | 15 +++++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/revision.c b/revision.c
> index c4390f0938..e045445bc3 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -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");
> diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh
> index 6289a2e8b0..d338f7ecb4 100755
> --- a/t/t6000-rev-list-misc.sh
> +++ b/t/t6000-rev-list-misc.sh
> @@ -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
prev parent reply other threads:[~2025-04-11 14:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-30 5:49 [PATCH] revision: fix --left/right-only use with unrelated histories Matt Hunter
2025-03-30 8:31 ` Johannes Sixt
2025-04-01 9:56 ` Junio C Hamano
2025-03-30 10:11 ` Phillip Wood
2025-03-30 10:54 ` Matt Hunter
2025-04-02 13:12 ` phillip.wood123
2025-04-04 5:13 ` Matt Hunter
2025-03-30 11:24 ` [PATCH v2] " Matt Hunter
2025-04-11 14:41 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqecxyoj4a.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=m@lfurio.us \
--cc=phillip.wood123@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).