tests: don't lose exit status with "(cd ...; test <op> $(git ...))"

Rewrite tests that ran "git" inside command substitution and lost the
exit status of "git" so that we notice the failing "git".

Have them use modern patterns such as a "test_cmp" of the expected
outputs instead.

We'll fix more of these these in the subsequent commit, for now we're
only converting the cases where this loss of exit code was combined
with spawning a sub-shell.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2023-02-06 23:44:30 +01:00
committed by Junio C Hamano
parent 62f3a45bb4
commit 0cd1a8818d
6 changed files with 45 additions and 24 deletions

View File

@ -217,8 +217,12 @@ test_http_push_nonff () {
git commit -a -m path2 --amend &&
test_must_fail git push -v origin >output 2>&1 &&
(cd "$REMOTE_REPO" &&
test $HEAD = $(git rev-parse --verify HEAD))
(
cd "$REMOTE_REPO" &&
echo "$HEAD" >expect &&
git rev-parse --verify HEAD >actual &&
test_cmp expect actual
)
'
test_expect_success 'non-fast-forward push show ref status' '