git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Tim Jaacks <tim.jaacks@garz-fricke.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Cc: Chris Torek <chris.torek@gmail.com>
Subject: Re: git diff ^! syntax stopped working for stashes in Git 2.28
Date: Mon, 12 Sep 2022 13:16:26 +0200	[thread overview]
Message-ID: <9e0c1a2c-542b-156f-4c70-371d3a9b452d@web.de> (raw)
In-Reply-To: <6f729c8c43c4409faf6a11a69791f45a@garz-fricke.com>

Am 12.09.22 um 11:57 schrieb Tim Jaacks:
> Hello,
>
> I noticed that the following syntax to show the changes of a stash stopped working in Git 2.28:
>
>   git diff stash@{0}^!
>
> It still works on commits and HEAD, though:
>
>   git diff f27984d^!
>   git diff HEAD^!
>
> And diffing against the stash's parent works as well:
>
>   git diff stash@{0}^1 stash@{0}
>
> I assume this is a bug. Can anybody confirm this? I verified the behavior change trying different Git versions via docker:
>
>   docker run -it --rm --user $(id -u):$(id -g) -v $HOME:$HOME:rw -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v $PWD:$PWD:rw -w $PWD bitnami/git:2.27.0 diff stash@{0}^!
>
> With v2.27.0 the above syntax works, with v2.28.0 and later it doesn't.

Bisects to 8bfcb3a690 (git diff: improve range handling, 2020-06-12).

Reverting it partially like in the patch below restores the behavior of
"git diff stash@{0}^!".  Tests still pass.

A stash revision is a merge.  With "stash@{0}^!" it ends up in
ent.objects[2] and its parents (marked UNINTERESTING) in ent.objects[0]
and ent.objects[1].

I don't know if the current behavior is expected or if the patch is the
right fix, but in any case it would need a good explanation that I
cannot come up with on the spot.

Copying Chris, author of the mentioned patch.  Old discussion thread:
https://lore.kernel.org/git/pull.804.git.git.1591661021.gitgitgadget@gmail.com/

René


diff --git a/builtin/diff.c b/builtin/diff.c
index 54bb3de964..c34adf2695 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -588,6 +588,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 				sdiff.left, sdiff.right, sdiff.base);
 		result = builtin_diff_tree(&rev, argc, argv,
 					   &ent.objects[0], &ent.objects[1]);
+	} else if (ent.objects[0].item->flags & UNINTERESTING) {
+		result = builtin_diff_tree(&rev, argc, argv,
+					   &ent.objects[0],
+					   &ent.objects[ent.nr-1]);
 	} else
 		result = builtin_diff_combined(&rev, argc, argv,
 					       ent.objects, ent.nr);


  reply	other threads:[~2022-09-12 11:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  9:57 git diff ^! syntax stopped working for stashes in Git 2.28 Tim Jaacks
2022-09-12 11:16 ` René Scharfe [this message]
2022-09-12 19:09   ` Chris Torek
2022-09-14 15:57     ` René Scharfe
2022-09-28  9:02       ` AW: " Tim Jaacks
2022-09-28 17:39         ` René Scharfe

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=9e0c1a2c-542b-156f-4c70-371d3a9b452d@web.de \
    --to=l.s.r@web.de \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tim.jaacks@garz-fricke.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).