t7406: avoid having git commands upstream of a pipe
When a git command is on the left side of a pipe, the pipe will swallow its exit status, preventing us from detecting failures in said commands. Restructure the tests to put the output in a temporary file to avoid this problem. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Aug 8, 2018 at 09:31 UTC
65799fbca72a251c75b087e7d018f367a4f7794f
1 file changed
+17
-9
t/t7406-submodule-update.sh
+17
-9
@@ -481,7 +481,8 @@ test_expect_success 'recursive submodule update - command in .git/config catches
481
482
test_expect_success 'submodule init does not copy command into .git/config' '
483
(cd super &&
484
- H=$(git ls-files -s submodule | cut -d" " -f2) &&
484
+ git ls-files -s submodule >out &&
485
+ H=$(cut -d" " -f2 out) &&
486
mkdir submodule1 &&
487
git update-index --add --cacheinfo 160000 $H submodule1 &&
488
git config -f .gitmodules submodule.submodule1.path submodule1 &&
@@ -579,9 +580,11 @@ test_expect_success 'submodule update - update=none in .git/config' '
580
git checkout master &&
581
compare_head
582
) &&
582
- git diff --name-only | grep ^submodule$ &&
583
+ git diff --name-only >out &&
584
+ grep ^submodule$ out &&
585
git submodule update &&
584
- git diff --name-only | grep ^submodule$ &&
586
+ git diff --name-only >out &&
587
+ grep ^submodule$ out &&
588
(cd submodule &&
589
compare_head
590
) &&
@@ -597,7 +600,8 @@ test_expect_success 'submodule update - update=none in .git/config but --checkou
600
git checkout master &&
601
compare_head
602
) &&
600
- git diff --name-only | grep ^submodule$ &&
603
+ git diff --name-only >out &&
604
+ grep ^submodule$ out &&
605
git submodule update --checkout &&
606
git diff --name-only >out &&
607
! grep ^submodule$ out &&
@@ -886,7 +890,8 @@ test_expect_success 'submodule update properly revives a moved submodule' '
890
H=$(git rev-parse --short HEAD) &&
891
git commit -am "pre move" &&
892
H2=$(git rev-parse --short HEAD) &&
889
- git status | sed "s/$H/XXX/" >expect &&
893
+ git status >out &&
894
+ sed "s/$H/XXX/" out >expect &&
895
H=$(cd submodule2 && git rev-parse HEAD) &&
896
git rm --cached submodule2 &&
897
rm -rf submodule2 &&
@@ -895,7 +900,8 @@ test_expect_success 'submodule update properly revives a moved submodule' '
900
git config -f .gitmodules submodule.submodule2.path "moved/sub module" &&
901
git commit -am "post move" &&
902
git submodule update &&
898
- git status | sed "s/$H2/XXX/" >actual &&
903
+ git status > out &&
904
+ sed "s/$H2/XXX/" out >actual &&
905
test_cmp expect actual
906
)
907
'
@@ -913,7 +919,7 @@ test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd'
919
920
test_expect_success 'submodule update clone shallow submodule' '
921
test_when_finished "rm -rf super3" &&
916
- first=$(git -C cloned submodule status submodule |cut -c2-41) &&
922
+ first=$(git -C cloned rev-parse HEAD:submodule) &&
923
second=$(git -C submodule rev-parse HEAD) &&
924
commit_count=$(git -C submodule rev-list --count $first^..$second) &&
925
git clone cloned super3 &&
@@ -923,7 +929,8 @@ test_expect_success 'submodule update clone shallow submodule' '
929
sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
930
mv -f .gitmodules.tmp .gitmodules &&
931
git submodule update --init --depth=$commit_count &&
926
- test 1 = $(git -C submodule log --oneline | wc -l)
932
+ git -C submodule log --oneline >out &&
933
+ test_line_count = 1 out
934
)
935
'
936
@@ -939,7 +946,8 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
946
test_i18ngrep "Direct fetching of that commit failed." actual &&
947
git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
948
git submodule update --init --depth=1 >actual &&
942
- test 1 = $(git -C submodule log --oneline | wc -l)
949
+ git -C submodule log --oneline >out &&
950
+ test_line_count = 1 out
951
)
952
'
953