diff options
-rwxr-xr-x | t/t7406-submodule-update.sh | 37 | ||||
-rw-r--r-- | t/test-lib-functions.sh | 8 |
2 files changed, 31 insertions, 14 deletions
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 686e6a439e..10dc91620a 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -175,7 +175,7 @@ test_expect_success 'submodule update does not fetch already present commits' ' git submodule update > ../actual 2> ../actual.err ) && test_i18ncmp expected actual && - ! test -s actual.err + test_must_be_empty actual.err ' test_expect_success 'submodule update should fail due to local changes' ' @@ -482,7 +482,8 @@ test_expect_success 'recursive submodule update - command in .git/config catches test_expect_success 'submodule init does not copy command into .git/config' ' (cd super && - H=$(git ls-files -s submodule | cut -d" " -f2) && + git ls-files -s submodule >out && + H=$(cut -d" " -f2 out) && mkdir submodule1 && git update-index --add --cacheinfo 160000 $H submodule1 && git config -f .gitmodules submodule.submodule1.path submodule1 && @@ -580,9 +581,11 @@ test_expect_success 'submodule update - update=none in .git/config' ' git checkout master && compare_head ) && - git diff --raw | grep " submodule" && + git diff --name-only >out && + grep ^submodule$ out && git submodule update && - git diff --raw | grep " submodule" && + git diff --name-only >out && + grep ^submodule$ out && (cd submodule && compare_head ) && @@ -598,11 +601,13 @@ test_expect_success 'submodule update - update=none in .git/config but --checkou git checkout master && compare_head ) && - git diff --raw | grep " submodule" && + git diff --name-only >out && + grep ^submodule$ out && git submodule update --checkout && - test_must_fail git diff --raw \| grep " submodule" && + git diff --name-only >out && + ! grep ^submodule$ out && (cd submodule && - test_must_fail compare_head + ! compare_head ) && git config --unset submodule.submodule.update ) @@ -616,8 +621,8 @@ test_expect_success 'submodule update --init skips submodule with update=none' ' git clone super cloned && (cd cloned && git submodule update --init && - test -e submodule/.git && - test_must_fail test -e none/.git + test_path_exists submodule/.git && + test_path_is_missing none/.git ) ' @@ -886,7 +891,8 @@ test_expect_success 'submodule update properly revives a moved submodule' ' H=$(git rev-parse --short HEAD) && git commit -am "pre move" && H2=$(git rev-parse --short HEAD) && - git status | sed "s/$H/XXX/" >expect && + git status >out && + sed "s/$H/XXX/" out >expect && H=$(cd submodule2 && git rev-parse HEAD) && git rm --cached submodule2 && rm -rf submodule2 && @@ -895,7 +901,8 @@ test_expect_success 'submodule update properly revives a moved submodule' ' git config -f .gitmodules submodule.submodule2.path "moved/sub module" && git commit -am "post move" && git submodule update && - git status | sed "s/$H2/XXX/" >actual && + git status > out && + sed "s/$H2/XXX/" out >actual && test_cmp expect actual ) ' @@ -913,7 +920,7 @@ test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' test_expect_success 'submodule update clone shallow submodule' ' test_when_finished "rm -rf super3" && - first=$(git -C cloned submodule status submodule |cut -c2-41) && + first=$(git -C cloned rev-parse HEAD:submodule) && second=$(git -C submodule rev-parse HEAD) && commit_count=$(git -C submodule rev-list --count $first^..$second) && git clone cloned super3 && @@ -923,7 +930,8 @@ test_expect_success 'submodule update clone shallow submodule' ' sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp && mv -f .gitmodules.tmp .gitmodules && git submodule update --init --depth=$commit_count && - test 1 = $(git -C submodule log --oneline | wc -l) + git -C submodule log --oneline >out && + test_line_count = 1 out ) ' @@ -939,7 +947,8 @@ test_expect_success 'submodule update clone shallow submodule outside of depth' test_i18ngrep "Direct fetching of that commit failed." actual && git -C ../submodule config uploadpack.allowReachableSHA1InWant true && git submodule update --init --depth=1 >actual && - test 1 = $(git -C submodule log --oneline | wc -l) + git -C submodule log --oneline >out && + test_line_count = 1 out ) ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2b2181dca0..4207af4077 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -565,6 +565,14 @@ test_path_is_dir () { fi } +test_path_exists () { + if ! test -e "$1" + then + echo "Path $1 doesn't exist. $2" + false + fi +} + # Check if the directory exists and is empty as expected, barf otherwise. test_dir_is_empty () { test_path_is_dir "$1" && |