stash: add a test for stashing in a detached state

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>

Joel Teichroeb committed Aug 19, 2017 at 13:13 UTC 4e9bf3dd6daec09b9a0b110825093c6a480f92e4
1 file changed +12
t/t3903-stash.sh
+12
@@ -822,6 +822,18 @@ test_expect_success 'create with multiple arguments for the message' '
822 test_cmp expect actual
823 '
824
825 +test_expect_success 'create in a detached state' '
826 + test_when_finished "git checkout master" &&
827 + git checkout HEAD~1 &&
828 + >foo &&
829 + git add foo &&
830 + STASH_ID=$(git stash create) &&
831 + HEAD_ID=$(git rev-parse --short HEAD) &&
832 + echo "WIP on (no branch): ${HEAD_ID} initial" >expect &&
833 + git show --pretty=%s -s ${STASH_ID} >actual &&
834 + test_cmp expect actual
835 +'
836 +
837 test_expect_success 'stash -- <pathspec> stashes and restores the file' '
838 >foo &&
839 >bar &&