Skip to content

Commit

Permalink
Merge branch 'jk/stash-list-p'
Browse files Browse the repository at this point in the history
Teach "git stash list -p" to show the difference between the base
commit version and the working tree version, which is in line with
what "git show" gives.

* jk/stash-list-p:
  stash: default listing to working-tree diff
  • Loading branch information
Junio C Hamano committed Sep 9, 2014
2 parents 1bada2b + 288c67c commit 753aaf3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion git-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ have_stash () {

list_stash () {
have_stash || return 0
git log --format="%gd: %gs" -g "$@" $ref_stash --
git log --format="%gd: %gs" -g --first-parent -m "$@" $ref_stash --
}

show_stash () {
Expand Down
42 changes: 42 additions & 0 deletions t/t3903-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -685,4 +685,46 @@ test_expect_success 'handle stash specification with spaces' '
grep pig file
'

test_expect_success 'setup stash with index and worktree changes' '
git stash clear &&
git reset --hard &&
echo index >file &&
git add file &&
echo working >file &&
git stash
'

test_expect_success 'stash list implies --first-parent -m' '
cat >expect <<-\EOF &&
stash@{0}: WIP on master: b27a2bc subdir
diff --git a/file b/file
index 257cc56..d26b33d 100644
--- a/file
+++ b/file
@@ -1 +1 @@
-foo
+working
EOF
git stash list -p >actual &&
test_cmp expect actual
'

test_expect_success 'stash list --cc shows combined diff' '
cat >expect <<-\EOF &&
stash@{0}: WIP on master: b27a2bc subdir
diff --cc file
index 257cc56,9015a7a..d26b33d
--- a/file
+++ b/file
@@@ -1,1 -1,1 +1,1 @@@
- foo
-index
++working
EOF
git stash list -p --cc >actual &&
test_cmp expect actual
'

test_done

0 comments on commit 753aaf3

Please sign in to comment.