Git fork
at reftables-rust 69 lines 1.5 kB view raw
1#!/bin/sh 2 3test_description='stash can handle submodules' 4 5. ./test-lib.sh 6. "$TEST_DIRECTORY"/lib-submodule-update.sh 7 8git_stash () { 9 git status -su >expect && 10 ls -1pR * >>expect && 11 may_only_be_test_must_fail "$2" && 12 $2 git read-tree -u -m "$1" && 13 if test -n "$2" 14 then 15 return 16 fi && 17 git stash && 18 git status -su >actual && 19 ls -1pR * >>actual && 20 test_cmp expect actual && 21 git stash apply 22} 23 24KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES=1 25KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1 26KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 27test_submodule_switch_func "git_stash" 28 29setup_basic () { 30 test_when_finished "rm -rf main sub" && 31 git init sub && 32 ( 33 cd sub && 34 test_commit sub_file 35 ) && 36 git init main && 37 ( 38 cd main && 39 git -c protocol.file.allow=always submodule add ../sub && 40 test_commit main_file 41 ) 42} 43 44test_expect_success 'stash push with submodule.recurse=true preserves dirty submodule worktree' ' 45 setup_basic && 46 ( 47 cd main && 48 git config submodule.recurse true && 49 echo "x" >main_file.t && 50 echo "y" >sub/sub_file.t && 51 git stash push && 52 test_must_fail git -C sub diff --quiet 53 ) 54' 55 56test_expect_success 'stash push and pop with submodule.recurse=true preserves dirty submodule worktree' ' 57 setup_basic && 58 ( 59 cd main && 60 git config submodule.recurse true && 61 echo "x" >main_file.t && 62 echo "y" >sub/sub_file.t && 63 git stash push && 64 git stash pop && 65 test_must_fail git -C sub diff --quiet 66 ) 67' 68 69test_done