]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: don't lose misc "git" exit codes
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 6 Feb 2023 22:44:33 +0000 (23:44 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Feb 2023 23:30:42 +0000 (15:30 -0800)
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>
t/t1401-symbolic-ref.sh
t/t3701-add-interactive.sh
t/t7516-commit-races.sh

index d708acdb819536083cc0f8bc5e41d2196d90aee3..5e36899d207a862a52bccd6e01dd89a01ce642be 100755 (executable)
@@ -33,7 +33,8 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' '
 reset_to_sane
 
 test_expect_success 'symbolic-ref refuses bare sha1' '
-       test_must_fail git symbolic-ref HEAD $(git rev-parse HEAD)
+       rev=$(git rev-parse HEAD) &&
+       test_must_fail git symbolic-ref HEAD "$rev"
 '
 
 reset_to_sane
index 5841f280fb2d4c3185e0a42b9d9a894d72cc4e79..f1fe5d606779c7707d5e53e029bef6630895f72e 100755 (executable)
@@ -296,9 +296,11 @@ test_expect_success FILEMODE 'stage mode and hunk' '
        echo content >>file &&
        chmod +x file &&
        printf "y\\ny\\n" | git add -p &&
-       git diff --cached file | grep "new mode" &&
-       git diff --cached file | grep "+content" &&
-       test -z "$(git diff file)"
+       git diff --cached file >out &&
+       grep "new mode" out &&
+       grep "+content" out &&
+       git diff file >out &&
+       test_must_be_empty out
 '
 
 # end of tests disabled when filemode is not usable
index f2ce14e9071c0a3b071f53186c2d311103883443..2d38a16480e82c0441075e0e54ffe8454b413cb2 100755 (executable)
@@ -10,7 +10,8 @@ test_expect_success 'race to create orphan commit' '
        test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
        git show -s --pretty=format:%s >subject &&
        grep hare subject &&
-       test -z "$(git show -s --pretty=format:%P)"
+       git show -s --pretty=format:%P >out &&
+       test_must_be_empty out
 '
 
 test_expect_success 'race to create non-orphan commit' '