* Viewing untracked+stashed files in git stash show @ 2017-03-16 16:34 Okash Khawaja 2017-03-17 8:20 ` stefan.naewe 0 siblings, 1 reply; 6+ messages in thread From: Okash Khawaja @ 2017-03-16 16:34 UTC (permalink / raw) To: git Hi, If you have some untracked files and your run `git stash -u`. Then `git stash show` doesn't show the untracked files. Is there a flag that can be passed to git stash show to report untracked files? Thanks, Okash ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Viewing untracked+stashed files in git stash show 2017-03-16 16:34 Viewing untracked+stashed files in git stash show Okash Khawaja @ 2017-03-17 8:20 ` stefan.naewe 2017-03-17 9:50 ` Okash Khawaja 0 siblings, 1 reply; 6+ messages in thread From: stefan.naewe @ 2017-03-17 8:20 UTC (permalink / raw) To: okash.khawaja, git Am 16.03.2017 um 17:34 schrieb Okash Khawaja: > Hi, > > If you have some untracked files and your run `git stash -u`. Then > `git stash show` doesn't show the untracked files. Is there a flag > that can be passed to git stash show to report untracked files? Not for 'git stash' but you can use 'git show stash@{0}^3 (Or, of course, 'gitk stash@{0}' ) HTH Stefan -- ---------------------------------------------------------------- /dev/random says: I keep my .BAT files in D:\BELFRY python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9 9666 829B 49C5 9221 27AF ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Viewing untracked+stashed files in git stash show 2017-03-17 8:20 ` stefan.naewe @ 2017-03-17 9:50 ` Okash Khawaja 2017-03-17 12:08 ` Okash Khawaja 2017-03-17 13:51 ` Jeff King 0 siblings, 2 replies; 6+ messages in thread From: Okash Khawaja @ 2017-03-17 9:50 UTC (permalink / raw) To: stefan.naewe; +Cc: git Hi, On Fri, Mar 17, 2017 at 8:20 AM, <stefan.naewe@atlas-elektronik.com> wrote: > Am 16.03.2017 um 17:34 schrieb Okash Khawaja: >> Hi, >> >> If you have some untracked files and your run `git stash -u`. Then >> `git stash show` doesn't show the untracked files. Is there a flag >> that can be passed to git stash show to report untracked files? > > Not for 'git stash' but you can use 'git show stash@{0}^3 Okay that's fine as long as you know. But the first thing that comes to your mind is that you've lost those untracked files. Is there a reason why git stash show doesn't show those files? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Viewing untracked+stashed files in git stash show 2017-03-17 9:50 ` Okash Khawaja @ 2017-03-17 12:08 ` Okash Khawaja 2017-03-17 13:51 ` Jeff King 1 sibling, 0 replies; 6+ messages in thread From: Okash Khawaja @ 2017-03-17 12:08 UTC (permalink / raw) To: stefan.naewe; +Cc: git Hi, On Fri, Mar 17, 2017 at 9:50 AM, Okash Khawaja <okash.khawaja@gmail.com> wrote: > Hi, > > On Fri, Mar 17, 2017 at 8:20 AM, <stefan.naewe@atlas-elektronik.com> wrote: >> Am 16.03.2017 um 17:34 schrieb Okash Khawaja: >>> Hi, >>> >>> If you have some untracked files and your run `git stash -u`. Then >>> `git stash show` doesn't show the untracked files. Is there a flag >>> that can be passed to git stash show to report untracked files? >> >> Not for 'git stash' but you can use 'git show stash@{0}^3 > > Okay that's fine as long as you know. But the first thing that comes > to your mind is that you've lost those untracked files. Is there a > reason why git stash show doesn't show those files? Here's some more interesting behaviour when stashing untracked files. Add new files (untracked) + modify some tracked files -> `git stash -u` -> modify the stashed files in a way that `git stash pop` will fail -> `git stash pop` -> it fails so now you would expect none of the stashed files restored but instead the untracked stashed files reappear. This combined with the fact that `git stash show` doesn't show untracked files suggest that untracked files go into an undefined (or at least undocumented) state when it comes to git stash. Is that something that needs to be looked at? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Viewing untracked+stashed files in git stash show 2017-03-17 9:50 ` Okash Khawaja 2017-03-17 12:08 ` Okash Khawaja @ 2017-03-17 13:51 ` Jeff King 2017-03-17 14:14 ` Jeff King 1 sibling, 1 reply; 6+ messages in thread From: Jeff King @ 2017-03-17 13:51 UTC (permalink / raw) To: Okash Khawaja; +Cc: stefan.naewe, git On Fri, Mar 17, 2017 at 09:50:29AM +0000, Okash Khawaja wrote: > Hi, > > On Fri, Mar 17, 2017 at 8:20 AM, <stefan.naewe@atlas-elektronik.com> wrote: > > Am 16.03.2017 um 17:34 schrieb Okash Khawaja: > >> Hi, > >> > >> If you have some untracked files and your run `git stash -u`. Then > >> `git stash show` doesn't show the untracked files. Is there a flag > >> that can be passed to git stash show to report untracked files? > > > > Not for 'git stash' but you can use 'git show stash@{0}^3 > > Okay that's fine as long as you know. But the first thing that comes > to your mind is that you've lost those untracked files. Is there a > reason why git stash show doesn't show those files? No, I don't think there is a good reason. The "untracked" option was added to git-stash much later, and nobody considered how it interacted with "stash show". Changes from the index have the same problem. Probably "stash show" should have options "--index" and "--untracked" to show: # index git diff $stash^1 $stash^2 # untracked git diff $stash^1 $stash^3 Possibly it should even show those by default when they are non-empty. -Peff ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Viewing untracked+stashed files in git stash show 2017-03-17 13:51 ` Jeff King @ 2017-03-17 14:14 ` Jeff King 0 siblings, 0 replies; 6+ messages in thread From: Jeff King @ 2017-03-17 14:14 UTC (permalink / raw) To: Okash Khawaja; +Cc: stefan.naewe, git On Fri, Mar 17, 2017 at 09:51:44AM -0400, Jeff King wrote: > > Okay that's fine as long as you know. But the first thing that comes > > to your mind is that you've lost those untracked files. Is there a > > reason why git stash show doesn't show those files? > > No, I don't think there is a good reason. The "untracked" option was > added to git-stash much later, and nobody considered how it interacted > with "stash show". > > Changes from the index have the same problem. Probably "stash show" > should have options "--index" and "--untracked" to show: > > # index > git diff $stash^1 $stash^2 > > # untracked > git diff $stash^1 $stash^3 > > Possibly it should even show those by default when they are non-empty. Actually, $stash^1 is already the parent of the other commits, so we can just show them as-is. Doing this: diff --git a/git-stash.sh b/git-stash.sh index 9c70662cc..868d9027b 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -388,7 +388,16 @@ show_stash () { fi fi - git diff ${FLAGS} $b_commit $w_commit + { + # use --pretty=format instead of tformat, because it omits the + # blank line between the subject and the diff; use "." + # to enable history simplification and drop empty commits. + git show --first-parent -m --pretty=format:'==> %s <==' \ + ${FLAGS} $w_commit -- . + git show --pretty=format:'%n==> %s <==' ${FLAGS} $i_commit -- . + test -n "$u_commit" && + git show --pretty=format:'%n==> %s <==' ${FLAGS} $u_commit -- . + } | git_pager } show_help () { actually looks OK to me, though I don't know if people really like the existing format. With a setup like: git init echo base >file git add file git commit -m base echo index >file git add file echo working tree >file echo untracked >other git stash -u it looks like: $ git stash show ==> WIP on master: 8aa1ec9 base <== file | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ==> index on master: 8aa1ec9 base <== file | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ==> untracked files on master: 8aa1ec9 base <== other | 1 + 1 file changed, 1 insertion(+) or: $ git stash show -p ==> WIP on master: 8aa1ec9 base <== diff --git a/file b/file index df967b9..ace4bb6 100644 --- a/file +++ b/file @@ -1 +1 @@ -base +working tree ==> index on master: 8aa1ec9 base <== diff --git a/file b/file index df967b9..9015a7a 100644 --- a/file +++ b/file @@ -1 +1 @@ -base +index ==> untracked files on master: 8aa1ec9 base <== diff --git a/other b/other new file mode 100644 index 0000000..5a72eb2 --- /dev/null +++ b/other @@ -0,0 +1 @@ +untracked And if you have only a single change, it omits the others: $ echo working tree >file $ git stash $ git stash show ==> WIP on master: 8aa1ec9 base <== file | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) If I were designing "stash show" from scratch today, I'd probably do something like that. But like I said, I don't know if people are invested in the current output (which _can_ be piped to "git apply" if need be, though my output could, too, if you do not have index or untracked files). -Peff ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-17 14:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-03-16 16:34 Viewing untracked+stashed files in git stash show Okash Khawaja 2017-03-17 8:20 ` stefan.naewe 2017-03-17 9:50 ` Okash Khawaja 2017-03-17 12:08 ` Okash Khawaja 2017-03-17 13:51 ` Jeff King 2017-03-17 14:14 ` Jeff King
Code repositories for project(s) associated with this public inbox https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).