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
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Sep 23, 2017, 07:03 UTC
Message-ID
<1506150231.3877.3.camel@gmail.com>
In-Reply-To
<20170920193630.l7ifret5dpqgxiwm@sigill.intra.peff.net>
On Wed, 2017-09-20 at 15:36 -0400, Jeff King wrote:
Show 12 quoted lines
> 
> Or sometimes people are just really behind in reading the mailing list. ;)
> 
> This seemed familiar, and indeed there was some discussion a few months
> ago:
> 
>   https://public-inbox.org/git/CAOtcWM3mrQEqDnjMipzea7Kp+VueBFsZDL2zcJ=y0wgj9N4Vjw@mail.gmail.com/
> 
> I sketched out a possible solution in:
> 
>   https://public-inbox.org/git/20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net/
> 

It seems I should have searched the list without being lazy before I sent this one. Anyways, the output of the patch there sound a little interesting.

> though I share your concerns over whether people would be annoyed to see
> the existing "stash show" output changed.
> 

Though I'm not sure whether people would be annoyed about the change in output, I personally find it a little odd to show the contents of untracked files as if they have been "added" to the index (although there is notice that these are "untracked-files"). I think that might puzzle some users.

That said, when I actually sent this mail I was thinking of an implementation of the following sort (thanks Peff!),

diff --git a/git-stash.sh b/git-stash.sh
index 8b2ce9afd..b79adc138 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -401,7 +401,10 @@ show_stash () {
                fi
        fi
 
-       git diff ${FLAGS} $b_commit $w_commit
+       {
+               git diff ${FLAGS} $b_commit $w_commit
+               test -n "$u_commit" && git show  --pretty=format:'%nUntracked files: ' ${FLAGS} $u_commit -- .
+       } | git_pager
 }
 
 show_help () {

I would like to turn this off when patch mode is requested, but I
currently couldn't. I would also like to print only the names of the
files, if possible.

I find this kind of output better than showing nothing at all or
showing the output of untracked files in the form of a diff when patch
mode is requested. IOW, this satisfies my expectation though I'm not
sure how much this would be useful to others.

---
Kaartic
Previous: Junio C Hamano
Message 8 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.