From: Jeff King Date: Sun, 29 Mar 2020 15:02:26 +0000 (-0400) Subject: test-lib-functions: simplify packetize() stdin code X-Git-Tag: v2.27.0-rc0~130^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cacae4329fa;p=thirdparty%2Fgit.git test-lib-functions: simplify packetize() stdin code The code path in packetize() for reading stdin needs to handle NUL bytes, so we can't rely on shell variables. However, the current code takes a whopping 4 processes and uses a temporary file. We can do this much more simply and efficiently by using a single perl invocation (and we already rely on perl in the matching depacketize() function). We'll keep the non-stdin code path as it is, since that uses zero extra processes. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 216918a58c..88b7dbd69a 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1373,11 +1373,10 @@ packetize() { packet="$*" printf '%04x%s' "$((4 + ${#packet}))" "$packet" else - cat >packetize.tmp && - len=$(wc -c }; + printf "%04x%s", 4 + length($packet), $packet; + ' fi }