threads / bug / 51774

[BUG} stash show does not show untracked files stashed (reposted)

Subject: [BUG} stash show does not show untracked files stashed (reposted)

## tl;dr

2 messages between Aug 29, 2019 and Sep 4, 2019.

replies: 1people: 2as markdown or json

randall.s.becker@rogers.com· Aug 29, 2019, 17:33 UTC · lore

I don't know whether this is new behaviour following changes to stash, but here goes.

Suppose I have files a,b,c,d modified, but only file d is in the index. After stash push (or save) --include-untracked, stash show only displays file d. A subsequent pop will restore files a,b,c,d. So functionally push and pop are fine, but stash show appears to ignores files in the stash. The git log below shows a previous commit (dce2e3e) to the WIP stash (ab0834c) that does contain the untracked files, and git diff is happy to show the contents when using the ref directly. It is just counterintuitive for stash show not to display all entries previously pushed. I would have expected symmetry. This is not new.

*-.   ab0834c (refs/stash) WIP on master: bf223fc Updated known
|\ \
| | * dce2e3e untracked files on master: bf223fc Updated known
| * a5ad1ef index on master: bf223fc Updated known
|/
* bf223fc (HEAD -> master) Updated known
* db0efd4 (origin/master, origin/HEAD) initial

This on git 2.23.0. I have the same behaviour on the Windows build of git 2.12.3.

builtins/stash.c show_stash() does not look like it accounts for multiple paths when calling setup_revisions, so I think it is missing the path to the untracked file ref (dce2e32). I am guessing.

Thanks, Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.
Jeff King· Sep 4, 2019, 07:29 UTC · re: randall.s.becker@rogers.com · lore

Re: [BUG} stash show does not show untracked files stashed (reposted)

On Thu, Aug 29, 2019 at 01:33:36PM -0400, randall.s.becker@rogers.com wrote:
Show 12 quoted lines
> I don't know whether this is new behaviour following changes to stash, but
> here goes.
> 
> Suppose I have files a,b,c,d modified, but only file d is in the index.
> After stash push  (or save) --include-untracked, stash show only displays
> file d. A subsequent pop will restore files a,b,c,d. So functionally push
> and pop are fine, but stash show appears to ignores files in the stash. The
> git log below shows a previous commit (dce2e3e) to the WIP stash (ab0834c)
> that does contain the untracked files, and git diff is happy to show the
> contents when using the ref directly. It is just counterintuitive for stash
> show not to display all entries previously pushed. I would have expected
> symmetry. This is not new.

Right, this is expected but unfortunate. The same problem occurs with stashed changes to the index. The fundamental issue is that a stash is not representing a single diff, but rather up to three diffs:

  - changes to the working tree
  - changes to the index
  - a set of untracked files
each of which is stored as a separate commit.

This has been discussed off and on. A while ago I suggested a possible output format that shows all three:

  https://public-inbox.org/git/20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net/

The patch there is useless now, as stash has been rewritten in C (though that probably means it would be possible to make it less hacky). The main obstacle IMHO is whether we're comfortable changing the output away from a single diff. I could imagine somebody scripting around stash, though if the output remained the same for stashes without index changes or untracked files, that makes problems less likely.

-Peff

← back to recent threads