{"thread":{"id":"46766","subject":"Behaviour of 'git stash show' when a stash has untracked files","startedAt":"2017-09-17T05:28:24Z","lastAt":"2017-09-24T00:41:38Z","messageCount":8,"participants":["Kaartic Sivaraam","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"328246","messageId":"1505626069.9625.6.camel@gmail.com","threadId":"46766","inReplyTo":null,"subject":"Behaviour of 'git stash show' when a stash has untracked files","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-09-17T05:27:49Z","receivedAt":"2017-09-17T05:28:24Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"Some time ago, I stashed a few changes along with untracked files. I\nalmost forgot it until recently. Then I wanted to see what I change I\nhad in the stash. So I did a 'git stash show <num>'. It worked fine but\ndidn't say anything about the untracked files in that stash. That made\nme wonder where the untracked files I added went. I then applied the\nstash to see that they were still there but weren't listed in show.\n\nI understand that they aren't listed because 'git stash show' is\ntypically a \"diff between the stashed state and its original parent\" as\nthe documentation says but shouldn't there be at least a message that\nthe stash contains untracked files? Those untracked files are \"part of\nthe stash\" and I see no way to get information about their presence\ncurrently.\n\nSo, should this behaviour be changed?\n\n-- \nKaartic\n"},{"id":"328450","messageId":"xmqqfubinddb.fsf@gitster.mtv.corp.google.com","threadId":"46766","inReplyTo":"1505626069.9625.6.camel@gmail.com","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-20T05:33:04Z","receivedAt":"2017-09-20T05:33:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:\n\n> Some time ago, I stashed a few changes along with untracked files. I\n> almost forgot it until recently. Then I wanted to see what I change I\n> had in the stash. So I did a 'git stash show <num>'. It worked fine but\n> didn't say anything about the untracked files in that stash. That made\n> me wonder where the untracked files I added went. I then applied the\n> stash to see that they were still there but weren't listed in show.\n>\n> I understand that they aren't listed because 'git stash show' is\n> typically a \"diff between the stashed state and its original parent\" as\n> the documentation says but shouldn't there be at least a message that\n> the stash contains untracked files? Those untracked files are \"part of\n> the stash\" and I see no way to get information about their presence\n> currently.\n>\n> So, should this behaviour be changed?\n\nHmm, crickets tell us that nobody is all that interested in this, it\nseems.  I do not think I'd be against a new feature that lets users\nask what untracked paths are in the stash (and even their contents),\nbut I do think it is a bad idea to change a vanilla \"stash show\" to\nshow that information in addition to what is currently shown.\n\nTwo things need to be designed carefuly.  One is the UI to _invoke_\nthe new feature, the other is the output from the new feature.\n\nAs to the invocation, an obvious pair of choices are:\n\n - \"git stash show-untracked stash@{0} [ [--] <pathspec>]\"?\n - \"git stash show --untracked stash@{0} [ [--] <pathspec>]\"?\n\nI'd personally vote for the former, if only because the latter makes\nthe design more complicated.  For one thing, tying the feature to\n\"show\" means the output _must_ be in the form of \"diff\" output in\norder to be consistent with the normal output from the subcommand,\nbut a whole-file creation diff may not be the best way to show the\nentire contents of an untracked file.  Also by adding it as an\noption to the existing \"show\" command, it makes it debatable if the\noutput should show the contents of untracked files in addition to\nthe stashed changes of tracked paths, or in place of them.  Because\nI suspect that viewing contents of the untracked files and the\nchanges to tracked paths may serve quite different purposes from the\npoint of view of expected use cases, I am leaning towards saying\nthat it is a bad idea to show contents of untracked paths in\naddition to changes to tracked paths.  There probably are other\nreasons why we should prefer the former, i.e. a separate subcommand\nto \"git stash\", independent of the existing \"git stash show\".\n\nAssuming that we choose to go with a separate command, the output\nformat from the command does not have to be in the form of patch, so\nperhaps \"git stash show-untracked --list\" may be a way to list the\npaths (and we may want -z to show the list NUL-terminated like\n\"ls-files\" does)?  There may be other operations to help those who\nwant a way to learn about untracked paths in a stash.  But this is\nnot exactly my itch so I'll let people who do have the itch to work\non designing the details out.\n\n\n\n"},{"id":"328487","messageId":"20170920193630.l7ifret5dpqgxiwm@sigill.intra.peff.net","threadId":"46766","inReplyTo":"xmqqfubinddb.fsf@gitster.mtv.corp.google.com","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-20T19:36:30Z","receivedAt":"2017-09-20T19:36:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 20, 2017 at 02:33:04PM +0900, Junio C Hamano wrote:\n\n> Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:\n> \n> > Some time ago, I stashed a few changes along with untracked files. I\n> > almost forgot it until recently. Then I wanted to see what I change I\n> > had in the stash. So I did a 'git stash show <num>'. It worked fine but\n> > didn't say anything about the untracked files in that stash. That made\n> > me wonder where the untracked files I added went. I then applied the\n> > stash to see that they were still there but weren't listed in show.\n> >\n> > I understand that they aren't listed because 'git stash show' is\n> > typically a \"diff between the stashed state and its original parent\" as\n> > the documentation says but shouldn't there be at least a message that\n> > the stash contains untracked files? Those untracked files are \"part of\n> > the stash\" and I see no way to get information about their presence\n> > currently.\n> >\n> > So, should this behaviour be changed?\n> \n> Hmm, crickets tell us that nobody is all that interested in this, it\n> seems.\n\nOr sometimes people are just really behind in reading the mailing list. ;)\n\nThis seemed familiar, and indeed there was some discussion a few months\nago:\n\n  https://public-inbox.org/git/CAOtcWM3mrQEqDnjMipzea7Kp+VueBFsZDL2zcJ=y0wgj9N4Vjw@mail.gmail.com/\n\nI sketched out a possible solution in:\n\n  https://public-inbox.org/git/20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net/\n\nthough I share your concerns over whether people would be annoyed to see\nthe existing \"stash show\" output changed.\n\n-Peff\n"},{"id":"328518","messageId":"xmqqpoakn8tj.fsf@gitster.mtv.corp.google.com","threadId":"46766","inReplyTo":"20170920193630.l7ifret5dpqgxiwm@sigill.intra.peff.net","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-21T01:23:36Z","receivedAt":"2017-09-21T01:25:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I sketched out a possible solution in:\n>\n>   https://public-inbox.org/git/20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net/\n>\n> though I share your concerns over whether people would be annoyed to see\n> the existing \"stash show\" output changed.\n\nForgot about that one.  I sometimes do \"stash show -p | apply\", so\nchanging what is included without any option would be annoying, and\nnot having an option to restore the original behaviour would be\ndoubly irritating.  \n\nPerhaps \"stash show [--[untracked|index|worktree]]\" to show only\none, without the \"==> I am this variant <==\" label, would be\nworkable, and with no option we would do --worktree that is the\ntraditional output.\n\nIn addition \"stash show --all\" could be the output in your earlier\npatch.  I like the way it uses the '.' pathspec to squelch the\nentire thing when there is no change ;-)\n\nThanks.\n"},{"id":"328530","messageId":"20170921033152.4hbkctzxraww5rqo@sigill.intra.peff.net","threadId":"46766","inReplyTo":"xmqqpoakn8tj.fsf@gitster.mtv.corp.google.com","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-21T03:31:52Z","receivedAt":"2017-09-21T03:32:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 21, 2017 at 10:23:36AM +0900, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > I sketched out a possible solution in:\n> >\n> >   https://public-inbox.org/git/20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net/\n> >\n> > though I share your concerns over whether people would be annoyed to see\n> > the existing \"stash show\" output changed.\n> \n> Forgot about that one.  I sometimes do \"stash show -p | apply\", so\n> changing what is included without any option would be annoying, and\n> not having an option to restore the original behaviour would be\n> doubly irritating.\n\nI think it would mostly Just Work for your case. git-apply should ignore\nthe subject cruft at the top of the patch. And if you didn't create a\nstash with \"-u\" or with bits in the index, then those would be absent\nfrom the diff.\n\nAnd if you _did_ create such a stash, I actually suspect that \"apply\"\nbarfing on the resulting patch may be a better outcome than silently\nignoring the changes.\n\nI dunno. I do not use either of those features (\"-u\" or stashing the\nindex state) myself. But I have always been bothered how the saved state\nis a bit hidden from the user. It seems like a recipe for user confusion\nwhen they save something with \"git stash\" but then \"stash show\" doesn't\neven mention it.\n\n> Perhaps \"stash show [--[untracked|index|worktree]]\" to show only\n> one, without the \"==> I am this variant <==\" label, would be\n> workable, and with no option we would do --worktree that is the\n> traditional output.\n> \n> In addition \"stash show --all\" could be the output in your earlier\n> patch.  I like the way it uses the '.' pathspec to squelch the\n> entire thing when there is no change ;-)\n\nThose all seem like sane interface proposals. As I said above, I have a\nvague feeling that the default _ought_ to tell about everything. But I\ndon't care all that much myself, and I agree that we should avoid\ncreating headaches for existing users (it's just not clear to me how big\nthe headaches would be).\n\nI guess the nuclear option there is introducing \"git stash info\" or\nsomething, and marking \"git stash show\" as an alias for \"git stash info\n--worktree\". It is too bad, though, as \"show\" is really the perfect\nname.\n\nAnyway. I don't have plans to work on this anytime soon, but I'd be\nhappy to review if anybody picked up the topic.\n\n-Peff\n"},{"id":"328718","messageId":"1506150231.3877.3.camel@gmail.com","threadId":"46766","inReplyTo":"20170920193630.l7ifret5dpqgxiwm@sigill.intra.peff.net","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-09-23T07:03:51Z","receivedAt":"2017-09-23T07:04:11Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Wed, 2017-09-20 at 15:36 -0400, Jeff King wrote:\n> \n> Or sometimes people are just really behind in reading the mailing list. ;)\n> \n> This seemed familiar, and indeed there was some discussion a few months\n> ago:\n> \n>   https://public-inbox.org/git/CAOtcWM3mrQEqDnjMipzea7Kp+VueBFsZDL2zcJ=y0wgj9N4Vjw@mail.gmail.com/\n> \n> I sketched out a possible solution in:\n> \n>   https://public-inbox.org/git/20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net/\n> \n\nIt seems I should have searched the list without being lazy before I\nsent this one. Anyways, the output of the patch there sound a little\ninteresting.\n\n> though I share your concerns over whether people would be annoyed to see\n> the existing \"stash show\" output changed.\n> \n\nThough I'm not sure whether people would be annoyed about the change in\noutput, I personally find it a little odd to show the contents of\nuntracked files as if they have been \"added\" to the index (although\nthere is notice that these are \"untracked-files\"). I think that might\npuzzle some users.\n\nThat said, when I actually sent this mail I was thinking of an\nimplementation of the following sort (thanks Peff!),\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 8b2ce9afd..b79adc138 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -401,7 +401,10 @@ show_stash () {\n                fi\n        fi\n \n-       git diff ${FLAGS} $b_commit $w_commit\n+       {\n+               git diff ${FLAGS} $b_commit $w_commit\n+               test -n \"$u_commit\" && git show  --pretty=format:'%nUntracked files: ' ${FLAGS} $u_commit -- .\n+       } | git_pager\n }\n \n show_help () {\n\nI would like to turn this off when patch mode is requested, but I\ncurrently couldn't. I would also like to print only the names of the\nfiles, if possible.\n\nI find this kind of output better than showing nothing at all or\nshowing the output of untracked files in the form of a diff when patch\nmode is requested. IOW, this satisfies my expectation though I'm not\nsure how much this would be useful to others.\n\n---\nKaartic\n"},{"id":"328719","messageId":"1506150665.3877.7.camel@gmail.com","threadId":"46766","inReplyTo":"20170921033152.4hbkctzxraww5rqo@sigill.intra.peff.net","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-09-23T07:11:05Z","receivedAt":"2017-09-23T07:11:18Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Wed, 2017-09-20 at 23:31 -0400, Jeff King wrote:\n> But I have always been bothered how the saved state\n> is a bit hidden from the user. It seems like a recipe for user confusion\n> when they save something with \"git stash\" but then \"stash show\" doesn't\n> even mention it.\n> \n\nYeah, I feel the same.\n\n> I guess the nuclear option there is introducing \"git stash info\" or\n> something, and marking \"git stash show\" as an alias for \"git stash info\n> --worktree\".\n\nSounds good.\n\n> but I'd be happy to review if anybody picked up the topic.\n> \n\nI would be, too.\n\n---\nKaartic\n"},{"id":"328754","messageId":"xmqqing9hqro.fsf@gitster.mtv.corp.google.com","threadId":"46766","inReplyTo":"20170921033152.4hbkctzxraww5rqo@sigill.intra.peff.net","subject":"Re: Behaviour of 'git stash show' when a stash has untracked files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-24T00:41:31Z","receivedAt":"2017-09-24T00:41:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think it would mostly Just Work for your case. git-apply should ignore\n> the subject cruft at the top of the patch. And if you didn't create a\n> stash with \"-u\" or with bits in the index, then those would be absent\n> from the diff.\n>\n> And if you _did_ create such a stash, I actually suspect that \"apply\"\n> barfing on the resulting patch may be a better outcome than silently\n> ignoring the changes.\n\nOK, that sounds sensible.\n\n> I dunno. I do not use either of those features (\"-u\" or stashing the\n> index state) myself. But I have always been bothered how the saved state\n> is a bit hidden from the user. It seems like a recipe for user confusion\n> when they save something with \"git stash\" but then \"stash show\" doesn't\n> even mention it.\n\nYes, I do not dispute that the issue needs to be addressed.  What I\nwas unsure was how (e.g. should that be given always? does the user\nask and if so how? what the output to tell the information looks\nlike?)\n\n> Those all seem like sane interface proposals. As I said above, I have a\n> vague feeling that the default _ought_ to tell about everything.\n\nOK.\n\n> I guess the nuclear option there is introducing \"git stash info\" or\n> something, and marking \"git stash show\" as an alias for \"git stash info\n> --worktree\". It is too bad, though, as \"show\" is really the perfect\n> name.\n\nI think the end result of that becomes the same as adding \"git stash\ninfo\" an alias for \"git stash show --all\" on top of what I wrote.\n\nI suspect nobody uses \"stash show\" in a script in such a way that\nits output is consumed by the script logic, so it may probably be OK\nto show everything by default (which I agree is the way we would\nhave done _if_ people demanded on day 1 that we need to record all\nthree variants; IIRC, in the early days of the command back when the\n\"show\" subcommand appeared, even \"--index\" was merely an intellectual\ncuriosity and was not a serious feature, and from that point of view\nthe historical output we currently have made sense).\n\n"}]}