Git fork

t/lib-patch-mode.sh: fix ignored exit codes

Fix code added in b319ef70a94 (Add a small patch-mode testing library,
2009-08-13) to use &&-chaining.

This avoids losing both the exit code of a "git" and the "cat"
processes.

This fixes cases where we'd have e.g. missed memory leaks under
SANITIZE=leak, this code doesn't leak now as far as I can tell, but I
discovered it while looking at leaks in related code.

For "verify_saved_head()" we could make use of "test_cmp_rev" with
some changes, but it uses "git rev-parse --verify", and this existing
test does not. I think it could safely use it, but let's avoid the
while-at-it change, and narrowly fix the exit code problem.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Ævar Arnfjörð Bjarmason and committed by
Junio C Hamano
62f3a45b fb18dd28

+8 -3
+8 -3
t/lib-patch-mode.sh
··· 29 29 30 30 # verify_state <path> <expected-worktree-content> <expected-index-content> 31 31 verify_state () { 32 - test "$(cat "$1")" = "$2" && 33 - test "$(git show :"$1")" = "$3" 32 + echo "$2" >expect && 33 + test_cmp expect "$1" && 34 + 35 + echo "$3" >expect && 36 + git show :"$1" >actual && 37 + test_cmp expect actual 34 38 } 35 39 36 40 # verify_saved_state <path> ··· 46 50 } 47 51 48 52 verify_saved_head () { 49 - test "$(cat _head)" = "$(git rev-parse HEAD)" 53 + git rev-parse HEAD >actual && 54 + test_cmp _head actual 50 55 }