Re: Behaviour of 'git stash show' when a stash has untracked files
Jeff Kingwrites: > 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. > 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).
Re: Behaviour of 'git stash show' when a stash has untracked files
On Wed, 2017-09-20 at 23:31 -0400, Jeff King wrote: > 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. > Yeah, I feel the same. > 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". Sounds good. > but I'd be happy to review if anybody picked up the topic. > I would be, too. --- Kaartic
Re: Behaviour of 'git stash show' when a stash has untracked files
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=y0wgj9n4...@mail.gmail.com/ > > I sketched out a possible solution in: > > > https://public-inbox.org/git/20170317141417.g2oenl67k74nl...@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
Re: Behaviour of 'git stash show' when a stash has untracked files
On Thu, Sep 21, 2017 at 10:23:36AM +0900, Junio C Hamano wrote: > Jeff Kingwrites: > > > I sketched out a possible solution in: > > > > > > https://public-inbox.org/git/20170317141417.g2oenl67k74nl...@sigill.intra.peff.net/ > > > > though I share your concerns over whether people would be annoyed to see > > the existing "stash show" output changed. > > Forgot about that one. I sometimes do "stash show -p | apply", so > changing what is included without any option would be annoying, and > not having an option to restore the original behaviour would be > doubly irritating. 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. 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. > Perhaps "stash show [--[untracked|index|worktree]]" to show only > one, without the "==> I am this variant <==" label, would be > workable, and with no option we would do --worktree that is the > traditional output. > > In addition "stash show --all" could be the output in your earlier > patch. I like the way it uses the '.' pathspec to squelch the > entire thing when there is no change ;-) Those all seem like sane interface proposals. As I said above, I have a vague feeling that the default _ought_ to tell about everything. But I don't care all that much myself, and I agree that we should avoid creating headaches for existing users (it's just not clear to me how big the headaches would be). 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. Anyway. I don't have plans to work on this anytime soon, but I'd be happy to review if anybody picked up the topic. -Peff
Re: Behaviour of 'git stash show' when a stash has untracked files
Jeff Kingwrites: > I sketched out a possible solution in: > > > https://public-inbox.org/git/20170317141417.g2oenl67k74nl...@sigill.intra.peff.net/ > > though I share your concerns over whether people would be annoyed to see > the existing "stash show" output changed. Forgot about that one. I sometimes do "stash show -p | apply", so changing what is included without any option would be annoying, and not having an option to restore the original behaviour would be doubly irritating. Perhaps "stash show [--[untracked|index|worktree]]" to show only one, without the "==> I am this variant <==" label, would be workable, and with no option we would do --worktree that is the traditional output. In addition "stash show --all" could be the output in your earlier patch. I like the way it uses the '.' pathspec to squelch the entire thing when there is no change ;-) Thanks.
Re: Behaviour of 'git stash show' when a stash has untracked files
On Wed, Sep 20, 2017 at 02:33:04PM +0900, Junio C Hamano wrote: > Kaartic Sivaraamwrites: > > > Some time ago, I stashed a few changes along with untracked files. I > > almost forgot it until recently. Then I wanted to see what I change I > > had in the stash. So I did a 'git stash show '. It worked fine but > > didn't say anything about the untracked files in that stash. That made > > me wonder where the untracked files I added went. I then applied the > > stash to see that they were still there but weren't listed in show. > > > > I understand that they aren't listed because 'git stash show' is > > typically a "diff between the stashed state and its original parent" as > > the documentation says but shouldn't there be at least a message that > > the stash contains untracked files? Those untracked files are "part of > > the stash" and I see no way to get information about their presence > > currently. > > > > So, should this behaviour be changed? > > Hmm, crickets tell us that nobody is all that interested in this, it > seems. 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=y0wgj9n4...@mail.gmail.com/ I sketched out a possible solution in: https://public-inbox.org/git/20170317141417.g2oenl67k74nl...@sigill.intra.peff.net/ though I share your concerns over whether people would be annoyed to see the existing "stash show" output changed. -Peff
Re: Behaviour of 'git stash show' when a stash has untracked files
Kaartic Sivaraamwrites: > Some time ago, I stashed a few changes along with untracked files. I > almost forgot it until recently. Then I wanted to see what I change I > had in the stash. So I did a 'git stash show '. It worked fine but > didn't say anything about the untracked files in that stash. That made > me wonder where the untracked files I added went. I then applied the > stash to see that they were still there but weren't listed in show. > > I understand that they aren't listed because 'git stash show' is > typically a "diff between the stashed state and its original parent" as > the documentation says but shouldn't there be at least a message that > the stash contains untracked files? Those untracked files are "part of > the stash" and I see no way to get information about their presence > currently. > > So, should this behaviour be changed? Hmm, crickets tell us that nobody is all that interested in this, it seems. I do not think I'd be against a new feature that lets users ask what untracked paths are in the stash (and even their contents), but I do think it is a bad idea to change a vanilla "stash show" to show that information in addition to what is currently shown. Two things need to be designed carefuly. One is the UI to _invoke_ the new feature, the other is the output from the new feature. As to the invocation, an obvious pair of choices are: - "git stash show-untracked stash@{0} [ [--] ]"? - "git stash show --untracked stash@{0} [ [--] ]"? I'd personally vote for the former, if only because the latter makes the design more complicated. For one thing, tying the feature to "show" means the output _must_ be in the form of "diff" output in order to be consistent with the normal output from the subcommand, but a whole-file creation diff may not be the best way to show the entire contents of an untracked file. Also by adding it as an option to the existing "show" command, it makes it debatable if the output should show the contents of untracked files in addition to the stashed changes of tracked paths, or in place of them. Because I suspect that viewing contents of the untracked files and the changes to tracked paths may serve quite different purposes from the point of view of expected use cases, I am leaning towards saying that it is a bad idea to show contents of untracked paths in addition to changes to tracked paths. There probably are other reasons why we should prefer the former, i.e. a separate subcommand to "git stash", independent of the existing "git stash show". Assuming that we choose to go with a separate command, the output format from the command does not have to be in the form of patch, so perhaps "git stash show-untracked --list" may be a way to list the paths (and we may want -z to show the list NUL-terminated like "ls-files" does)? There may be other operations to help those who want a way to learn about untracked paths in a stash. But this is not exactly my itch so I'll let people who do have the itch to work on designing the details out.