]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5703-upload-pack-ref-in-want.sh
t/lib-httpd: avoid using macOS' sed
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 27 Feb 2020 13:23:11 +0000 (13:23 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2020 17:58:41 +0000 (09:58 -0800)
commiteafff6e41e6a16c23764dcd31373bedd61572cf1
tree8624d17156164b3ac99c4a1c54c4ad63cfa99d2b
parentc522f061d551c9bb8684a7c3859b2ece4499b56b
t/lib-httpd: avoid using macOS' sed

Among other differences relative to GNU sed, macOS' sed always ends its
output with a trailing newline, even if the input did not have such a
trailing newline.

Surprisingly, this makes three httpd-based tests fail on macOS: t5616,
t5702 and t5703. ("Surprisingly" because those tests have been around
for some time, but apparently nobody runs them on macOS with a working
Apache2 setup.)

The reason is that we use `sed` in those tests to filter the response of
the web server. Apart from the fact that we use GNU constructs (such as
using a space after the `c` command instead of a backslash and a
newline), we have another problem: macOS' sed LF-only newlines while
webservers are supposed to use CR/LF ones.

Even worse, t5616 uses `sed` to replace a binary part of the response
with a new binary part (kind of hoping that the replaced binary part
does not contain a 0x0a byte which would be interpreted as a newline).

To that end, it calls on Perl to read the binary pack file and
hex-encode it, then calls on `sed` to prefix every hex digit pair with a
`\x` in order to construct the text that the `c` statement of the `sed`
invocation is supposed to insert. So we call Perl and sed to construct a
sed statement. The final nail in the coffin is that macOS' sed does not
even interpret those `\x<hex>` constructs.

Let's just replace all of that by Perl snippets. With Perl, at least, we
do not have to deal with GNU vs macOS semantics, we do not have to worry
about unwanted trailing newlines, and we do not have to spawn commands
to construct arguments for other commands to be spawned (i.e. we can
avoid a whole lot of shell scripting complexity).

The upshot is that this fixes t5616, t5702 and t5703 on macOS with
Apache2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-httpd.sh
t/lib-httpd/apache.conf
t/lib-httpd/apply-one-time-perl.sh [new file with mode: 0644]
t/lib-httpd/apply-one-time-sed.sh [deleted file]
t/t5537-fetch-shallow.sh
t/t5616-partial-clone.sh
t/t5702-protocol-v2.sh
t/t5703-upload-pack-ref-in-want.sh