stash: add a test for stashing in a detached state
authorJoel Teichroeb <joel@teichroeb.net>
Sat, 19 Aug 2017 20:13:26 +0000 (13:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 19 Aug 2017 21:04:04 +0000 (14:04 -0700)
All that we are really testing here is that the message is
correct when we are not on any branch. All other functionality is
already tested elsewhere.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3903-stash.sh
index 887010c4978f5dbed700e0daabed67fa827fc045..3b1ac1971af1d972b77b3dfe8ae4a56e00e1fa55 100755 (executable)
@@ -822,6 +822,18 @@ test_expect_success 'create with multiple arguments for the message' '
        test_cmp expect actual
 '
 
+test_expect_success 'create in a detached state' '
+       test_when_finished "git checkout master" &&
+       git checkout HEAD~1 &&
+       >foo &&
+       git add foo &&
+       STASH_ID=$(git stash create) &&
+       HEAD_ID=$(git rev-parse --short HEAD) &&
+       echo "WIP on (no branch): ${HEAD_ID} initial" >expect &&
+       git show --pretty=%s -s ${STASH_ID} >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'stash -- <pathspec> stashes and restores the file' '
        >foo &&
        >bar &&