The rot13-filter.pl script hardcodes "#!/usr/bin/perl", and
does not respect $PERL_PATH at all. That is a problem if the
system does not have perl at that path, or if it has a perl
that is too old to run a complicated script like the
rot13-filter (but PERL_PATH points to a more modern one).
We can fix this by using write_script() to create a new copy
of the script with the correct #!-line. In theory we could
move the whole script inside t0021-conversion.sh rather than
having it as an auxiliary file, but it's long enough that
it just makes things harder to read.
As a bonus, we can stop using the full path to the script in
the filter-process config we add (because the trash
directory is in our PATH). Not only is this shorter, but it
sidesteps any shell-quoting issues. The original was broken
when $TEST_DIRECTORY contained a space, because it was
interpolated in the outer script.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
raw | patch | inline | side by side (parent: 30030a3 )
'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
EOF
'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
EOF
+write_script rot13-filter.pl "$PERL_PATH" \
+ <"$TEST_DIRECTORY"/t0021/rot13-filter.pl
+
generate_random_characters () {
LEN=$1
NAME=$2
generate_random_characters () {
LEN=$1
NAME=$2
'
test_expect_success PERL 'required process filter should filter data' '
'
test_expect_success PERL 'required process filter should filter data' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean smudge" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
test_expect_success PERL 'required process filter takes precedence' '
test_config_global filter.protocol.clean false &&
test_expect_success PERL 'required process filter takes precedence' '
test_config_global filter.protocol.clean false &&
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
'
test_expect_success PERL 'required process filter should be used only for "clean" operation only' '
'
test_expect_success PERL 'required process filter should be used only for "clean" operation only' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean" &&
rm -rf repo &&
mkdir repo &&
(
rm -rf repo &&
mkdir repo &&
(
'
test_expect_success PERL 'required process filter should process multiple packets' '
'
test_expect_success PERL 'required process filter should process multiple packets' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean smudge" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
'
test_expect_success PERL 'required process filter with clean error should fail' '
'
test_expect_success PERL 'required process filter with clean error should fail' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean smudge" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
test_config_global filter.protocol.required true &&
rm -rf repo &&
mkdir repo &&
'
test_expect_success PERL 'process filter should restart after unexpected write failure' '
'
test_expect_success PERL 'process filter should restart after unexpected write failure' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean smudge" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
rm -rf repo &&
mkdir repo &&
(
rm -rf repo &&
mkdir repo &&
(
'
test_expect_success PERL 'process filter should not be restarted if it signals an error' '
'
test_expect_success PERL 'process filter should not be restarted if it signals an error' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean smudge" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
rm -rf repo &&
mkdir repo &&
(
rm -rf repo &&
mkdir repo &&
(
'
test_expect_success PERL 'process filter abort stops processing of all further files' '
'
test_expect_success PERL 'process filter abort stops processing of all further files' '
- test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/ rot13-filter.pl clean smudge" &&
+ test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
rm -rf repo &&
mkdir repo &&
(
rm -rf repo &&
mkdir repo &&
(
#
# Example implementation for the Git filter protocol version 2
# See Documentation/gitattributes.txt, section "Filter Protocol"
#
# Example implementation for the Git filter protocol version 2
# See Documentation/gitattributes.txt, section "Filter Protocol"