Merge branch 'ta/config-set-2'
[gitweb.git] / t / t3903-stash.sh
index 634b2b74f49558781f612e3044d99cbc6fa3e657..1e29962fad30edb263cd07b6586f1b1a962c88cf 100755 (executable)
@@ -654,4 +654,77 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
        test_cmp output expect
 '
 
+test_expect_success 'store called with invalid commit' '
+       test_must_fail git stash store foo
+'
+
+test_expect_success 'store updates stash ref and reflog' '
+       git stash clear &&
+       git reset --hard &&
+       echo quux >bazzy &&
+       git add bazzy &&
+       STASH_ID=$(git stash create) &&
+       git reset --hard &&
+       ! grep quux bazzy &&
+       git stash store -m quuxery $STASH_ID &&
+       test $(cat .git/refs/stash) = $STASH_ID &&
+       grep $STASH_ID .git/logs/refs/stash &&
+       git stash pop &&
+       grep quux bazzy
+'
+
+test_expect_success 'handle stash specification with spaces' '
+       git stash clear &&
+       echo pig >file &&
+       git stash &&
+       stamp=$(git log -g --format="%cd" -1 refs/stash) &&
+       test_tick &&
+       echo cow >file &&
+       git stash &&
+       git stash apply "stash@{$stamp}" &&
+       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