Thread (3 messages) flat view 3 messages, 3 authors, 2017-09-23

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

From: Kaartic Sivaraam <hidden>
Date: 2017-09-23 07:04:11
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

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=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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help