Skip to content

Commit 4e9bf3d

Browse files
klusarkgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b04e691 commit 4e9bf3d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

t/t3903-stash.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,18 @@ test_expect_success 'create with multiple arguments for the message' '
822822
test_cmp expect actual
823823
'
824824

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+
825837
test_expect_success 'stash -- <pathspec> stashes and restores the file' '
826838
>foo &&
827839
>bar &&

0 commit comments

Comments
 (0)