A GSoC micro.
* ra/t3600-test-path-funcs:
t3600: use helpers to replace test -d/f/e/s <path>
t3600: modernize style
test functions: add function `test_file_not_empty`
@ -159,15 +160,15 @@ test_expect_success 'Re-add foo and baz for HEAD tests' '
@@ -159,15 +160,15 @@ test_expect_success 'Re-add foo and baz for HEAD tests' '
test_expect_success 'foo is different in index from HEAD -- rm should refuse' '
test_must_fail git rm foo baz &&
test -f foo &&
test -f baz &&
test_path_is_file foo &&
test_path_is_file baz &&
git ls-files --error-unmatch foo baz
'
test_expect_success 'but with -f it should work.' '
test_expect_success 'refresh index before checking if it is up-to-date' '
git reset --hard &&
test-tool chmtime -86400 frotz/nitfol &&
git rm frotz/nitfol &&
test ! -f frotz/nitfol
test_path_is_missing frotz/nitfol
'
test_expect_success 'choking "git rm" should not let it die with cruft' '
@ -242,8 +245,8 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
@@ -242,8 +245,8 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
@ -314,7 +317,7 @@ test_expect_success 'rm removes work tree of unmodified submodules' '
@@ -314,7 +317,7 @@ test_expect_success 'rm removes work tree of unmodified submodules' '
git reset --hard &&
git submodule update &&
git rm submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
@ -325,7 +328,7 @@ test_expect_success 'rm removes a submodule with a trailing /' '
@@ -325,7 +328,7 @@ test_expect_success 'rm removes a submodule with a trailing /' '
git reset --hard &&
git submodule update &&
git rm submod/ &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -343,12 +346,12 @@ test_expect_success 'rm of a populated submodule with different HEAD fails unles
@@ -343,12 +346,12 @@ test_expect_success 'rm of a populated submodule with different HEAD fails unles
git submodule update &&
git -C submod checkout HEAD^ &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
@ -359,8 +362,8 @@ test_expect_success 'rm --cached leaves work tree of populated submodules and .g
@@ -359,8 +362,8 @@ test_expect_success 'rm --cached leaves work tree of populated submodules and .g
git reset --hard &&
git submodule update &&
git rm --cached submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno >actual &&
test_cmp expect.cached actual &&
git config -f .gitmodules submodule.sub.url &&
@ -371,7 +374,7 @@ test_expect_success 'rm --dry-run does not touch the submodule or .gitmodules' '
@@ -371,7 +374,7 @@ test_expect_success 'rm --dry-run does not touch the submodule or .gitmodules' '
git reset --hard &&
git submodule update &&
git rm -n submod &&
test -f submod/.git &&
test_path_is_file submod/.git &&
git diff-index --exit-code HEAD
'
@ -381,8 +384,8 @@ test_expect_success 'rm does not complain when no .gitmodules file is found' '
@@ -381,8 +384,8 @@ test_expect_success 'rm does not complain when no .gitmodules file is found' '
git rm .gitmodules &&
git rm submod >actual 2>actual.err &&
test_must_be_empty actual.err &&
! test -d submod &&
! test -f submod/.git &&
test_path_is_missing submod &&
test_path_is_missing submod/.git &&
git status -s -uno >actual &&
test_cmp expect.both_deleted actual
'
@ -392,15 +395,15 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta
@@ -392,15 +395,15 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta
@ -413,8 +416,8 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule
@@ -413,8 +416,8 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule
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 -d submod &&
! test -f submod/.git &&
test_path_is_missing submod &&
test_path_is_missing submod/.git &&
git status -s -uno >actual &&
test_cmp expect actual
'
@ -424,12 +427,12 @@ test_expect_success 'rm of a populated submodule with modifications fails unless
@@ -424,12 +427,12 @@ test_expect_success 'rm of a populated submodule with modifications fails unless
git submodule update &&
echo X >submod/empty &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified_inside actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -439,12 +442,12 @@ test_expect_success 'rm of a populated submodule with untracked files fails unle
@@ -439,12 +442,12 @@ test_expect_success 'rm of a populated submodule with untracked files fails unle
git submodule update &&
echo X >submod/untracked &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified_untracked actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -481,7 +484,7 @@ test_expect_success 'rm removes work tree of unmodified conflicted submodule' '
@@ -481,7 +484,7 @@ test_expect_success 'rm removes work tree of unmodified conflicted submodule' '
git submodule update &&
test_must_fail git merge conflict2 &&
git rm submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -493,12 +496,12 @@ test_expect_success 'rm of a conflicted populated submodule with different HEAD
@@ -493,12 +496,12 @@ test_expect_success 'rm of a conflicted populated submodule with different HEAD
git -C submod checkout HEAD^ &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
@ -512,12 +515,12 @@ test_expect_success 'rm of a conflicted populated submodule with modifications f
@@ -512,12 +515,12 @@ test_expect_success 'rm of a conflicted populated submodule with modifications f
echo X >submod/empty &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
@ -531,12 +534,12 @@ test_expect_success 'rm of a conflicted populated submodule with untracked files
@@ -531,12 +534,12 @@ test_expect_success 'rm of a conflicted populated submodule with untracked files
echo X >submod/untracked &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -545,20 +548,21 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
@@ -545,20 +548,21 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
(cd submod &&
(
cd submod &&
rm .git &&
cp -R ../.git/modules/sub .git &&
GIT_WORK_TREE=. git config --unset core.worktree
) &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -d submod/.git &&
test_path_is_dir submod &&
test_path_is_dir submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/.git &&
test_path_is_dir submod &&
test_path_is_dir submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git merge --abort &&
@ -570,7 +574,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
@@ -570,7 +574,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
git reset --hard &&
test_must_fail git merge conflict2 &&
git rm submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -579,17 +583,18 @@ test_expect_success 'rm of a populated submodule with a .git directory migrates
@@ -579,17 +583,18 @@ test_expect_success 'rm of a populated submodule with a .git directory migrates
test_expect_success 'rm recursively removes work tree of unmodified submodules' '
git rm submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -624,12 +630,12 @@ test_expect_success 'rm of a populated nested submodule with different nested HE
@@ -624,12 +630,12 @@ test_expect_success 'rm of a populated nested submodule with different nested HE
git submodule update --recursive &&
git -C submod/subsubmod checkout HEAD^ &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified_inside actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -639,12 +645,12 @@ test_expect_success 'rm of a populated nested submodule with nested modification
@@ -639,12 +645,12 @@ test_expect_success 'rm of a populated nested submodule with nested modification
git submodule update --recursive &&
echo X >submod/subsubmod/empty &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified_inside actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -654,12 +660,12 @@ test_expect_success 'rm of a populated nested submodule with nested untracked fi
@@ -654,12 +660,12 @@ test_expect_success 'rm of a populated nested submodule with nested untracked fi
git submodule update --recursive &&
echo X >submod/subsubmod/untracked &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
test_path_is_dir submod &&
test_path_is_file submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified_untracked actual &&
git rm -f submod &&
test ! -d submod &&
test_path_is_missing submod &&
git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@ -667,16 +673,17 @@ test_expect_success 'rm of a populated nested submodule with nested untracked fi
@@ -667,16 +673,17 @@ test_expect_success 'rm of a populated nested submodule with nested untracked fi