Code

Merge branch 'jk/maint-stash-oob' into maint
[git.git] / t / t3903-stash.sh
index 3c91f48b204764804fbf6d1cef1133d3fe518b87..5c725406422dcedb6c6d5e5d61cfc80f87d3595c 100755 (executable)
@@ -43,14 +43,26 @@ test_expect_success 'applying bogus stash does nothing' '
        test_cmp expect file
 '
 
-test_expect_success 'apply needs clean working directory' '
-       echo 4 > other-file &&
+test_expect_success 'apply does not need clean working directory' '
+       echo 4 >other-file &&
        git add other-file &&
-       echo 5 > other-file &&
-       test_must_fail git stash apply
+       echo 5 >other-file &&
+       git stash apply &&
+       echo 3 >expect &&
+       test_cmp expect file
+'
+
+test_expect_success 'apply does not clobber working directory changes' '
+       git reset --hard &&
+       echo 4 >file &&
+       test_must_fail git stash apply &&
+       echo 4 >expect &&
+       test_cmp expect file
 '
 
 test_expect_success 'apply stashed changes' '
+       git reset --hard &&
+       echo 5 >other-file &&
        git add other-file &&
        test_tick &&
        git commit -m other-file &&
@@ -224,6 +236,14 @@ test_expect_success 'stash -k' '
        test bar,bar4 = $(cat file),$(cat file2)
 '
 
+test_expect_success 'stash --no-keep-index' '
+       echo bar33 > file &&
+       echo bar44 > file2 &&
+       git add file2 &&
+       git stash --no-keep-index &&
+       test bar,bar2 = $(cat file),$(cat file2)
+'
+
 test_expect_success 'stash --invalid-option' '
        echo bar5 > file &&
        echo bar6 > file2 &&
@@ -562,4 +582,23 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
        git rev-parse stash@{0} --
 '
 
+test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
+       git stash clear &&
+       echo 1 >subdir/subfile1 &&
+       echo 2 >subdir/subfile2 &&
+       git add subdir/subfile1 &&
+       git commit -m subdir &&
+       (
+               cd subdir &&
+               echo x >subfile1 &&
+               echo x >../file &&
+               git status >../expect &&
+               git stash &&
+               sane_unset GIT_MERGE_VERBOSITY &&
+               git stash apply
+       ) |
+       sed -e 1,2d >actual && # drop "Saved..." and "HEAD is now..."
+       test_cmp expect actual
+'
+
 test_done