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

Re: Behaviour of 'git stash show' when a stash has untracked files

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 24, 2017, 00:41 UTC
Message-ID
<xmqqing9hqro.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170921033152.4hbkctzxraww5rqo@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> I think it would mostly Just Work for your case. git-apply should ignore
> the subject cruft at the top of the patch. And if you didn't create a
> stash with "-u" or with bits in the index, then those would be absent
> from the diff.
>
> And if you _did_ create such a stash, I actually suspect that "apply"
> barfing on the resulting patch may be a better outcome than silently
> ignoring the changes.
OK, that sounds sensible.
Show 5 quoted lines
> I dunno. I do not use either of those features ("-u" or stashing the
> index state) myself. But I have always been bothered how the saved state
> is a bit hidden from the user. It seems like a recipe for user confusion
> when they save something with "git stash" but then "stash show" doesn't
> even mention it.

Yes, I do not dispute that the issue needs to be addressed. What I was unsure was how (e.g. should that be given always? does the user ask and if so how? what the output to tell the information looks like?)

> Those all seem like sane interface proposals. As I said above, I have a
> vague feeling that the default _ought_ to tell about everything.
OK.
> I guess the nuclear option there is introducing "git stash info" or
> something, and marking "git stash show" as an alias for "git stash info
> --worktree". It is too bad, though, as "show" is really the perfect
> name.

I think the end result of that becomes the same as adding "git stash info" an alias for "git stash show --all" on top of what I wrote.

I suspect nobody uses "stash show" in a script in such a way that its output is consumed by the script logic, so it may probably be OK to show everything by default (which I agree is the way we would have done _if_ people demanded on day 1 that we need to record all three variants; IIRC, in the early days of the command back when the "show" subcommand appeared, even "--index" was merely an intellectual curiosity and was not a serious feature, and from that point of view the historical output we currently have made sense).

Previous: Kaartic SivaraamNext: Kaartic Sivaraam
Message 7 of 8 in “Behaviour of 'git stash show' when a stash has untracked files”
  1. Kaartic SivaraamSep 17, 2017
  2. Junio C HamanoSep 20, 2017
  3. Jeff KingSep 20, 2017
  4. Junio C HamanoSep 21, 2017
  5. Jeff KingSep 21, 2017
  6. Kaartic SivaraamSep 23, 2017
  7. Junio C HamanoSep 24, 2017
  8. Kaartic SivaraamSep 23, 2017

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.