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