]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: prepare `test_match_signal ()` calls for `set -e`
authorPatrick Steinhardt <ps@pks.im>
Tue, 21 Apr 2026 07:34:14 +0000 (09:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Apr 2026 22:53:35 +0000 (15:53 -0700)
We have a couple of calls to `test_match_signal ()` where we execute a
Git command and expect it to die with a specific signal. These calls
will essentially execute the process in a subshell via `foo; echo $?`,
but as we expect `foo` to fail this will cause the overall subshell to
fail once we `set -e`.

Fix this issue by using `foo && echo 0 || echo $?` instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0005-signals.sh
t/t3600-rm.sh

index afba0fc3fc673e5d7d4d55b2031607905853f737..84319cf169e571b1f21fb4934d1d85495584c790 100755 (executable)
@@ -42,12 +42,12 @@ test_expect_success 'create blob' '
 '
 
 test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
-       OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
+       OUT=$( ((large_git && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) &&
        test_match_signal 13 "$OUT"
 '
 
 test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
-       OUT=$( ((trap "" PIPE && large_git; echo $? 1>&3) | :) 3>&1 ) &&
+       OUT=$( ((trap "" PIPE && large_git && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) &&
        test_match_signal 13 "$OUT"
 '
 
index 1f16e6b52285bce57251951da88a02da1d44a3e7..a371ea690ef79d232d3e4289bbb1e28a04b8e056 100755 (executable)
@@ -260,7 +260,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft (induce S
 
 test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' '
        choke_git_rm_setup &&
-       OUT=$( ((trap "" PIPE && git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
+       OUT=$( ((trap "" PIPE && git rm -n "some-file-*" && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) &&
        test_match_signal 13 "$OUT" &&
        test_path_is_missing .git/index.lock
 '