Git 2.46-rc2
[alt-git.git] / t / t3906-stash-submodule.sh
blob0f61f01ef43b2c889bd2850fbd41c4a42f52c6e6
1 #!/bin/sh
3 test_description='stash can handle submodules'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-submodule-update.sh
9 git_stash () {
10 git status -su >expect &&
11 ls -1pR * >>expect &&
12 may_only_be_test_must_fail "$2" &&
13 $2 git read-tree -u -m "$1" &&
14 if test -n "$2"
15 then
16 return
17 fi &&
18 git stash &&
19 git status -su >actual &&
20 ls -1pR * >>actual &&
21 test_cmp expect actual &&
22 git stash apply
25 KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES=1
26 KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1
27 KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
28 test_submodule_switch_func "git_stash"
30 setup_basic () {
31 test_when_finished "rm -rf main sub" &&
32 git init sub &&
34 cd sub &&
35 test_commit sub_file
36 ) &&
37 git init main &&
39 cd main &&
40 git -c protocol.file.allow=always submodule add ../sub &&
41 test_commit main_file
45 test_expect_success 'stash push with submodule.recurse=true preserves dirty submodule worktree' '
46 setup_basic &&
48 cd main &&
49 git config submodule.recurse true &&
50 echo "x" >main_file.t &&
51 echo "y" >sub/sub_file.t &&
52 git stash push &&
53 test_must_fail git -C sub diff --quiet
57 test_expect_success 'stash push and pop with submodule.recurse=true preserves dirty submodule worktree' '
58 setup_basic &&
60 cd main &&
61 git config submodule.recurse true &&
62 echo "x" >main_file.t &&
63 echo "y" >sub/sub_file.t &&
64 git stash push &&
65 git stash pop &&
66 test_must_fail git -C sub diff --quiet
70 test_done