3 # Copyright (c) 2007 Johannes E Schindelin
6 test_description='Test git stash'
10 test_expect_success 'stash some dirty working directory' '
13 echo unrelated >other-file &&
16 git commit -m initial &&
22 git diff-files --quiet &&
23 git diff-index --cached --quiet HEAD
27 diff --git a/file b/file
28 index 0cfbf08..00750ed 100644
36 test_expect_success 'parents of stash' '
37 test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
38 git diff stash^2..stash >output &&
39 test_cmp expect output
42 test_expect_success 'applying bogus stash does nothing' '
43 test_must_fail git stash apply stash@{1} &&
48 test_expect_success 'apply does not need clean working directory' '
55 test_expect_success 'apply does not clobber working directory changes' '
58 test_must_fail git stash apply &&
63 test_expect_success 'apply stashed changes' '
68 git commit -m other-file &&
70 test 3 = $(cat file) &&
71 test 1 = $(git show :file) &&
72 test 1 = $(git show HEAD:file)
75 test_expect_success 'apply stashed changes (including index)' '
76 git reset --hard HEAD^ &&
80 git commit -m other-file &&
81 git stash apply --index &&
82 test 3 = $(cat file) &&
83 test 2 = $(git show :file) &&
84 test 1 = $(git show HEAD:file)
87 test_expect_success 'unstashing in a subdirectory' '
88 git reset --hard HEAD &&
96 test_expect_success 'stash drop complains of extra options' '
97 test_must_fail git stash drop --foo
100 test_expect_success 'drop top stash' '
102 git stash list >expected &&
106 git stash list >actual &&
107 test_cmp expected actual &&
109 test 3 = $(cat file) &&
110 test 1 = $(git show :file) &&
111 test 1 = $(git show HEAD:file)
114 test_expect_success 'drop middle stash' '
120 git stash drop stash@{1} &&
121 test 2 = $(git stash list | wc -l) &&
123 test 9 = $(cat file) &&
124 test 1 = $(git show :file) &&
125 test 1 = $(git show HEAD:file) &&
129 test 3 = $(cat file) &&
130 test 1 = $(git show :file) &&
131 test 1 = $(git show HEAD:file)
134 test_expect_success 'drop middle stash by index' '
141 test 2 = $(git stash list | wc -l) &&
143 test 9 = $(cat file) &&
144 test 1 = $(git show :file) &&
145 test 1 = $(git show HEAD:file) &&
149 test 3 = $(cat file) &&
150 test 1 = $(git show :file) &&
151 test 1 = $(git show HEAD:file)
154 test_expect_success 'stash pop' '
157 test 3 = $(cat file) &&
158 test 1 = $(git show :file) &&
159 test 1 = $(git show HEAD:file) &&
160 test 0 = $(git stash list | wc -l)
164 diff --git a/file2 b/file2
166 index 0000000..1fe912c
174 diff --git a/file b/file
175 index 257cc56..5716ca5 100644
184 diff --git a/file b/file
185 index 7601807..5716ca5 100644
191 diff --git a/file2 b/file2
193 index 0000000..1fe912c
200 test_expect_success 'stash branch' '
202 git commit file -m first &&
208 git commit file -m second &&
209 git stash branch stashbranch &&
210 test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
211 test $(git rev-parse HEAD) = $(git rev-parse master^) &&
212 git diff --cached >output &&
213 test_cmp expect output &&
215 test_cmp expect1 output &&
217 git commit -m alternate\ second &&
218 git diff master..stashbranch >output &&
219 test_cmp output expect2 &&
220 test 0 = $(git stash list | wc -l)
223 test_expect_success 'apply -q is quiet' '
226 git stash apply -q >output.out 2>&1 &&
227 test_must_be_empty output.out
230 test_expect_success 'save -q is quiet' '
231 git stash save --quiet >output.out 2>&1 &&
232 test_must_be_empty output.out
235 test_expect_success 'pop -q is quiet' '
236 git stash pop -q >output.out 2>&1 &&
237 test_must_be_empty output.out
240 test_expect_success 'pop -q --index works and is quiet' '
243 git stash save --quiet &&
244 git stash pop -q --index >output.out 2>&1 &&
245 test foo = "$(git show :file)" &&
246 test_must_be_empty output.out
249 test_expect_success 'drop -q is quiet' '
251 git stash drop -q >output.out 2>&1 &&
252 test_must_be_empty output.out
255 test_expect_success 'stash -k' '
260 test bar,bar4 = $(cat file),$(cat file2)
263 test_expect_success 'stash --no-keep-index' '
267 git stash --no-keep-index &&
268 test bar,bar2 = $(cat file),$(cat file2)
271 test_expect_success 'stash --invalid-option' '
275 test_must_fail git stash --invalid-option &&
276 test_must_fail git stash save --invalid-option &&
277 test bar5,bar6 = $(cat file),$(cat file2)
280 test_expect_success 'stash an added file' '
284 git stash save "added file" &&
287 test new = "$(cat file3)"
290 test_expect_success 'stash --intent-to-add file' '
293 git add --intent-to-add file4 &&
294 test_when_finished "git rm -f file4" &&
295 test_must_fail git stash
298 test_expect_success 'stash rm then recreate' '
302 git stash save "rm then recreate" &&
303 test bar = "$(cat file)" &&
305 test bar7 = "$(cat file)"
308 test_expect_success 'stash rm and ignore' '
311 echo file >.gitignore &&
312 git stash save "rm and ignore" &&
313 test bar = "$(cat file)" &&
314 test file = "$(cat .gitignore)" &&
317 test file = "$(cat .gitignore)"
320 test_expect_success 'stash rm and ignore (stage .gitignore)' '
323 echo file >.gitignore &&
324 git add .gitignore &&
325 git stash save "rm and ignore (stage .gitignore)" &&
326 test bar = "$(cat file)" &&
327 ! test -r .gitignore &&
330 test file = "$(cat .gitignore)"
333 test_expect_success SYMLINKS 'stash file to symlink' '
337 git stash save "file to symlink" &&
339 test bar = "$(cat file)" &&
341 case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
344 test_expect_success SYMLINKS 'stash file to symlink (stage rm)' '
348 git stash save "file to symlink (stage rm)" &&
350 test bar = "$(cat file)" &&
352 case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
355 test_expect_success SYMLINKS 'stash file to symlink (full stage)' '
360 git stash save "file to symlink (full stage)" &&
362 test bar = "$(cat file)" &&
364 case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
367 # This test creates a commit with a symlink used for the following tests
369 test_expect_success 'stash symlink to file' '
371 test_ln_s_add file filelink &&
372 git commit -m "Add symlink" &&
375 git stash save "symlink to file"
378 test_expect_success SYMLINKS 'this must have re-created the symlink' '
380 case "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac
383 test_expect_success 'unstash must re-create the file' '
385 ! test -h filelink &&
386 test bar = "$(cat file)"
389 test_expect_success 'stash symlink to file (stage rm)' '
393 git stash save "symlink to file (stage rm)"
396 test_expect_success SYMLINKS 'this must have re-created the symlink' '
398 case "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac
401 test_expect_success 'unstash must re-create the file' '
403 ! test -h filelink &&
404 test bar = "$(cat file)"
407 test_expect_success 'stash symlink to file (full stage)' '
412 git stash save "symlink to file (full stage)"
415 test_expect_success SYMLINKS 'this must have re-created the symlink' '
417 case "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac
420 test_expect_success 'unstash must re-create the file' '
422 ! test -h filelink &&
423 test bar = "$(cat file)"
426 test_expect_failure 'stash directory to file' '
429 echo foo >dir/file &&
431 git commit -m "Add file in dir" &&
434 git stash save "directory to file" &&
436 test foo = "$(cat dir/file)" &&
437 test_must_fail git stash apply &&
438 test bar = "$(cat dir)" &&
439 git reset --soft HEAD^
442 test_expect_failure 'stash file to directory' '
446 echo foo >file/file &&
447 git stash save "file to directory" &&
449 test bar = "$(cat file)" &&
452 test foo = "$(cat file/file)"
455 test_expect_success 'giving too many ref arguments does not modify files' '
457 test_when_finished "git reset --hard HEAD" &&
462 test-tool chmtime =123456789 file2 &&
463 for type in apply pop "branch stash-branch"
465 test_must_fail git stash $type stash@{0} stash@{1} 2>err &&
466 test_i18ngrep "Too many revisions" err &&
467 test 123456789 = $(test-tool chmtime -g file2) || return 1
471 test_expect_success 'drop: too many arguments errors out (does nothing)' '
472 git stash list >expect &&
473 test_must_fail git stash drop stash@{0} stash@{1} 2>err &&
474 test_i18ngrep "Too many revisions" err &&
475 git stash list >actual &&
476 test_cmp expect actual
479 test_expect_success 'show: too many arguments errors out (does nothing)' '
480 test_must_fail git stash show stash@{0} stash@{1} 2>err 1>out &&
481 test_i18ngrep "Too many revisions" err &&
482 test_must_be_empty out
485 test_expect_success 'stash create - no changes' '
487 test_when_finished "git reset --hard HEAD" &&
489 git stash create >actual &&
490 test_must_be_empty actual
493 test_expect_success 'stash branch - no stashes on stack, stash-like argument' '
495 test_when_finished "git reset --hard HEAD" &&
498 STASH_ID=$(git stash create) &&
500 git stash branch stash-branch ${STASH_ID} &&
501 test_when_finished "git reset --hard HEAD && git checkout master &&
502 git branch -D stash-branch" &&
503 test $(git ls-files --modified | wc -l) -eq 1
506 test_expect_success 'stash branch - stashes on stack, stash-like argument' '
508 test_when_finished "git reset --hard HEAD" &&
512 test_when_finished "git stash drop" &&
514 STASH_ID=$(git stash create) &&
516 git stash branch stash-branch ${STASH_ID} &&
517 test_when_finished "git reset --hard HEAD && git checkout master &&
518 git branch -D stash-branch" &&
519 test $(git ls-files --modified | wc -l) -eq 1
522 test_expect_success 'stash branch complains with no arguments' '
523 test_must_fail git stash branch 2>err &&
524 test_i18ngrep "No branch name specified" err
527 test_expect_success 'stash show format defaults to --stat' '
529 test_when_finished "git reset --hard HEAD" &&
533 test_when_finished "git stash drop" &&
535 STASH_ID=$(git stash create) &&
537 cat >expected <<-EOF &&
539 1 file changed, 1 insertion(+)
541 git stash show ${STASH_ID} >actual &&
542 test_i18ncmp expected actual
545 test_expect_success 'stash show - stashes on stack, stash-like argument' '
547 test_when_finished "git reset --hard HEAD" &&
551 test_when_finished "git stash drop" &&
553 STASH_ID=$(git stash create) &&
555 echo "1 0 file" >expected &&
556 git stash show --numstat ${STASH_ID} >actual &&
557 test_cmp expected actual
560 test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
562 test_when_finished "git reset --hard HEAD" &&
566 test_when_finished "git stash drop" &&
568 STASH_ID=$(git stash create) &&
570 cat >expected <<-EOF &&
571 diff --git a/file b/file
572 index 7601807..935fbd3 100644
579 git stash show -p ${STASH_ID} >actual &&
580 test_cmp expected actual
583 test_expect_success 'stash show - no stashes on stack, stash-like argument' '
585 test_when_finished "git reset --hard HEAD" &&
588 STASH_ID=$(git stash create) &&
590 echo "1 0 file" >expected &&
591 git stash show --numstat ${STASH_ID} >actual &&
592 test_cmp expected actual
595 test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
597 test_when_finished "git reset --hard HEAD" &&
600 STASH_ID=$(git stash create) &&
602 cat >expected <<-EOF &&
603 diff --git a/file b/file
604 index 7601807..71b52c4 100644
611 git stash show -p ${STASH_ID} >actual &&
612 test_cmp expected actual
615 test_expect_success 'stash show --patience shows diff' '
618 STASH_ID=$(git stash create) &&
620 cat >expected <<-EOF &&
621 diff --git a/file b/file
622 index 7601807..71b52c4 100644
629 git stash show --patience ${STASH_ID} >actual &&
630 test_cmp expected actual
633 test_expect_success 'drop: fail early if specified stash is not a stash ref' '
635 test_when_finished "git reset --hard HEAD && git stash clear" &&
641 test_must_fail git stash drop $(git rev-parse stash@{0}) &&
643 test bar = "$(cat file)" &&
644 git reset --hard HEAD
647 test_expect_success 'pop: fail early if specified stash is not a stash ref' '
649 test_when_finished "git reset --hard HEAD && git stash clear" &&
655 test_must_fail git stash pop $(git rev-parse stash@{0}) &&
657 test bar = "$(cat file)" &&
658 git reset --hard HEAD
661 test_expect_success 'ref with non-existent reflog' '
667 test_must_fail git rev-parse --quiet --verify does-not-exist &&
668 test_must_fail git stash drop does-not-exist &&
669 test_must_fail git stash drop does-not-exist@{0} &&
670 test_must_fail git stash pop does-not-exist &&
671 test_must_fail git stash pop does-not-exist@{0} &&
672 test_must_fail git stash apply does-not-exist &&
673 test_must_fail git stash apply does-not-exist@{0} &&
674 test_must_fail git stash show does-not-exist &&
675 test_must_fail git stash show does-not-exist@{0} &&
676 test_must_fail git stash branch tmp does-not-exist &&
677 test_must_fail git stash branch tmp does-not-exist@{0} &&
681 test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
683 test_must_fail git stash drop stash@{0} &&
688 test_must_fail git stash drop stash@{1} &&
689 test_must_fail git stash pop stash@{1} &&
690 test_must_fail git stash apply stash@{1} &&
691 test_must_fail git stash show stash@{1} &&
692 test_must_fail git stash branch tmp stash@{1} &&
696 test_expect_success 'invalid ref of the form "n", n >= N' '
698 test_must_fail git stash drop 0 &&
703 test_must_fail git stash drop 1 &&
704 test_must_fail git stash pop 1 &&
705 test_must_fail git stash apply 1 &&
706 test_must_fail git stash show 1 &&
707 test_must_fail git stash branch tmp 1 &&
711 test_expect_success 'valid ref of the form "n", n < N' '
718 git stash branch tmp 0 &&
719 git checkout master &&
726 test_must_fail git stash drop
729 test_expect_success 'branch: do not drop the stash if the branch exists' '
733 git commit -m initial &&
736 test_must_fail git stash branch master stash@{0} &&
737 git rev-parse stash@{0} --
740 test_expect_success 'branch: should not drop the stash if the apply fails' '
742 git reset HEAD~1 --hard &&
745 git commit -m initial &&
749 test_when_finished "git checkout master" &&
750 test_must_fail git stash branch new_branch stash@{0} &&
751 git rev-parse stash@{0} --
754 test_expect_success 'apply: show same status as git status (relative to ./)' '
756 echo 1 >subdir/subfile1 &&
757 echo 2 >subdir/subfile2 &&
758 git add subdir/subfile1 &&
759 git commit -m subdir &&
764 git status >../expect &&
766 sane_unset GIT_MERGE_VERBOSITY &&
769 sed -e 1d >actual && # drop "Saved..."
770 test_i18ncmp expect actual
774 diff --git a/HEAD b/HEAD
776 index 0000000..fe0cbee
783 test_expect_success 'stash where working directory contains "HEAD" file' '
786 echo file-not-a-ref >HEAD &&
790 git diff-files --quiet &&
791 git diff-index --cached --quiet HEAD &&
792 test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
793 git diff stash^..stash >output &&
794 test_cmp expect output
797 test_expect_success 'store called with invalid commit' '
798 test_must_fail git stash store foo
801 test_expect_success 'store updates stash ref and reflog' '
806 STASH_ID=$(git stash create) &&
808 test_path_is_missing bazzy &&
809 git stash store -m quuxery $STASH_ID &&
810 test $(git rev-parse stash) = $STASH_ID &&
811 git reflog --format=%H stash| grep $STASH_ID &&
816 test_expect_success 'handle stash specification with spaces' '
820 stamp=$(git log -g --format="%cd" -1 refs/stash) &&
824 git stash apply "stash@{$stamp}" &&
828 test_expect_success 'setup stash with index and worktree changes' '
833 echo working >file &&
837 test_expect_success 'stash list implies --first-parent -m' '
838 cat >expect <<-EOF &&
841 diff --git a/file b/file
842 index 257cc56..d26b33d 100644
849 git stash list --format=%gd -p >actual &&
850 test_cmp expect actual
853 test_expect_success 'stash list --cc shows combined diff' '
854 cat >expect <<-\EOF &&
858 index 257cc56,9015a7a..d26b33d
861 @@@ -1,1 -1,1 +1,1 @@@
866 git stash list --format=%gd -p --cc >actual &&
867 test_cmp expect actual
870 test_expect_success 'stash is not confused by partial renames' '
875 test_path_is_file renamed &&
876 test_path_is_missing file
879 test_expect_success 'push -m shows right message' '
882 git stash push -m "test message" &&
883 echo "stash@{0}: On master: test message" >expect &&
884 git stash list -1 >actual &&
885 test_cmp expect actual
888 test_expect_success 'push -m also works without space' '
891 git stash push -m"unspaced test message" &&
892 echo "stash@{0}: On master: unspaced test message" >expect &&
893 git stash list -1 >actual &&
894 test_cmp expect actual
897 test_expect_success 'store -m foo shows right message' '
902 STASH_ID=$(git stash create) &&
903 git stash store -m "store m" $STASH_ID &&
904 echo "stash@{0}: store m" >expect &&
905 git stash list -1 >actual &&
906 test_cmp expect actual
909 test_expect_success 'store -mfoo shows right message' '
914 STASH_ID=$(git stash create) &&
915 git stash store -m"store mfoo" $STASH_ID &&
916 echo "stash@{0}: store mfoo" >expect &&
917 git stash list -1 >actual &&
918 test_cmp expect actual
921 test_expect_success 'store --message=foo shows right message' '
926 STASH_ID=$(git stash create) &&
927 git stash store --message="store message=foo" $STASH_ID &&
928 echo "stash@{0}: store message=foo" >expect &&
929 git stash list -1 >actual &&
930 test_cmp expect actual
933 test_expect_success 'store --message foo shows right message' '
938 STASH_ID=$(git stash create) &&
939 git stash store --message "store message foo" $STASH_ID &&
940 echo "stash@{0}: store message foo" >expect &&
941 git stash list -1 >actual &&
942 test_cmp expect actual
945 test_expect_success 'push -mfoo uses right message' '
948 git stash push -m"test mfoo" &&
949 echo "stash@{0}: On master: test mfoo" >expect &&
950 git stash list -1 >actual &&
951 test_cmp expect actual
954 test_expect_success 'push --message foo is synonym for -mfoo' '
957 git stash push --message "test message foo" &&
958 echo "stash@{0}: On master: test message foo" >expect &&
959 git stash list -1 >actual &&
960 test_cmp expect actual
963 test_expect_success 'push --message=foo is synonym for -mfoo' '
966 git stash push --message="test message=foo" &&
967 echo "stash@{0}: On master: test message=foo" >expect &&
968 git stash list -1 >actual &&
969 test_cmp expect actual
972 test_expect_success 'push -m shows right message' '
975 git stash push -m "test m foo" &&
976 echo "stash@{0}: On master: test m foo" >expect &&
977 git stash list -1 >actual &&
978 test_cmp expect actual
981 test_expect_success 'create stores correct message' '
984 STASH_ID=$(git stash create "create test message") &&
985 echo "On master: create test message" >expect &&
986 git show --pretty=%s -s ${STASH_ID} >actual &&
987 test_cmp expect actual
990 test_expect_success 'create with multiple arguments for the message' '
993 STASH_ID=$(git stash create test untracked) &&
994 echo "On master: test untracked" >expect &&
995 git show --pretty=%s -s ${STASH_ID} >actual &&
996 test_cmp expect actual
999 test_expect_success 'create in a detached state' '
1000 test_when_finished "git checkout master" &&
1001 git checkout HEAD~1 &&
1004 STASH_ID=$(git stash create) &&
1005 HEAD_ID=$(git rev-parse --short HEAD) &&
1006 echo "WIP on (no branch): ${HEAD_ID} initial" >expect &&
1007 git show --pretty=%s -s ${STASH_ID} >actual &&
1008 test_cmp expect actual
1011 test_expect_success 'stash -- <pathspec> stashes and restores the file' '
1015 git stash push -- foo &&
1016 test_path_is_file bar &&
1017 test_path_is_missing foo &&
1019 test_path_is_file foo &&
1020 test_path_is_file bar
1023 test_expect_success 'stash -- <pathspec> stashes in subdirectory' '
1030 git stash push -- ../foo
1032 test_path_is_file bar &&
1033 test_path_is_missing foo &&
1035 test_path_is_file foo &&
1036 test_path_is_file bar
1039 test_expect_success 'stash with multiple pathspec arguments' '
1043 git add foo bar extra &&
1044 git stash push -- foo bar &&
1045 test_path_is_missing bar &&
1046 test_path_is_missing foo &&
1047 test_path_is_file extra &&
1049 test_path_is_file foo &&
1050 test_path_is_file bar &&
1051 test_path_is_file extra
1054 test_expect_success 'stash with file including $IFS character' '
1059 git stash push -- "foo b*" &&
1060 test_path_is_missing "foo bar" &&
1061 test_path_is_file foo &&
1062 test_path_is_file bar &&
1064 test_path_is_file "foo bar" &&
1065 test_path_is_file foo &&
1066 test_path_is_file bar
1069 test_expect_success 'stash with pathspec matching multiple paths' '
1070 echo original >file &&
1071 echo original >other-file &&
1072 git commit -m "two" file other-file &&
1073 echo modified >file &&
1074 echo modified >other-file &&
1075 git stash push -- "*file" &&
1076 echo original >expect &&
1077 test_cmp expect file &&
1078 test_cmp expect other-file &&
1080 echo modified >expect &&
1081 test_cmp expect file &&
1082 test_cmp expect other-file
1085 test_expect_success 'stash push -p with pathspec shows no changes only once' '
1088 git commit -m "tmp" &&
1089 git stash push -p foo >actual &&
1090 echo "No local changes to save" >expect &&
1091 git reset --hard HEAD~ &&
1092 test_i18ncmp expect actual
1095 test_expect_success 'push <pathspec>: show no changes when there are none' '
1098 git commit -m "tmp" &&
1099 git stash push foo >actual &&
1100 echo "No local changes to save" >expect &&
1101 git reset --hard HEAD~ &&
1102 test_i18ncmp expect actual
1105 test_expect_success 'push: <pathspec> not in the repository errors out' '
1107 test_must_fail git stash push untracked &&
1108 test_path_is_file untracked
1111 test_expect_success 'push: -q is quiet with changes' '
1114 git stash push -q >output 2>&1 &&
1115 test_must_be_empty output
1118 test_expect_success 'push: -q is quiet with no changes' '
1119 git stash push -q >output 2>&1 &&
1120 test_must_be_empty output
1123 test_expect_success 'push: -q is quiet even if there is no initial commit' '
1125 test_when_finished rm -rf foo_dir &&
1129 test_must_fail git stash push -q >output 2>&1 &&
1130 test_must_be_empty output
1134 test_expect_success 'untracked files are left in place when -u is not given' '
1138 git stash push file &&
1139 test_path_is_file untracked
1142 test_expect_success 'stash without verb with pathspec' '
1147 git stash -- "foo b*" &&
1148 test_path_is_missing "foo bar" &&
1149 test_path_is_file foo &&
1150 test_path_is_file bar &&
1152 test_path_is_file "foo bar" &&
1153 test_path_is_file foo &&
1154 test_path_is_file bar
1157 test_expect_success 'stash -k -- <pathspec> leaves unstaged files intact' '
1162 git commit -m "test" &&
1165 git stash -k -- foo &&
1166 test "",bar = $(cat foo),$(cat bar) &&
1168 test foo,bar = $(cat foo),$(cat bar)
1171 test_expect_success 'stash -- <subdir> leaves untracked files in subdir intact' '
1173 >subdir/untracked &&
1176 git add subdir/tracked* &&
1177 git stash -- subdir/ &&
1178 test_path_is_missing subdir/tracked1 &&
1179 test_path_is_missing subdir/tracked2 &&
1180 test_path_is_file subdir/untracked &&
1182 test_path_is_file subdir/tracked1 &&
1183 test_path_is_file subdir/tracked2 &&
1184 test_path_is_file subdir/untracked
1187 test_expect_success 'stash -- <subdir> works with binary files' '
1189 >subdir/untracked &&
1191 cp "$TEST_DIRECTORY"/test-binary-1.png subdir/tracked-binary &&
1192 git add subdir/tracked* &&
1193 git stash -- subdir/ &&
1194 test_path_is_missing subdir/tracked &&
1195 test_path_is_missing subdir/tracked-binary &&
1196 test_path_is_file subdir/untracked &&
1198 test_path_is_file subdir/tracked &&
1199 test_path_is_file subdir/tracked-binary &&
1200 test_path_is_file subdir/untracked
1203 test_expect_success 'stash with user.name and user.email set works' '
1204 test_config user.name "A U Thor" &&
1205 test_config user.email "a.u@thor" &&
1209 test_expect_success 'stash works when user.name and user.email are not set' '
1213 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" >expect &&
1215 git show -s --format="%an <%ae>" refs/stash >actual &&
1216 test_cmp expect actual &&
1219 test_config user.useconfigonly true &&
1220 test_config stash.usebuiltin true &&
1222 sane_unset GIT_AUTHOR_NAME &&
1223 sane_unset GIT_AUTHOR_EMAIL &&
1224 sane_unset GIT_COMMITTER_NAME &&
1225 sane_unset GIT_COMMITTER_EMAIL &&
1226 test_unconfig user.email &&
1227 test_unconfig user.name &&
1228 test_must_fail git commit -m "should fail" &&
1229 echo "git stash <git@stash>" >expect &&
1232 git show -s --format="%an <%ae>" refs/stash >actual &&
1233 test_cmp expect actual
1237 test_expect_success 'stash --keep-index with file deleted in index does not resurrect it on disk' '
1238 test_commit to-remove to-remove &&
1240 git stash --keep-index &&
1241 test_path_is_missing to-remove
1244 test_expect_success 'stash handles skip-worktree entries nicely' '
1246 echo changed >A.t &&
1248 git update-index --skip-worktree A.t &&
1252 git rev-parse --verify refs/stash:A.t