test-lib-functions: make packetize() more efficient
authorJeff King <peff@peff.net>
Fri, 27 Mar 2020 08:03:00 +0000 (04:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Mar 2020 18:50:54 +0000 (11:50 -0700)
commit88124ab263670b4252be7c13d03754a127cee90e
tree3be57835c5a2d73dab7daa436aebd16fcf009042
parent274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925
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>
t/t5562-http-backend-content-length.sh
t/test-lib-functions.sh