]> git.ipfire.org Git - thirdparty/git.git/commit
t7004: avoid subshells to capture git exit codes
authorSiddharth Shrimali <r.siddharth.shrimali@gmail.com>
Tue, 21 Apr 2026 05:33:34 +0000 (11:03 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Apr 2026 07:20:42 +0000 (00:20 -0700)
commitef85286e511b4cebfdce0c4bffc7c8985274f142
tree150a6863739842d43862a190a0663707c7763d76
parente3253255d3e1c007e80742c304ddde9421dca9ca
t7004: avoid subshells to capture git exit codes

Several tests in t7004 use the 'test$(git ...) = ...' or the '! (git ...)'
subshell pattern. This swallows git's exit code. If git crashes
(e.g. segmentation fault) the crash would go undetected, and the test
would fail due to a mismatch or an inverted exit code.

Modernize these tests by directly writing output to files(actual) and
verifying them with 'test_cmp' or 'test_grep'. Replace subshell
negations with 'test_must_fail'. This way, if git crashes, the test
fails immediately and clearly instead of hiding the error behind a
string mismatch.

Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7004-tag.sh