git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff ^! syntax stopped working for stashes in Git 2.28

From
Chris Torek <chris.torek@gmail.com>
Date
Sep 12, 2022, 19:09 UTC
Message-ID
<CAPx1Gve=BZ3J7KH0FA_BbAnYMEFXyDyiD=tX1vBiKCfHS0JfFg@mail.gmail.com>
In-Reply-To
<9e0c1a2c-542b-156f-4c70-371d3a9b452d@web.de>
On Mon, Sep 12, 2022 at 4:16 AM René Scharfe <l.s.r@web.de> wrote:
> Am 12.09.22 um 11:57 schrieb Tim Jaacks:
>> I noticed that the following syntax to show the changes of a stash stopped working in Git 2.28:
>>
>>   git diff stash@{0}^!
> Bisects to 8bfcb3a690 (git diff: improve range handling, 2020-06-12).

It's not really clear to me what `git diff stash^!` (and similar) *should* do. That it worked before was at least in part an accident of implementation.

> 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].
Right: the ^! suffix produces a negated list of the children as additional
revs (with the stash itself as the lone positive rev).  Note that a stash
made with `-u` will list *three* such revs rather than just two, since such
a stash is a three-parent merge.

You're advised (in the git stash documentation) to use `git stash show`, not `git diff`, to get a diff from the stash's parent commit to the stash's working-tree commit.

It's certainly possible to detect a single positive rev and two or three negative ones as special cases here, but it's not clear that this is a good idea. Note that in commit bafa2d741e I made one of the tests stop using `git diff HEAD^!` on the grounds that it's not defined behavior.

Chris
Previous: René ScharfeNext: René Scharfe
Message 3 of 6 in “git diff ^! syntax stopped working for stashes in Git 2.28”
  1. Tim JaacksSep 12, 2022
  2. René ScharfeSep 12, 2022
  3. Chris TorekSep 12, 2022
  4. René ScharfeSep 14, 2022
  5. AW: git diff ^! syntax stopped working for stashes in Git 2.28Tim Jaacks, Sep 28, 2022
  6. René ScharfeSep 28, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.