tests: don't lose misc "git" exit codes

Fix a few miscellaneous cases where: - We lost the "git" exit code via "git ... | grep" - Likewise by having a $(git) argument to git itself - Used "test -z" to check that a command emitted no output, we can use "test_must_be_empty" and &&-chaining instead. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Feb 6, 2023 at 23:44 UTC 9fdc79ecba0f4a3ef885f1409d2db5a1dbabd649
3 files changed +9 -5
t/t1401-symbolic-ref.sh
+2 -1
@@ -33,7 +33,8 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' '
33 reset_to_sane
34
35 test_expect_success 'symbolic-ref refuses bare sha1' '
36 - test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD)
36 + rev=$(git rev-parse HEAD) &&
37 + test_must_fail git symbolic-ref HEAD "$rev"
38 '
39
40 reset_to_sane
t/t3701-add-interactive.sh
+5 -3
@@ -296,9 +296,11 @@ test_expect_success FILEMODE 'stage mode and hunk' '
296 echo content >>file &&
297 chmod +x file &&
298 printf "y\\ny\\n" | git add -p &&
299 - git diff --cached file | grep "new mode" &&
300 - git diff --cached file | grep "+content" &&
301 - test -z "$(git diff file)"
299 + git diff --cached file >out &&
300 + grep "new mode" out &&
301 + grep "+content" out &&
302 + git diff file >out &&
303 + test_must_be_empty out
304 '
305
306 # end of tests disabled when filemode is not usable
t/t7516-commit-races.sh
+2 -1
@@ -10,7 +10,8 @@ test_expect_success 'race to create orphan commit' '
10 test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
11 git show -s --pretty=format:%s >subject &&
12 grep hare subject &&
13 - test -z "$(git show -s --pretty=format:%P)"
13 + git show -s --pretty=format:%P >out &&
14 + test_must_be_empty out
15 '
16
17 test_expect_success 'race to create non-orphan commit' '