diff options
Diffstat (limited to 't/t3600-rm.sh')
-rwxr-xr-x | t/t3600-rm.sh | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index efec8d13b6..bb9ef35dac 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -5,6 +5,9 @@ test_description='Test of the various options to git rm.' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh # Setup some files to be removed, some with funny characters @@ -240,7 +243,7 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' test_path_is_missing frotz/nitfol ' -test_expect_success 'choking "git rm" should not let it die with cruft' ' +choke_git_rm_setup() { git reset -q --hard && test_when_finished "rm -f .git/index.lock && git reset -q --hard" && i=0 && @@ -249,12 +252,24 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' do echo "100644 $hash 0 some-file-$i" i=$(( $i + 1 )) - done | git update-index --index-info && + done | git update-index --index-info +} + +test_expect_success 'choking "git rm" should not let it die with cruft (induce SIGPIPE)' ' + choke_git_rm_setup && # git command is intentionally placed upstream of pipe to induce SIGPIPE git rm -n "some-file-*" | : && test_path_is_missing .git/index.lock ' + +test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' ' + choke_git_rm_setup && + OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) && + test_match_signal 13 "$OUT" && + test_path_is_missing .git/index.lock +' + test_expect_success 'Resolving by removal is not a warning-worthy event' ' git reset -q --hard && test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" && @@ -439,7 +454,7 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule git add .gitmodules && echo "warning: Could not find section in .gitmodules where path=submod" >expect.err && git rm submod >actual 2>actual.err && - test_i18ncmp expect.err actual.err && + test_cmp expect.err actual.err && test_path_is_missing submod && test_path_is_missing submod/.git && git status -s -uno >actual && @@ -483,16 +498,16 @@ test_expect_success 'setup submodule conflict' ' echo 1 >nitfol && git add nitfol && git commit -m "added nitfol 1" && - git checkout -b branch2 master && + git checkout -b branch2 main && echo 2 >nitfol && git add nitfol && git commit -m "added nitfol 2" && - git checkout -b conflict1 master && + git checkout -b conflict1 main && git -C submod fetch && git -C submod checkout branch1 && git add submod && git commit -m "submod 1" && - git checkout -b conflict2 master && + git checkout -b conflict2 main && git -C submod checkout branch2 && git add submod && git commit -m "submod 2" @@ -604,7 +619,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' ' ' test_expect_success 'rm of a populated submodule with a .git directory migrates git dir' ' - git checkout -f master && + git checkout -f main && git reset --hard && git submodule update && ( @@ -717,7 +732,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual git checkout HEAD^ && git submodule update && git checkout -q HEAD^ && - git checkout -q master 2>actual && + git checkout -q main 2>actual && test_i18ngrep "^warning: unable to rmdir '\''submod'\'':" actual && git status -s submod >actual && echo "?? submod/" >expected && @@ -809,7 +824,7 @@ test_expect_success 'rm files with different staged content' ' echo content1 >foo.txt && echo content1 >bar.txt && test_must_fail git rm foo.txt bar.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm files with different staged content without hints' ' @@ -822,7 +837,7 @@ test_expect_success 'rm files with different staged content without hints' ' echo content2 >foo.txt && echo content2 >bar.txt && test_must_fail git -c advice.rmhints=false rm foo.txt bar.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with local modification' ' @@ -834,7 +849,7 @@ test_expect_success 'rm file with local modification' ' git commit -m "testing rm 3" && echo content3 >foo.txt && test_must_fail git rm foo.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with local modification without hints' ' @@ -844,7 +859,7 @@ test_expect_success 'rm file with local modification without hints' ' EOF echo content4 >bar.txt && test_must_fail git -c advice.rmhints=false rm bar.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with changes in the index' ' @@ -857,7 +872,7 @@ test_expect_success 'rm file with changes in the index' ' echo content5 >foo.txt && git add foo.txt && test_must_fail git rm foo.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm file with changes in the index without hints' ' @@ -866,7 +881,7 @@ test_expect_success 'rm file with changes in the index without hints' ' foo.txt EOF test_must_fail git -c advice.rmhints=false rm foo.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm files with two different errors' ' @@ -885,7 +900,7 @@ test_expect_success 'rm files with two different errors' ' echo content6 >bar1.txt && git add bar1.txt && test_must_fail git rm bar1.txt foo1.txt 2>actual && - test_i18ncmp expect actual + test_cmp expect actual ' test_expect_success 'rm empty string should fail' ' |