From 0d913dfa7e41f31befb080512d2e8524338f1907 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 27 Nov 2019 11:53:16 -0800 Subject: t3600: use test_line_count() where possible Since we have a helper function that can test the number of lines in a file that gives better debugging information on failure, use test_line_count() to test the number of lines. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- t/t3600-rm.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 't/t3600-rm.sh') diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 8c8cca5bfb..f6e659b7e9 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -113,9 +113,10 @@ test_expect_success '"rm" command printed' ' echo frotz >test-file && git add test-file && git commit -m "add file for rm test" && - git rm test-file >rm-output && - test $(grep "^rm " rm-output | wc -l) = 1 && - rm -f test-file rm-output && + git rm test-file >rm-output.raw && + grep "^rm " rm-output.raw >rm-output && + test_line_count = 1 rm-output && + rm -f test-file rm-output.raw rm-output && git commit -m "remove file from rm test" ' -- cgit v1.2.3 From 3b737381d880bd6db1b09d8721f806774931853a Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 27 Nov 2019 11:53:18 -0800 Subject: t3600: stop losing return codes of git commands When a command is in a non-assignment command substitution, the return code will be lost in favour of the surrounding command's. As a result, if a git command fails, we won't know about it. Rewrite instances of this so that git commands are either run in an assignment-only command substitution so that their return codes aren't lost. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- t/t3600-rm.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 't/t3600-rm.sh') diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index f6e659b7e9..0c3bf10edd 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -304,7 +304,8 @@ EOF test_expect_success 'rm removes empty submodules from work tree' ' mkdir submod && - git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) submod && + hash=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000 "$hash" submod && git config -f .gitmodules submodule.sub.url ./. && git config -f .gitmodules submodule.sub.path submod && git submodule init && @@ -623,7 +624,8 @@ test_expect_success 'setup subsubmodule' ' git submodule update && ( cd submod && - git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod && + hash=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000 "$hash" subsubmod && git config -f .gitmodules submodule.sub.url ../. && git config -f .gitmodules submodule.sub.path subsubmod && git submodule init && -- cgit v1.2.3 From 50cd31c6526637e59ca180397aba425ec7a1e218 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 27 Nov 2019 11:53:20 -0800 Subject: t3600: comment on inducing SIGPIPE in `git rm` Add a comment about intentionally inducing SIGPIPE since this is unusual and future developers should be aware. Also, even though we are trying to refactor git commands out of the upstream of pipes, we cannot do it here since we rely on it being upstream to induce SIGPIPE. Comment on that as well so that future developers do not try to change it. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- t/t3600-rm.sh | 1 + 1 file changed, 1 insertion(+) (limited to 't/t3600-rm.sh') diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 0c3bf10edd..0ea858d652 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -251,6 +251,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' echo "100644 $hash 0 some-file-$i" i=$(( $i + 1 )) done | git update-index --index-info && + # git command is intentionally placed upstream of pipe to induce SIGPIPE git rm -n "some-file-*" | : && test_path_is_missing .git/index.lock ' -- cgit v1.2.3