From: Junio C Hamano <gitster@pobox.com>
To: "Chris Torek via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Chris Torek <chris.torek@gmail.com>
Subject: Re: [PATCH 1/3] t/t3430: avoid undocumented git diff behavior
Date: Mon, 08 Jun 2020 22:18:19 -0700 [thread overview]
Message-ID: <xmqqr1uoizqc.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <414163bbc3cbdda241bedc7bc4dfb8b493071dcb.1591661021.git.gitgitgadget@gmail.com> (Chris Torek via GitGitGadget's message of "Tue, 09 Jun 2020 00:03:39 +0000")
"Chris Torek via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Chris Torek <chris.torek@gmail.com>
>
> According to the documentation, "git diff" takes at most two commit-ish,
> or an A..B style range, or an A...B style symmetric difference range.
> The autosquash-and-exec test relied on "git diff HEAD^!", which works
> fine for ordinary commits as the revision parse produces two commit-ish,
> namely ^HEAD^ and HEAD.
>
> For merge commits, however, this test makes use of an undocumented
> feature:
s/undocumented feature/undefined behaviour/;
The show.sh scripts wants to compute the diff against first parent,
and it uses a range notation HEAD^! which happens to mean
HEAD^..HEAD for a single parent commit, but it forgets that the
commit it may get fed could be a merge. What the code happens to do
when given "git diff ^HEAD^2 HEAD^..HEAD" is undefined behaviour and
does not even ...
> the resulting revision parse has all the parents as UNINTERESTING
> followed by the HEAD commit. This looks identical to a symmetric
> diff parse, which lists the merge bases as UNINTERESTING, followed by
> the A (UNINTERESTING) and B revs. So the diff winds up treating it
> as one, using the first oid (i.e., HEAD^) and the last (i.e., HEAD).
> The documentation, however, says nothing about this usage.
...deserve to be explained in a paragraph like this, I would think.
> Since diff actually just uses HEAD^ and HEAD, call for these directly
> here. That makes it possible to improve the diff code's handling of
> symmetric difference arguments.
Yes, the resulting code expresses the intent much better.
>
> Signed-off-by: Chris Torek <chris.torek@gmail.com>
> ---
> t/t3430-rebase-merges.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
> index a1bc3e20016..b454f400ebd 100755
> --- a/t/t3430-rebase-merges.sh
> +++ b/t/t3430-rebase-merges.sh
> @@ -420,7 +420,7 @@ test_expect_success 'with --autosquash and --exec' '
> git commit --fixup B B.t &&
> write_script show.sh <<-\EOF &&
> subject="$(git show -s --format=%s HEAD)"
> - content="$(git diff HEAD^! | tail -n 1)"
> + content="$(git diff HEAD^ HEAD | tail -n 1)"
> echo "$subject: $content"
> EOF
> test_tick &&
next prev parent reply other threads:[~2020-06-09 5:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 0:03 [PATCH 0/3] improve git-diff documentation and A...B handling Chris Torek via GitGitGadget
2020-06-09 0:03 ` [PATCH 1/3] t/t3430: avoid undocumented git diff behavior Chris Torek via GitGitGadget
2020-06-09 5:18 ` Junio C Hamano [this message]
2020-06-09 0:03 ` [PATCH 2/3] git diff: improve A...B merge-base handling Chris Torek via GitGitGadget
2020-06-09 5:40 ` Junio C Hamano
2020-06-12 13:38 ` Philip Oakley
2020-06-12 17:06 ` Junio C Hamano
2020-06-09 0:03 ` [PATCH 3/3] Documentation: tweak git diff help slightly Chris Torek via GitGitGadget
2020-06-09 5:45 ` Junio C Hamano
2020-06-09 19:00 ` [PATCH v2 0/3] improve git-diff documentation and A...B handling Chris Torek via GitGitGadget
2020-06-09 19:00 ` [PATCH v2 1/3] t/t3430: avoid undefined git diff behavior Chris Torek via GitGitGadget
2020-06-09 19:00 ` [PATCH v2 2/3] git diff: improve A...B merge-base handling Chris Torek via GitGitGadget
2020-06-09 22:52 ` Junio C Hamano
2020-06-09 19:00 ` [PATCH v2 3/3] Documentation: tweak git diff help slightly Chris Torek via GitGitGadget
2020-06-09 23:01 ` Junio C Hamano
2020-06-11 15:15 ` [PATCH v3 0/3] improve git-diff documentation and A...B handling Chris Torek via GitGitGadget
2020-06-11 15:15 ` [PATCH v3 1/3] t/t3430: avoid undefined git diff behavior Chris Torek via GitGitGadget
2020-06-11 15:15 ` [PATCH v3 2/3] git diff: improve range handling Chris Torek via GitGitGadget
2020-06-11 15:51 ` Chris Torek
2020-06-11 15:15 ` [PATCH v3 3/3] Documentation: usage for diff combined commits Chris Torek via GitGitGadget
2020-06-12 16:19 ` [PATCH v4 0/3] improve git-diff documentation and A...B handling Chris Torek via GitGitGadget
2020-06-12 16:19 ` [PATCH v4 1/3] t/t3430: avoid undefined git diff behavior Chris Torek via GitGitGadget
2020-06-12 16:19 ` [PATCH v4 2/3] git diff: improve range handling Chris Torek via GitGitGadget
2020-06-12 18:31 ` Junio C Hamano
2020-06-12 19:25 ` Chris Torek
2020-06-12 16:20 ` [PATCH v4 3/3] Documentation: usage for diff combined commits Chris Torek via GitGitGadget
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr1uoizqc.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).