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

From: Kaartic Sivaraam <[email-masked]>
Date: Sat, 23 Sep 2017 12:33:51 +0530

On Wed, 2017-09-20 at 15:36 -0400, Jeff King wrote:
> 
> 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=[email-masked]/
> 
> I sketched out a possible solution in:
> 
>   https://public-inbox.org/git/[email-masked]/
> 

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