t7614: avoid hiding git's exit code in a pipe
The exit code of the upstream command in a pipe is ignored, so in git cat-file commit HEAD | sed -e "1,/^\$/d" >actual a crash of "git cat-file" would go unnoticed: the exit code of the pipeline is that of "sed", which happily succeeds on empty input. The test would thus pass even though "git cat-file" failed. Write the output of "git cat-file" to a file first and run "sed" on that file, so that the exit codes of both commands are checked by the &&-chain. Signed-off-by: Shlok Kulshreshtha <diy2903@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shlok Kulshreshtha committed
Jul 15, 2026 at 17:03 UTC
b6b276974e727f4ac92fbaef972f2cd59b3071dd
1 file changed
+6
-3
t/t7614-merge-signoff.sh
+6
-3
@@ -45,7 +45,8 @@ test_expect_success 'git merge --signoff adds a sign-off line' '
45
test_commit main-branch-2 file2 2 &&
46
git checkout other-branch &&
47
git merge main --signoff --no-edit &&
48
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
48
+ git cat-file commit HEAD >commit &&
49
+ sed -e "1,/^\$/d" commit >actual &&
50
test_cmp expected-signed actual
51
'
52
@@ -55,7 +56,8 @@ test_expect_success 'git merge does not add a sign-off line' '
56
test_commit main-branch-3 file3 3 &&
57
git checkout other-branch &&
58
git merge main --no-edit &&
58
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
59
+ git cat-file commit HEAD >commit &&
60
+ sed -e "1,/^\$/d" commit >actual &&
61
test_cmp expected-unsigned actual
62
'
63
@@ -65,7 +67,8 @@ test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
67
test_commit main-branch-4 file4 4 &&
68
git checkout other-branch &&
69
git merge main --no-edit --signoff --no-signoff &&
68
- git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
70
+ git cat-file commit HEAD >commit &&
71
+ sed -e "1,/^\$/d" commit >actual &&
72
test_cmp expected-unsigned actual
73
'
74