summaryrefslogtreecommitdiff
path: root/t/t5562-http-backend-content-length.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-03-27 08:03:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-03-27 18:50:54 (GMT)
commit88124ab263670b4252be7c13d03754a127cee90e (patch)
tree3be57835c5a2d73dab7daa436aebd16fcf009042 /t/t5562-http-backend-content-length.sh
parent274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925 (diff)
downloadgit-88124ab263670b4252be7c13d03754a127cee90e.zip
git-88124ab263670b4252be7c13d03754a127cee90e.tar.gz
git-88124ab263670b4252be7c13d03754a127cee90e.tar.bz2
test-lib-functions: make packetize() more efficient
The packetize() function takes its input on stdin, and requires 4 separate sub-processes to format a simple string. We can do much better by getting the length via the shell's "${#packet}" construct. The one caveat is that the shell can't put a NUL into a variable, so we'll have to continue to provide the stdin form for a few calls. There are a few other cleanups here in the touched code: - the stdin form of packetize() had an extra stray "%s" when printing the packet - the converted calls in t5562 can be made simpler by redirecting output as a block, rather than repeated appending Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5562-http-backend-content-length.sh')
-rwxr-xr-xt/t5562-http-backend-content-length.sh19
1 files changed, 12 insertions, 7 deletions
diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh
index 4a110b3..3f4ac71 100755
--- a/t/t5562-http-backend-content-length.sh
+++ b/t/t5562-http-backend-content-length.sh
@@ -53,15 +53,20 @@ test_expect_success 'setup' '
test_commit c1 &&
hash_head=$(git rev-parse HEAD) &&
hash_prev=$(git rev-parse HEAD~1) &&
- printf "want %s" "$hash_head" | packetize >fetch_body &&
- printf 0000 >>fetch_body &&
- printf "have %s" "$hash_prev" | packetize >>fetch_body &&
- printf done | packetize >>fetch_body &&
+ {
+ packetize "want $hash_head" &&
+ printf 0000 &&
+ packetize "have $hash_prev" &&
+ packetize "done"
+ } >fetch_body &&
test_copy_bytes 10 <fetch_body >fetch_body.trunc &&
hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) &&
- printf "%s %s refs/heads/newbranch\\0report-status\\n" "$ZERO_OID" "$hash_next" | packetize >push_body &&
- printf 0000 >>push_body &&
- echo "$hash_next" | git pack-objects --stdout >>push_body &&
+ {
+ printf "%s %s refs/heads/newbranch\\0report-status\\n" \
+ "$ZERO_OID" "$hash_next" | packetize &&
+ printf 0000 &&
+ echo "$hash_next" | git pack-objects --stdout
+ } >push_body &&
test_copy_bytes 10 <push_body >push_body.trunc &&
: >empty_body
'