]> git.ipfire.org Git - thirdparty/git.git/commitdiff
upload-pack tests: avoid a non-zero "grep" exit status
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 23 Jan 2021 13:00:44 +0000 (14:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 23 Jan 2021 21:25:12 +0000 (13:25 -0800)
Continue changing a test that 763b47bafa (t5703: stop losing return
codes of git commands, 2019-11-27) already refactored.

This was originally added as part of a series to add support for
running under bash's "set -o pipefail", under that mode this test will
fail because sometimes there's no commits in the "objs" output.

It's easier to fix that than exempt these tests under a hypothetical
"set -o pipefail" test mode. It looks like we probably won't have
that, but once we've dug this code up let's refactor it[2] so we don't
hide a potential pipe failure.

1. https://lore.kernel.org/git/xmqqzh18o8o6.fsf@gitster.c.googlers.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5703-upload-pack-ref-in-want.sh

index eab966985b7aab80afad18cb87e0f605b37d246b..5d825b1781be49eaed4e5672d4f27a1a240794f9 100755 (executable)
@@ -16,7 +16,8 @@ get_actual_commits () {
        test-tool pkt-line unpack-sideband <out >o.pack &&
        git index-pack o.pack &&
        git verify-pack -v o.idx >objs &&
-       grep commit objs | cut -d" " -f1 | sort >actual_commits
+       sed -n -e 's/\([0-9a-f][0-9a-f]*\) commit .*/\1/p' objs >objs.sed &&
+       sort >actual_commits <objs.sed
 }
 
 check_output () {