Skip to content

Commit 753aaf3

Browse files
committed
Merge branch 'jk/stash-list-p'
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
2 parents 1bada2b + 288c67c commit 753aaf3

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

git-stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ have_stash () {
297297

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

303303
show_stash () {

t/t3903-stash.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,4 +685,46 @@ test_expect_success 'handle stash specification with spaces' '
685685
grep pig file
686686
'
687687

688+
test_expect_success 'setup stash with index and worktree changes' '
689+
git stash clear &&
690+
git reset --hard &&
691+
echo index >file &&
692+
git add file &&
693+
echo working >file &&
694+
git stash
695+
'
696+
697+
test_expect_success 'stash list implies --first-parent -m' '
698+
cat >expect <<-\EOF &&
699+
stash@{0}: WIP on master: b27a2bc subdir
700+
701+
diff --git a/file b/file
702+
index 257cc56..d26b33d 100644
703+
--- a/file
704+
+++ b/file
705+
@@ -1 +1 @@
706+
-foo
707+
+working
708+
EOF
709+
git stash list -p >actual &&
710+
test_cmp expect actual
711+
'
712+
713+
test_expect_success 'stash list --cc shows combined diff' '
714+
cat >expect <<-\EOF &&
715+
stash@{0}: WIP on master: b27a2bc subdir
716+
717+
diff --cc file
718+
index 257cc56,9015a7a..d26b33d
719+
--- a/file
720+
+++ b/file
721+
@@@ -1,1 -1,1 +1,1 @@@
722+
- foo
723+
-index
724+
++working
725+
EOF
726+
git stash list -p --cc >actual &&
727+
test_cmp expect actual
728+
'
729+
688730
test_done

0 commit comments

Comments
 (0)