{"thread":{"id":"45396","subject":"Viewing untracked+stashed files in git stash show","startedAt":"2017-03-16T16:35:24Z","lastAt":"2017-03-17T14:16:02Z","messageCount":6,"participants":["Okash Khawaja","stefan.naewe@atlas-elektronik.com","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"314230","messageId":"CAOtcWM3mrQEqDnjMipzea7Kp+VueBFsZDL2zcJ=y0wgj9N4Vjw@mail.gmail.com","threadId":"45396","inReplyTo":null,"subject":"Viewing untracked+stashed files in git stash show","fromName":"Okash Khawaja","fromEmail":"okash.khawaja@gmail.com","sentAt":"2017-03-16T16:34:55Z","receivedAt":"2017-03-16T16:35:24Z","isPatch":false,"sender":{"key":"okash.khawaja@gmail.com","avatar":"https://gravatar.com/avatar/360c278c5bcbdc05b1b912192f648c5953421ede775b852770ce81ee363a8996?d=mp&s=160"},"body":"Hi,\n\nIf you have some untracked files and your run `git stash -u`. Then\n`git stash show` doesn't show the untracked files. Is there a flag\nthat can be passed to git stash show to report untracked files?\n\nThanks,\nOkash\n"},{"id":"314314","messageId":"295db01e-6252-6acc-88d8-d2f366397ea0@atlas-elektronik.com","threadId":"45396","inReplyTo":"CAOtcWM3mrQEqDnjMipzea7Kp+VueBFsZDL2zcJ=y0wgj9N4Vjw@mail.gmail.com","subject":"Re: Viewing untracked+stashed files in git stash show","fromName":"","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2017-03-17T08:20:27Z","receivedAt":"2017-03-17T08:30:56Z","isPatch":false,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Am 16.03.2017 um 17:34 schrieb Okash Khawaja:\n> Hi,\n> \n> If you have some untracked files and your run `git stash -u`. Then\n> `git stash show` doesn't show the untracked files. Is there a flag\n> that can be passed to git stash show to report untracked files?\n\nNot for 'git stash' but you can use 'git show stash@{0}^3\n\n(Or, of course, 'gitk stash@{0}' )\n\nHTH\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: I keep my .BAT files in D:\\BELFRY\npython -c \"print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')\" \nGPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF"},{"id":"314315","messageId":"CAOtcWM1jExsj_L4HRm194F57bt9LPuf8fFSpyuGWiPG7U_4v8A@mail.gmail.com","threadId":"45396","inReplyTo":"295db01e-6252-6acc-88d8-d2f366397ea0@atlas-elektronik.com","subject":"Re: Viewing untracked+stashed files in git stash show","fromName":"Okash Khawaja","fromEmail":"okash.khawaja@gmail.com","sentAt":"2017-03-17T09:50:29Z","receivedAt":"2017-03-17T09:50:35Z","isPatch":false,"sender":{"key":"okash.khawaja@gmail.com","avatar":"https://gravatar.com/avatar/360c278c5bcbdc05b1b912192f648c5953421ede775b852770ce81ee363a8996?d=mp&s=160"},"body":"Hi,\n\nOn Fri, Mar 17, 2017 at 8:20 AM,  <stefan.naewe@atlas-elektronik.com> wrote:\n> Am 16.03.2017 um 17:34 schrieb Okash Khawaja:\n>> Hi,\n>>\n>> If you have some untracked files and your run `git stash -u`. Then\n>> `git stash show` doesn't show the untracked files. Is there a flag\n>> that can be passed to git stash show to report untracked files?\n>\n> Not for 'git stash' but you can use 'git show stash@{0}^3\n\nOkay that's fine as long as you know. But the first thing that comes\nto your mind is that you've lost those untracked files. Is there a\nreason why git stash show doesn't show those files?\n"},{"id":"314330","messageId":"CAOtcWM2wg3_uV=THi_PUSVcD8rXMwbd-ZDcTxC=YXvgpP1g_vw@mail.gmail.com","threadId":"45396","inReplyTo":"CAOtcWM1jExsj_L4HRm194F57bt9LPuf8fFSpyuGWiPG7U_4v8A@mail.gmail.com","subject":"Re: Viewing untracked+stashed files in git stash show","fromName":"Okash Khawaja","fromEmail":"okash.khawaja@gmail.com","sentAt":"2017-03-17T12:08:16Z","receivedAt":"2017-03-17T12:39:47Z","isPatch":false,"sender":{"key":"okash.khawaja@gmail.com","avatar":"https://gravatar.com/avatar/360c278c5bcbdc05b1b912192f648c5953421ede775b852770ce81ee363a8996?d=mp&s=160"},"body":"Hi,\n\nOn Fri, Mar 17, 2017 at 9:50 AM, Okash Khawaja <okash.khawaja@gmail.com> wrote:\n> Hi,\n>\n> On Fri, Mar 17, 2017 at 8:20 AM,  <stefan.naewe@atlas-elektronik.com> wrote:\n>> Am 16.03.2017 um 17:34 schrieb Okash Khawaja:\n>>> Hi,\n>>>\n>>> If you have some untracked files and your run `git stash -u`. Then\n>>> `git stash show` doesn't show the untracked files. Is there a flag\n>>> that can be passed to git stash show to report untracked files?\n>>\n>> Not for 'git stash' but you can use 'git show stash@{0}^3\n>\n> Okay that's fine as long as you know. But the first thing that comes\n> to your mind is that you've lost those untracked files. Is there a\n> reason why git stash show doesn't show those files?\n\nHere's some more interesting behaviour when stashing untracked files.\n\nAdd new files (untracked) + modify some tracked files -> `git stash\n-u` -> modify the stashed files in a way that `git stash pop` will\nfail -> `git stash pop` -> it fails so now you would expect none of\nthe stashed files restored but instead the untracked stashed files\nreappear.\n\nThis combined with the fact that `git stash show` doesn't show\nuntracked files suggest that untracked files go into an undefined (or\nat least undocumented) state when it comes to git stash. Is that\nsomething that needs to be looked at?\n"},{"id":"314334","messageId":"20170317135144.scnbtyug2cqbg77p@sigill.intra.peff.net","threadId":"45396","inReplyTo":"CAOtcWM1jExsj_L4HRm194F57bt9LPuf8fFSpyuGWiPG7U_4v8A@mail.gmail.com","subject":"Re: Viewing untracked+stashed files in git stash show","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-17T13:51:44Z","receivedAt":"2017-03-17T13:51:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 17, 2017 at 09:50:29AM +0000, Okash Khawaja wrote:\n\n> Hi,\n> \n> On Fri, Mar 17, 2017 at 8:20 AM,  <stefan.naewe@atlas-elektronik.com> wrote:\n> > Am 16.03.2017 um 17:34 schrieb Okash Khawaja:\n> >> Hi,\n> >>\n> >> If you have some untracked files and your run `git stash -u`. Then\n> >> `git stash show` doesn't show the untracked files. Is there a flag\n> >> that can be passed to git stash show to report untracked files?\n> >\n> > Not for 'git stash' but you can use 'git show stash@{0}^3\n> \n> Okay that's fine as long as you know. But the first thing that comes\n> to your mind is that you've lost those untracked files. Is there a\n> reason why git stash show doesn't show those files?\n\nNo, I don't think there is a good reason. The \"untracked\" option was\nadded to git-stash much later, and nobody considered how it interacted\nwith \"stash show\".\n\nChanges from the index have the same problem. Probably \"stash show\"\nshould have options \"--index\" and \"--untracked\" to show:\n\n  # index\n  git diff $stash^1 $stash^2\n\n  # untracked\n  git diff $stash^1 $stash^3\n\nPossibly it should even show those by default when they are non-empty.\n\n-Peff\n"},{"id":"314336","messageId":"20170317141417.g2oenl67k74nlqrq@sigill.intra.peff.net","threadId":"45396","inReplyTo":"20170317135144.scnbtyug2cqbg77p@sigill.intra.peff.net","subject":"Re: Viewing untracked+stashed files in git stash show","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-17T14:14:17Z","receivedAt":"2017-03-17T14:16:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 17, 2017 at 09:51:44AM -0400, Jeff King wrote:\n\n> > Okay that's fine as long as you know. But the first thing that comes\n> > to your mind is that you've lost those untracked files. Is there a\n> > reason why git stash show doesn't show those files?\n> \n> No, I don't think there is a good reason. The \"untracked\" option was\n> added to git-stash much later, and nobody considered how it interacted\n> with \"stash show\".\n> \n> Changes from the index have the same problem. Probably \"stash show\"\n> should have options \"--index\" and \"--untracked\" to show:\n> \n>   # index\n>   git diff $stash^1 $stash^2\n> \n>   # untracked\n>   git diff $stash^1 $stash^3\n> \n> Possibly it should even show those by default when they are non-empty.\n\nActually, $stash^1 is already the parent of the other commits, so we can\njust show them as-is. Doing this:\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 9c70662cc..868d9027b 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -388,7 +388,16 @@ show_stash () {\n \t\tfi\n \tfi\n \n-\tgit diff ${FLAGS} $b_commit $w_commit\n+\t{\n+\t\t# use --pretty=format instead of tformat, because it omits the\n+\t\t# blank line between the subject and the diff; use \".\"\n+\t\t# to enable history simplification and drop empty commits.\n+\t\tgit show --first-parent -m --pretty=format:'==> %s <==' \\\n+\t\t\t${FLAGS} $w_commit -- .\n+\t\tgit show --pretty=format:'%n==> %s <==' ${FLAGS} $i_commit -- .\n+\t\ttest -n \"$u_commit\" &&\n+\t\t\tgit show --pretty=format:'%n==> %s <==' ${FLAGS} $u_commit -- .\n+\t} | git_pager\n }\n \n show_help () {\nactually looks OK to me, though I don't know if people really like the\nexisting format. With a setup like:\n\n  git init\n  echo base >file\n  git add file\n  git commit -m base\n  echo index >file\n  git add file\n  echo working tree >file\n  echo untracked >other\n  git stash -u\n\nit looks like:\n\n  $ git stash show\n  ==> WIP on master: 8aa1ec9 base <==\n   file | 2 +-\n   1 file changed, 1 insertion(+), 1 deletion(-)\n  \n  ==> index on master: 8aa1ec9 base <==\n   file | 2 +-\n   1 file changed, 1 insertion(+), 1 deletion(-)\n  \n  ==> untracked files on master: 8aa1ec9 base <==\n   other | 1 +\n   1 file changed, 1 insertion(+)\n\nor:\n\n  $ git stash show -p\n  ==> WIP on master: 8aa1ec9 base <==\n  diff --git a/file b/file\n  index df967b9..ace4bb6 100644\n  --- a/file\n  +++ b/file\n  @@ -1 +1 @@\n  -base\n  +working tree\n  \n  ==> index on master: 8aa1ec9 base <==\n  diff --git a/file b/file\n  index df967b9..9015a7a 100644\n  --- a/file\n  +++ b/file\n  @@ -1 +1 @@\n  -base\n  +index\n  \n  ==> untracked files on master: 8aa1ec9 base <==\n  diff --git a/other b/other\n  new file mode 100644\n  index 0000000..5a72eb2\n  --- /dev/null\n  +++ b/other\n  @@ -0,0 +1 @@\n  +untracked\n\nAnd if you have only a single change, it omits the others:\n\n  $ echo working tree >file\n  $ git stash\n  $ git stash show\n  ==> WIP on master: 8aa1ec9 base <==\n   file | 2 +-\n   1 file changed, 1 insertion(+), 1 deletion(-)\n\n\nIf I were designing \"stash show\" from scratch today, I'd probably do\nsomething like that. But like I said, I don't know if people are\ninvested in the current output (which _can_ be piped to \"git apply\" if\nneed be, though my output could, too, if you do not have index or\nuntracked files).\n\n-Peff\n"}]}