Reputation: 25113
I can view stashed changes as:
$ git stash show -p stash@{0}
diff --git a/t/database/test.t b/t/database/test.t
index 3e9dcf87..4326d7e0 100644
--- a/t/database/test.t
+++ b/t/database/test.t
@@ -249,6 +249,8 @@ begin
loop raise notice ''before: %%'', r; end loop;
end if;
+ -- delete OLD if NEW.sys_period is empty
+ -- or create pid to track full version history. See transaction time
UPDATE %1$s
SET
-- NOTICE: Here new values for sys_time column should be now() instead of sys_time()
But when I do git show stash@{0}
or git show -p 803d7231
it displays just info without changes:
commit 803d7231aebc79819d69b5e8505c4be7f747441f (refs/stash)
Merge: 2b30b862 3f34d241
Author: Eugen Konkov <[email protected]>
Date: Mon Apr 27 12:34:43 2020 +0300
On bi-temporal: TODO: Bi-Temporal improvement: track how data is changed
Why git show
does not display diff?
Upvotes: 2
Views: 104
Reputation: 51790
A stash is actually a merge commit, and git show
will hide a diff chunk that looks like an accepted merge change.
You can use the -m
option :
git show -m stash@{0}
or explicitly ask for the diff between stash@{0}
and its first parent (your last active commit) :
git diff stash@{0}^ stash@{0}
stash
is actually a merge commitgit stash
actually creates two commits :
You can look at the history of stash@{0}
:
$ git log --graph --oneline stash@{0}
* afffe0c (refs/stash) WIP on master: 6615405 commit: created file "a.txt"
|\
| * 6ebdc03 index on master: 6615405 commit: created file "a.txt"
|/
* 6615405 (HEAD -> master) commit: created file "a.txt"
* 170d9f8 empty
git stash show
and git show
git stash show -p
knows that you generally want to view the diff between stash@{0}
and your work (its first parent) ;
git show stash@{0}
, on the other hand, displays this commit as a merge commit.
If the modifications were staged when you stashed then, then these modifications will be part of the index on xxx : ...
commit, and git show
will not, by default, display this diff chunk.
See git help show
:
For commits it shows the log message and textual diff. It also presents the merge commit in a special format as produced by git diff-tree --cc.
and git help diff-tree
, the --cc
option :
--cc
This flag changes the way a merge commit patch is displayed, in a similar way to the -c option. It implies the -c and -p options and further compresses the patch output by omitting uninteresting hunks whose the contents in the parents have only two variants and the merge result picks one of them without modification. When all hunks are uninteresting, the commit itself and the commit log message is not shown, just like in any other "empty diff" case.
Upvotes: 2
Reputation: 30858
A stash is a merge commit which has 2 parents. According to the doc, git show <merge-commit>
presents the merge commit in a special format as produced by git diff-tree --cc
.
This flag changes the way a merge commit patch is displayed, in a similar way to the -c option. It implies the -c and -p options and further compresses the patch output by omitting uninteresting hunks whose the contents in the parents have only two variants and the merge result picks one of them without modification. When all hunks are uninteresting, the commit itself and the commit log message is not shown, just like in any other "empty diff" case.
I think no diff is displayed because all hunks are uninteresting and therefore omitted in your case.
Upvotes: 1