mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
eafff6e41e
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>
27 lines
686 B
Bash
27 lines
686 B
Bash
#!/bin/sh
|
|
|
|
# If "one-time-perl" exists in $HTTPD_ROOT_PATH, run perl on the HTTP response,
|
|
# using the contents of "one-time-perl" as the perl command to be run. If the
|
|
# response was modified as a result, delete "one-time-perl" so that subsequent
|
|
# HTTP responses are no longer modified.
|
|
#
|
|
# This can be used to simulate the effects of the repository changing in
|
|
# between HTTP request-response pairs.
|
|
if test -f one-time-perl
|
|
then
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
"$GIT_EXEC_PATH/git-http-backend" >out
|
|
perl -pe "$(cat one-time-perl)" out >out_modified
|
|
|
|
if cmp -s out out_modified
|
|
then
|
|
cat out
|
|
else
|
|
cat out_modified
|
|
rm one-time-perl
|
|
fi
|
|
else
|
|
"$GIT_EXEC_PATH/git-http-backend"
|
|
fi
|