]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5500: simplify test implementation and fix git exit code suppression
authorShreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Wed, 21 Jan 2026 12:54:11 +0000 (18:24 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Jan 2026 17:40:59 +0000 (09:40 -0800)
The 'shallow since with commit graph and already-seen commit”
test uses a convoluted here-doc that combines manual input
construction with packetize, echo and embedded Git commands.
This structure hides failures from the git commands,
as their exit codes are suppressed inside echo command
substitution and being on the upstream side of pipes.

Instead of using here-doc to construct the pack
protocol that is directly sent to the
'git upload-pack' command being tested,
capture the outputs of the git commands upfront
and use the 'test-tool pkt-line pack'
tool to construct the input in a temporary file,
and then feed it to the command.

This has a few advantages:

* Executing the git commands outside the here-doc
avoids suppressing their exit codes and makes
debugging easier.

* It removes the need to manually count and
manage pkt-line lengths to keep in line with
the v2 protocol, as the tool handles this internally.

Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5500-fetch-pack.sh

index 2677cd5faa8253131a7b36cb08c20e6f223099e6..4bb56c167a52ecf7a25f48af7b3543e189339f12 100755 (executable)
@@ -892,15 +892,20 @@ test_expect_success 'shallow since with commit graph and already-seen commit' '
        test_commit other &&
        git commit-graph write --reachable &&
        git config core.commitGraph true &&
-
-       GIT_PROTOCOL=version=2 git upload-pack . <<-EOF >/dev/null
-       0012command=fetch
-       $(echo "object-format=$(test_oid algo)" | packetize)
-       00010013deepen-since 1
-       $(echo "want $(git rev-parse other)" | packetize)
-       $(echo "have $(git rev-parse main)" | packetize)
+       oid_algo=$(test_oid algo) &&
+       oid_other=$(git rev-parse other) &&
+       oid_main=$(git rev-parse main) &&
+
+       test-tool pkt-line pack >input <<-EOF &&
+       command=fetch
+       object-format=$oid_algo
+       0001
+       deepen-since 1
+       want $oid_other
+       have $oid_main
        0000
        EOF
+       GIT_PROTOCOL=version=2 git upload-pack . <input >/dev/null
        )
 '