Merge branch 'ps/test-wo-perl-prereq'

"make test" used to have a hard dependency on (basic) Perl; tests
have been rewritten help environment with NO_PERL test the build as
much as possible.

* ps/test-wo-perl-prereq:
  t5703: refactor test to not depend on Perl
  t5316: refactor `max_chain()` to not depend on Perl
  t0210: refactor trace2 scrubbing to not use Perl
  t0021: refactor `generate_random_characters()` to not depend on Perl
  t/lib-httpd: refactor "one-time-perl" CGI script to not depend on Perl
  t/lib-t6000: refactor `name_from_description()` to not depend on Perl
  t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl
  t: refactor tests depending on Perl for textconv scripts
  t: refactor tests depending on Perl to print data
  t: refactor tests depending on Perl substitution operator
  t: refactor tests depending on Perl transliteration operator
  Makefile: stop requiring Perl when running tests
  meson: stop requiring Perl when tests are enabled
  t: adapt existing PERL prerequisites
  t: introduce PERL_TEST_HELPERS prerequisite
  t: adapt `test_readlink()` to not use Perl
  t: adapt `test_copy_bytes()` to not use Perl
  t: adapt character translation helpers to not use Perl
  t: refactor environment sanitization to not use Perl
  t: skip chain lint when PERL_PATH is unset
This commit is contained in:
Junio C Hamano
2025-04-16 13:54:20 -07:00
84 changed files with 471 additions and 373 deletions

View File

@@ -815,7 +815,7 @@ endif
# features. It is optional if you want to neither execute tests nor use any of # features. It is optional if you want to neither execute tests nor use any of
# these optional features. # these optional features.
perl_required = get_option('perl') perl_required = get_option('perl')
if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_option('docs') != [] if get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_option('docs') != []
perl_required = true perl_required = true
endif endif

View File

@@ -59,16 +59,21 @@ CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT
all:: $(DEFAULT_TEST_TARGET) all:: $(DEFAULT_TEST_TARGET)
test: pre-clean check-chainlint check-meson $(TEST_LINT) test: pre-clean check-meson $(TEST_LINT)
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup $(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
ifneq ($(PERL_PATH),)
test: check-chainlint
prove: check-chainlint
endif
failed: failed:
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \ @failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
grep -l '^failed [1-9]' *.counts | \ grep -l '^failed [1-9]' *.counts | \
sed -n 's/\.counts$$/.sh/p') && \ sed -n 's/\.counts$$/.sh/p') && \
test -z "$$failed" || $(MAKE) $$failed test -z "$$failed" || $(MAKE) $$failed
prove: pre-clean check-chainlint $(TEST_LINT) prove: pre-clean $(TEST_LINT)
@echo "*** prove (shell & unit tests) ***" @echo "*** prove (shell & unit tests) ***"
@$(CHAINLINTSUPPRESS) TEST_OPTIONS='$(GIT_TEST_OPTS)' TEST_SHELL_PATH='$(TEST_SHELL_PATH_SQ)' $(PROVE) --exec ./run-test.sh $(GIT_PROVE_OPTS) $(T) $(UNIT_TESTS) @$(CHAINLINTSUPPRESS) TEST_OPTIONS='$(GIT_TEST_OPTS)' TEST_SHELL_PATH='$(TEST_SHELL_PATH_SQ)' $(PROVE) --exec ./run-test.sh $(GIT_PROVE_OPTS) $(T) $(UNIT_TESTS)
$(MAKE) clean-except-prove-cache $(MAKE) clean-except-prove-cache
@@ -132,8 +137,13 @@ check-meson:
fi; \ fi; \
done done
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \ test-lint: test-lint-duplicates test-lint-executable \
test-lint-filenames test-lint-filenames
ifneq ($(PERL_PATH),)
test-lint: test-lint-shell-syntax
else
GIT_TEST_CHAIN_LINT = 0
endif
ifneq ($(GIT_TEST_CHAIN_LINT),0) ifneq ($(GIT_TEST_CHAIN_LINT),0)
test-lint: test-chainlint test-lint: test-chainlint
endif endif

View File

@@ -323,6 +323,19 @@ int cmd__path_utils(int argc, const char **argv)
return 0; return 0;
} }
if (argc >= 2 && !strcmp(argv[1], "readlink")) {
struct strbuf target = STRBUF_INIT;
while (argc > 2) {
if (strbuf_readlink(&target, argv[2], 0) < 0)
die_errno("cannot read link at '%s'", argv[2]);
puts(target.buf);
argc--;
argv++;
}
strbuf_release(&target);
return 0;
}
if (argc >= 2 && !strcmp(argv[1], "absolute_path")) { if (argc >= 2 && !strcmp(argv[1], "absolute_path")) {
while (argc > 2) { while (argc > 2) {
puts(absolute_path(argv[2])); puts(absolute_path(argv[2]));

View File

@@ -15,7 +15,7 @@ do
{ {
test -z "$pfx" || echo "$pfx" test -z "$pfx" || echo "$pfx"
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
perl -pe 'y/\000/g/' tr "\000" "g"
} | ./t/helper/test-tool $sha1 $cnt } | ./t/helper/test-tool $sha1 $cnt
) )
if test "$expect" = "$actual" if test "$expect" = "$actual"
@@ -61,7 +61,7 @@ do
{ {
test -z "$pfx" || echo "$pfx" test -z "$pfx" || echo "$pfx"
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
perl -pe 'y/\000/g/' tr "\000" "g"
} | sha1sum | } | sha1sum |
sed -e 's/ .*//' sed -e 's/ .*//'
) )

View File

@@ -21,8 +21,8 @@ compare_diff_raw_z () {
# Also we do not check SHA1 hash generation in this test, which # Also we do not check SHA1 hash generation in this test, which
# is a job for t0000-basic.sh # is a job for t0000-basic.sh
perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 tr "\000" "\012" <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 tr "\000" "\012" <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
} }

View File

@@ -192,9 +192,5 @@ test_lazy_prereq GPGSSH_VERIFYTIME '
' '
sanitize_pgp() { sanitize_pgp() {
perl -ne ' sed "/^-----BEGIN PGP/,/^-----END PGP/{/^-/p;d;}"
/^-----END PGP/ and $in_pgp = 0;
print unless $in_pgp;
/^-----BEGIN PGP/ and $in_pgp = 1;
'
} }

View File

@@ -165,7 +165,7 @@ prepare_httpd() {
install_script broken-smart-http.sh install_script broken-smart-http.sh
install_script error-smart-http.sh install_script error-smart-http.sh
install_script error.sh install_script error.sh
install_script apply-one-time-perl.sh install_script apply-one-time-script.sh
install_script nph-custom-auth.sh install_script nph-custom-auth.sh
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"

View File

@@ -135,7 +135,7 @@ SetEnv PERL_PATH ${PERL_PATH}
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_HTTP_EXPORT_ALL
</LocationMatch> </LocationMatch>
<LocationMatch /one_time_perl/> <LocationMatch /one_time_script/>
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_HTTP_EXPORT_ALL
</LocationMatch> </LocationMatch>
@@ -159,7 +159,7 @@ ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
ScriptAlias /broken_smart/ broken-smart-http.sh/ ScriptAlias /broken_smart/ broken-smart-http.sh/
ScriptAlias /error_smart/ error-smart-http.sh/ ScriptAlias /error_smart/ error-smart-http.sh/
ScriptAlias /error/ error.sh/ ScriptAlias /error/ error.sh/
ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1 ScriptAliasMatch /one_time_script/(.*) apply-one-time-script.sh/$1
ScriptAliasMatch /custom_auth/(.*) nph-custom-auth.sh/$1 ScriptAliasMatch /custom_auth/(.*) nph-custom-auth.sh/$1
<Directory ${GIT_EXEC_PATH}> <Directory ${GIT_EXEC_PATH}>
Options FollowSymlinks Options FollowSymlinks
@@ -182,7 +182,7 @@ ScriptAliasMatch /custom_auth/(.*) nph-custom-auth.sh/$1
<Files error.sh> <Files error.sh>
Options ExecCGI Options ExecCGI
</Files> </Files>
<Files apply-one-time-perl.sh> <Files apply-one-time-script.sh>
Options ExecCGI Options ExecCGI
</Files> </Files>
<Files ${GIT_EXEC_PATH}/git-http-backend> <Files ${GIT_EXEC_PATH}/git-http-backend>

View File

@@ -1,27 +0,0 @@
#!/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_PATH" -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

View File

@@ -0,0 +1,26 @@
#!/bin/sh
# If "one-time-script" exists in $HTTPD_ROOT_PATH, run the script on the HTTP
# response. If the response was modified as a result, delete "one-time-script"
# 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-script
then
LC_ALL=C
export LC_ALL
"$GIT_EXEC_PATH/git-http-backend" >out
./one-time-script out >out_modified
if cmp -s out out_modified
then
cat out
else
cat out_modified
rm one-time-script
fi
else
"$GIT_EXEC_PATH/git-http-backend"
fi

View File

@@ -109,13 +109,12 @@ check_output () {
# All alphanums translated into -'s which are then compressed and stripped # All alphanums translated into -'s which are then compressed and stripped
# from front and back. # from front and back.
name_from_description () { name_from_description () {
perl -pe ' sed \
s/[^A-Za-z0-9.]/-/g; -e 's/[^A-Za-z0-9.]/-/g' \
s/-+/-/g; -e 's/--*/-/g' \
s/-$//; -e 's/-$//' \
s/^-//; -e 's/^-//' \
y/A-Z/a-z/; -e 'y/A-Z/a-z/'
'
} }

View File

@@ -39,11 +39,11 @@ test_stderr () {
} }
broken_c_unquote () { broken_c_unquote () {
"$PERL_PATH" -pe 's/^"//; s/\\//; s/"$//; tr/\n/\0/' "$@" sed -e 's/^"//' -e 's/\\//' -e 's/"$//' "$1" | tr '\n' '\0'
} }
broken_c_unquote_verbose () { broken_c_unquote_verbose () {
"$PERL_PATH" -pe 's/ "/ /; s/\\//; s/"$//; tr/:\t\n/\0/' "$@" sed -e 's/ "/ /' -e 's/\\//' -e 's/"$//' "$1" | tr ':\t\n' '\000'
} }
stderr_contains () { stderr_contains () {

View File

@@ -20,8 +20,7 @@ EOF
generate_random_characters () { generate_random_characters () {
LEN=$1 LEN=$1
NAME=$2 NAME=$2
test-tool genrandom some-seed $LEN | test-tool genrandom some-seed | tr -dc 'a-z' | test_copy_bytes "$LEN" >"$TEST_ROOT/$NAME"
perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME"
} }
filter_git () { filter_git () {
@@ -841,7 +840,7 @@ test_expect_success 'process filter abort stops processing of all further files'
) )
' '
test_expect_success PERL 'invalid process filter must fail (and not hang!)' ' test_expect_success 'invalid process filter must fail (and not hang!)' '
test_config_global filter.protocol.process cat && test_config_global filter.protocol.process cat &&
test_config_global filter.protocol.required true && test_config_global filter.protocol.required true &&
rm -rf repo && rm -rf repo &&
@@ -1111,19 +1110,19 @@ do
branch) opt='-f HEAD' ;; branch) opt='-f HEAD' ;;
esac esac
test_expect_success PERL,TTY "delayed checkout shows progress by default on tty ($mode checkout)" ' test_expect_success TTY "delayed checkout shows progress by default on tty ($mode checkout)" '
test_delayed_checkout_progress test_terminal git checkout $opt test_delayed_checkout_progress test_terminal git checkout $opt
' '
test_expect_success PERL "delayed checkout omits progress on non-tty ($mode checkout)" ' test_expect_success "delayed checkout omits progress on non-tty ($mode checkout)" '
test_delayed_checkout_progress ! git checkout $opt test_delayed_checkout_progress ! git checkout $opt
' '
test_expect_success PERL,TTY "delayed checkout omits progress with --quiet ($mode checkout)" ' test_expect_success TTY "delayed checkout omits progress with --quiet ($mode checkout)" '
test_delayed_checkout_progress ! test_terminal git checkout --quiet $opt test_delayed_checkout_progress ! test_terminal git checkout --quiet $opt
' '
test_expect_success PERL,TTY "delayed checkout honors --[no]-progress ($mode checkout)" ' test_expect_success TTY "delayed checkout honors --[no]-progress ($mode checkout)" '
test_delayed_checkout_progress ! test_terminal git checkout --no-progress $opt && test_delayed_checkout_progress ! test_terminal git checkout --no-progress $opt &&
test_delayed_checkout_progress test_terminal git checkout --quiet --progress $opt test_delayed_checkout_progress test_terminal git checkout --quiet --progress $opt
' '

View File

@@ -128,7 +128,7 @@ test_expect_success 'second commit has cache-tree' '
test_cache_tree test_cache_tree
' '
test_expect_success PERL 'commit --interactive gives cache-tree on partial commit' ' test_expect_success 'commit --interactive gives cache-tree on partial commit' '
test_when_finished "git reset --hard" && test_when_finished "git reset --hard" &&
cat <<-\EOT >foo.c && cat <<-\EOT >foo.c &&
int foo() int foo()
@@ -162,7 +162,7 @@ test_expect_success PERL 'commit --interactive gives cache-tree on partial commi
test_cache_tree expected.status test_cache_tree expected.status
' '
test_expect_success PERL 'commit -p with shrinking cache-tree' ' test_expect_success 'commit -p with shrinking cache-tree' '
mkdir -p deep/very-long-subdir && mkdir -p deep/very-long-subdir &&
echo content >deep/very-long-subdir/file && echo content >deep/very-long-subdir/file &&
git add deep && git add deep &&

View File

@@ -53,10 +53,41 @@ GIT_TRACE2_BRIEF=1 && export GIT_TRACE2_BRIEF
# #
# Implicit return from cmd_<verb> function propagates <code>. # Implicit return from cmd_<verb> function propagates <code>.
scrub_normal () {
# Scrub the variable fields from the normal trace2 output to make
# testing easier:
#
# 1. Various messages include an elapsed time in the middle of the
# message. Replace the time with a placeholder to simplify our
# HEREDOC in the test script.
#
# 2. We expect:
#
# start <argv0> [<argv1> [<argv2> [...]]]
#
# where argv0 might be a relative or absolute path, with or
# without quotes, and platform dependent. Replace argv0 with a
# token for HEREDOC matching in the test script.
#
# 3. Likewise, the 'cmd_path' message breaks out argv[0].
#
# This line is only emitted when RUNTIME_PREFIX is defined,
# so just omit it for testing purposes.
#
# 4. 'cmd_ancestry' is not implemented everywhere, so for portability's
# sake, skip it when parsing normal.
sed \
-e 's/elapsed:[0-9]*\.[0-9][0-9]*\([eE][-+]\{0,1\}[0-9][0-9]*\)\{0,1\}/elapsed:_TIME_/g' \
-e "s/^start '[^']*' \(.*\)/start _EXE_ \1/" \
-e 's/^start [^ ][^ ]* \(.*\)/start _EXE_ \1/' \
-e '/^cmd_path/d' \
-e '/^cmd_ancestry/d'
}
test_expect_success 'normal stream, return code 0' ' test_expect_success 'normal stream, return code 0' '
test_when_finished "rm trace.normal actual expect" && test_when_finished "rm trace.normal actual expect" &&
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 0 && GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 0 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 001return 0 start _EXE_ trace2 001return 0
@@ -70,7 +101,7 @@ test_expect_success 'normal stream, return code 0' '
test_expect_success 'normal stream, return code 1' ' test_expect_success 'normal stream, return code 1' '
test_when_finished "rm trace.normal actual expect" && test_when_finished "rm trace.normal actual expect" &&
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 1 && test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 1 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 001return 1 start _EXE_ trace2 001return 1
@@ -85,7 +116,7 @@ test_expect_success 'automatic filename' '
test_when_finished "rm -r traces actual expect" && test_when_finished "rm -r traces actual expect" &&
mkdir traces && mkdir traces &&
GIT_TRACE2="$(pwd)/traces" test-tool trace2 001return 0 && GIT_TRACE2="$(pwd)/traces" test-tool trace2 001return 0 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <"$(ls traces/*)" >actual && scrub_normal <"$(ls traces/*)" >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 001return 0 start _EXE_ trace2 001return 0
@@ -103,7 +134,7 @@ test_expect_success 'automatic filename' '
test_expect_success 'normal stream, exit code 0' ' test_expect_success 'normal stream, exit code 0' '
test_when_finished "rm trace.normal actual expect" && test_when_finished "rm trace.normal actual expect" &&
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 0 && GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 0 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 002exit 0 start _EXE_ trace2 002exit 0
@@ -117,7 +148,7 @@ test_expect_success 'normal stream, exit code 0' '
test_expect_success 'normal stream, exit code 1' ' test_expect_success 'normal stream, exit code 1' '
test_when_finished "rm trace.normal actual expect" && test_when_finished "rm trace.normal actual expect" &&
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 1 && test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 1 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 002exit 1 start _EXE_ trace2 002exit 1
@@ -135,7 +166,7 @@ test_expect_success 'normal stream, exit code 1' '
test_expect_success 'normal stream, error event' ' test_expect_success 'normal stream, error event' '
test_when_finished "rm trace.normal actual expect" && test_when_finished "rm trace.normal actual expect" &&
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 003error "hello world" "this is a test" && GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 003error "hello world" "this is a test" &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 003error '\''hello world'\'' '\''this is a test'\'' start _EXE_ trace2 003error '\''hello world'\'' '\''this is a test'\''
@@ -155,7 +186,7 @@ test_expect_success 'normal stream, error event' '
test_expect_success 'BUG messages are written to trace2' ' test_expect_success 'BUG messages are written to trace2' '
test_when_finished "rm trace.normal actual expect" && test_when_finished "rm trace.normal actual expect" &&
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 007bug && test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 007bug &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 007bug start _EXE_ trace2 007bug
@@ -179,7 +210,7 @@ test_expect_success 'bug messages with BUG_if_bug() are written to trace2' '
sed "s/^.*: //" <err >actual && sed "s/^.*: //" <err >actual &&
test_cmp expect actual && test_cmp expect actual &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 008bug start _EXE_ trace2 008bug
@@ -205,7 +236,7 @@ test_expect_success 'bug messages without explicit BUG_if_bug() are written to t
sed "s/^.*: //" <err >actual && sed "s/^.*: //" <err >actual &&
test_cmp expect actual && test_cmp expect actual &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 009bug_BUG start _EXE_ trace2 009bug_BUG
@@ -230,7 +261,7 @@ test_expect_success 'bug messages followed by BUG() are written to trace2' '
sed "s/^.*: //" <err >actual && sed "s/^.*: //" <err >actual &&
test_cmp expect actual && test_cmp expect actual &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 010bug_BUG start _EXE_ trace2 010bug_BUG
@@ -262,7 +293,7 @@ test_expect_success 'using global config, normal stream, return code 0' '
test_config_global trace2.normalBrief 1 && test_config_global trace2.normalBrief 1 &&
test_config_global trace2.normalTarget "$(pwd)/trace.normal" && test_config_global trace2.normalTarget "$(pwd)/trace.normal" &&
test-tool trace2 001return 0 && test-tool trace2 001return 0 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 001return 0 start _EXE_ trace2 001return 0
@@ -280,7 +311,7 @@ test_expect_success 'using global config with include' '
mv "$(pwd)/.gitconfig" "$(pwd)/real.gitconfig" && mv "$(pwd)/.gitconfig" "$(pwd)/real.gitconfig" &&
test_config_global include.path "$(pwd)/real.gitconfig" && test_config_global include.path "$(pwd)/real.gitconfig" &&
test-tool trace2 001return 0 && test-tool trace2 001return 0 &&
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual && scrub_normal <trace.normal >actual &&
cat >expect <<-EOF && cat >expect <<-EOF &&
version $V version $V
start _EXE_ trace2 001return 0 start _EXE_ trace2 001return 0

View File

@@ -1,54 +0,0 @@
#!/usr/bin/perl
#
# Scrub the variable fields from the normal trace2 output to
# make testing easier.
use strict;
use warnings;
my $float = '[0-9]*\.[0-9]+([eE][-+]?[0-9]+)?';
# This code assumes that the trace2 data was written with bare
# turned on (which omits the "<clock> <file>:<line>" prefix.
while (<>) {
# Various messages include an elapsed time in the middle
# of the message. Replace the time with a placeholder to
# simplify our HEREDOC in the test script.
s/elapsed:$float/elapsed:_TIME_/g;
my $line = $_;
# we expect:
# start <argv0> [<argv1> [<argv2> [...]]]
#
# where argv0 might be a relative or absolute path, with
# or without quotes, and platform dependent. Replace argv0
# with a token for HEREDOC matching in the test script.
if ($line =~ m/^start/) {
$line =~ /^start\s+(.*)/;
my $argv = $1;
$argv =~ m/(\'[^\']*\'|[^ ]+)\s+(.*)/;
my $argv_0 = $1;
my $argv_rest = $2;
print "start _EXE_ $argv_rest\n";
}
elsif ($line =~ m/^cmd_path/) {
# Likewise, the 'cmd_path' message breaks out argv[0].
#
# This line is only emitted when RUNTIME_PREFIX is defined,
# so just omit it for testing purposes.
# print "cmd_path _EXE_\n";
}
elsif ($line =~ m/^cmd_ancestry/) {
# 'cmd_ancestry' is not implemented everywhere, so for portability's
# sake, skip it when parsing normal.
#
# print "$line";
}
else {
print "$line";
}
}

View File

@@ -4,6 +4,12 @@ test_description='test trace2 facility (perf target)'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping trace2 tests; Perl not available'
test_done
fi
# Turn off any inherited trace2 settings for this test. # Turn off any inherited trace2 settings for this test.
sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT
sane_unset GIT_TRACE2_PERF_BRIEF sane_unset GIT_TRACE2_PERF_BRIEF

View File

@@ -653,9 +653,8 @@ test_expect_success 'basic: commit and list refs' '
test_expect_success 'basic: can write large commit message' ' test_expect_success 'basic: can write large commit message' '
test_when_finished "rm -rf repo" && test_when_finished "rm -rf repo" &&
git init repo && git init repo &&
perl -e "
print \"this is a long commit message\" x 50000 awk "BEGIN { for (i = 0; i < 50000; i++) printf \"%s\", \"this is a long commit message\" }" >commit-msg &&
" >commit-msg &&
git -C repo commit --allow-empty --file=../commit-msg git -C repo commit --allow-empty --file=../commit-msg
' '

View File

@@ -145,7 +145,7 @@ test_expect_success 'small block size fails with large reflog message' '
( (
cd repo && cd repo &&
test_commit A && test_commit A &&
perl -e "print \"a\" x 500" >logmsg && test-tool genzeros 500 | tr "\000" "a" >logmsg &&
cat >expect <<-EOF && cat >expect <<-EOF &&
fatal: update_ref failed for ref ${SQ}refs/heads/logme${SQ}: reftable: transaction failure: entry too large fatal: update_ref failed for ref ${SQ}refs/heads/logme${SQ}: reftable: transaction failure: entry too large
EOF EOF

View File

@@ -1323,7 +1323,7 @@ extract_batch_output () {
' "$@" ' "$@"
} }
test_expect_success 'cat-file --batch-all-objects --batch ignores replace' ' test_expect_success PERL_TEST_HELPERS 'cat-file --batch-all-objects --batch ignores replace' '
git cat-file --batch-all-objects --batch >actual.raw && git cat-file --batch-all-objects --batch >actual.raw &&
extract_batch_output $orig <actual.raw >actual && extract_batch_output $orig <actual.raw >actual &&
{ {
@@ -1376,7 +1376,7 @@ test_expect_success 'batch-command flush without --buffer' '
grep "^fatal:.*flush is only for --buffer mode.*" err grep "^fatal:.*flush is only for --buffer mode.*" err
' '
script=' perl_script='
use warnings; use warnings;
use strict; use strict;
use IPC::Open2; use IPC::Open2;
@@ -1398,12 +1398,16 @@ $? == 0 or die "\$?=$?";
expect="$hello_oid blob $hello_size" expect="$hello_oid blob $hello_size"
test_expect_success PERL '--batch-check is unbuffered by default' ' test_lazy_prereq PERL_IPC_OPEN2 '
perl -e "$script" -- --batch-check $hello_oid "$expect" perl -MIPC::Open2 -e "exit 0"
' '
test_expect_success PERL '--batch-command info is unbuffered by default' ' test_expect_success PERL_IPC_OPEN2 '--batch-check is unbuffered by default' '
perl -e "$script" -- --batch-command $hello_oid "$expect" "info " perl -e "$perl_script" -- --batch-check $hello_oid "$expect"
'
test_expect_success PERL_IPC_OPEN2 '--batch-command info is unbuffered by default' '
perl -e "$perl_script" -- --batch-command $hello_oid "$expect" "info "
' '
test_done test_done

View File

@@ -205,7 +205,7 @@ test_expect_success 'too-short tree' '
grep "too-short tree object" err grep "too-short tree object" err
' '
test_expect_success 'malformed mode in tree' ' test_expect_success PERL_TEST_HELPERS 'malformed mode in tree' '
hex_oid=$(echo foo | git hash-object --stdin -w) && hex_oid=$(echo foo | git hash-object --stdin -w) &&
bin_oid=$(echo $hex_oid | hex2oct) && bin_oid=$(echo $hex_oid | hex2oct) &&
printf "9100644 \0$bin_oid" >tree-with-malformed-mode && printf "9100644 \0$bin_oid" >tree-with-malformed-mode &&
@@ -213,7 +213,7 @@ test_expect_success 'malformed mode in tree' '
grep "malformed mode in tree entry" err grep "malformed mode in tree entry" err
' '
test_expect_success 'empty filename in tree' ' test_expect_success PERL_TEST_HELPERS 'empty filename in tree' '
hex_oid=$(echo foo | git hash-object --stdin -w) && hex_oid=$(echo foo | git hash-object --stdin -w) &&
bin_oid=$(echo $hex_oid | hex2oct) && bin_oid=$(echo $hex_oid | hex2oct) &&
printf "100644 \0$bin_oid" >tree-with-empty-filename && printf "100644 \0$bin_oid" >tree-with-empty-filename &&
@@ -221,7 +221,7 @@ test_expect_success 'empty filename in tree' '
grep "empty filename in tree entry" err grep "empty filename in tree entry" err
' '
test_expect_success 'duplicate filename in tree' ' test_expect_success PERL_TEST_HELPERS 'duplicate filename in tree' '
hex_oid=$(echo foo | git hash-object --stdin -w) && hex_oid=$(echo foo | git hash-object --stdin -w) &&
bin_oid=$(echo $hex_oid | hex2oct) && bin_oid=$(echo $hex_oid | hex2oct) &&
{ {

View File

@@ -42,13 +42,13 @@ test_expect_success 'ls-tree piped to mktree (2)' '
' '
test_expect_success 'ls-tree output in wrong order given to mktree (1)' ' test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
perl -e "print reverse <>" <top | sort -r <top |
git mktree >actual && git mktree >actual &&
test_cmp tree actual test_cmp tree actual
' '
test_expect_success 'ls-tree output in wrong order given to mktree (2)' ' test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
perl -e "print reverse <>" <top.withsub | sort -r <top.withsub |
git mktree >actual && git mktree >actual &&
test_cmp tree.withsub actual test_cmp tree.withsub actual
' '

View File

@@ -346,7 +346,7 @@ test_expect_success 'unparseable tree object' '
test_grep ! "fatal: empty filename in tree entry" out test_grep ! "fatal: empty filename in tree entry" out
' '
test_expect_success 'tree entry with type mismatch' ' test_expect_success PERL_TEST_HELPERS 'tree entry with type mismatch' '
test_when_finished "remove_object \$blob" && test_when_finished "remove_object \$blob" &&
test_when_finished "remove_object \$tree" && test_when_finished "remove_object \$tree" &&
test_when_finished "remove_object \$commit" && test_when_finished "remove_object \$commit" &&
@@ -364,7 +364,7 @@ test_expect_success 'tree entry with type mismatch' '
test_grep ! "dangling blob" out test_grep ! "dangling blob" out
' '
test_expect_success 'tree entry with bogus mode' ' test_expect_success PERL_TEST_HELPERS 'tree entry with bogus mode' '
test_when_finished "remove_object \$blob" && test_when_finished "remove_object \$blob" &&
test_when_finished "remove_object \$tree" && test_when_finished "remove_object \$tree" &&
blob=$(echo blob | git hash-object -w --stdin) && blob=$(echo blob | git hash-object -w --stdin) &&
@@ -984,7 +984,7 @@ corrupt_index_checksum () {
# Corrupt the checksum on the index and then # Corrupt the checksum on the index and then
# verify that only fsck notices. # verify that only fsck notices.
test_expect_success 'detect corrupt index file in fsck' ' test_expect_success PERL_TEST_HELPERS 'detect corrupt index file in fsck' '
cp .git/index .git/index.backup && cp .git/index .git/index.backup &&
test_when_finished "mv .git/index.backup .git/index" && test_when_finished "mv .git/index.backup .git/index" &&
corrupt_index_checksum && corrupt_index_checksum &&

View File

@@ -70,7 +70,7 @@ test_expect_success 'ls-files -z does not quote funny filename' '
tabs ," (dq) and spaces tabs ," (dq) and spaces
EOF EOF
git ls-files -z >ls-files.z && git ls-files -z >ls-files.z &&
perl -pe "y/\000/\012/" <ls-files.z >current && tr "\000" "\012" <ls-files.z >current &&
test_cmp expected current test_cmp expected current
' '
@@ -107,7 +107,7 @@ test_expect_success 'diff-index -z does not quote funny filename' '
tabs ," (dq) and spaces tabs ," (dq) and spaces
EOF EOF
git diff-index -z --name-status $t0 >diff-index.z && git diff-index -z --name-status $t0 >diff-index.z &&
perl -pe "y/\000/\012/" <diff-index.z >current && tr "\000" "\012" <diff-index.z >current &&
test_cmp expected current test_cmp expected current
' '
@@ -117,7 +117,7 @@ test_expect_success 'diff-tree -z does not quote funny filename' '
tabs ," (dq) and spaces tabs ," (dq) and spaces
EOF EOF
git diff-tree -z --name-status $t0 $t1 >diff-tree.z && git diff-tree -z --name-status $t0 $t1 >diff-tree.z &&
perl -pe y/\\000/\\012/ <diff-tree.z >current && tr "\000" "\012" <diff-tree.z >current &&
test_cmp expected current test_cmp expected current
' '

View File

@@ -11,6 +11,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh . "$TEST_DIRECTORY"/lib-diff.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping diff various tests; Perl not available'
test_done
fi
test_expect_success setup ' test_expect_success setup '
GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&

View File

@@ -448,7 +448,7 @@ cat >>expect.no-threading <<EOF
--- ---
EOF EOF
test_expect_success 'no threading' ' test_expect_success PERL_TEST_HELPERS 'no threading' '
git checkout side && git checkout side &&
check_threading expect.no-threading main check_threading expect.no-threading main
' '
@@ -466,11 +466,11 @@ In-Reply-To: <0>
References: <0> References: <0>
EOF EOF
test_expect_success 'thread' ' test_expect_success PERL_TEST_HELPERS 'thread' '
check_threading expect.thread --thread main check_threading expect.thread --thread main
' '
test_expect_success '--thread overrides format.thread=deep' ' test_expect_success PERL_TEST_HELPERS '--thread overrides format.thread=deep' '
test_config format.thread deep && test_config format.thread deep &&
check_threading expect.thread --thread main check_threading expect.thread --thread main
' '
@@ -490,7 +490,7 @@ In-Reply-To: <1>
References: <1> References: <1>
EOF EOF
test_expect_success 'thread in-reply-to' ' test_expect_success PERL_TEST_HELPERS 'thread in-reply-to' '
check_threading expect.in-reply-to --in-reply-to="<test.message>" \ check_threading expect.in-reply-to --in-reply-to="<test.message>" \
--thread main --thread main
' '
@@ -512,7 +512,7 @@ In-Reply-To: <0>
References: <0> References: <0>
EOF EOF
test_expect_success 'thread cover-letter' ' test_expect_success PERL_TEST_HELPERS 'thread cover-letter' '
check_threading expect.cover-letter --cover-letter --thread main check_threading expect.cover-letter --cover-letter --thread main
' '
@@ -538,12 +538,12 @@ References: <1>
<0> <0>
EOF EOF
test_expect_success 'thread cover-letter in-reply-to' ' test_expect_success PERL_TEST_HELPERS 'thread cover-letter in-reply-to' '
check_threading expect.cl-irt --cover-letter \ check_threading expect.cl-irt --cover-letter \
--in-reply-to="<test.message>" --thread main --in-reply-to="<test.message>" --thread main
' '
test_expect_success 'thread explicit shallow' ' test_expect_success PERL_TEST_HELPERS 'thread explicit shallow' '
check_threading expect.cl-irt --cover-letter \ check_threading expect.cl-irt --cover-letter \
--in-reply-to="<test.message>" --thread=shallow main --in-reply-to="<test.message>" --thread=shallow main
' '
@@ -562,7 +562,7 @@ References: <0>
<1> <1>
EOF EOF
test_expect_success 'thread deep' ' test_expect_success PERL_TEST_HELPERS 'thread deep' '
check_threading expect.deep --thread=deep main check_threading expect.deep --thread=deep main
' '
@@ -584,7 +584,7 @@ References: <1>
<2> <2>
EOF EOF
test_expect_success 'thread deep in-reply-to' ' test_expect_success PERL_TEST_HELPERS 'thread deep in-reply-to' '
check_threading expect.deep-irt --thread=deep \ check_threading expect.deep-irt --thread=deep \
--in-reply-to="<test.message>" main --in-reply-to="<test.message>" main
' '
@@ -609,7 +609,7 @@ References: <0>
<2> <2>
EOF EOF
test_expect_success 'thread deep cover-letter' ' test_expect_success PERL_TEST_HELPERS 'thread deep cover-letter' '
check_threading expect.deep-cl --cover-letter --thread=deep main check_threading expect.deep-cl --cover-letter --thread=deep main
' '
@@ -638,27 +638,27 @@ References: <1>
<3> <3>
EOF EOF
test_expect_success 'thread deep cover-letter in-reply-to' ' test_expect_success PERL_TEST_HELPERS 'thread deep cover-letter in-reply-to' '
check_threading expect.deep-cl-irt --cover-letter \ check_threading expect.deep-cl-irt --cover-letter \
--in-reply-to="<test.message>" --thread=deep main --in-reply-to="<test.message>" --thread=deep main
' '
test_expect_success 'thread via config' ' test_expect_success PERL_TEST_HELPERS 'thread via config' '
test_config format.thread true && test_config format.thread true &&
check_threading expect.thread main check_threading expect.thread main
' '
test_expect_success 'thread deep via config' ' test_expect_success PERL_TEST_HELPERS 'thread deep via config' '
test_config format.thread deep && test_config format.thread deep &&
check_threading expect.deep main check_threading expect.deep main
' '
test_expect_success 'thread config + override' ' test_expect_success PERL_TEST_HELPERS 'thread config + override' '
test_config format.thread deep && test_config format.thread deep &&
check_threading expect.thread --thread main check_threading expect.thread --thread main
' '
test_expect_success 'thread config + --no-thread' ' test_expect_success PERL_TEST_HELPERS 'thread config + --no-thread' '
test_config format.thread deep && test_config format.thread deep &&
check_threading expect.no-threading --no-thread main check_threading expect.no-threading --no-thread main
' '

View File

@@ -237,7 +237,7 @@ check_external_diff 0 empty empty 0 on --quiet
check_external_diff 1 empty empty 1 on --quiet check_external_diff 1 empty empty 1 on --quiet
check_external_diff 128 empty error 2 on --quiet check_external_diff 128 empty error 2 on --quiet
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file echo NULZbetweenZwords | tr "Z" "\000" > file
test_expect_success 'force diff with "diff"' ' test_expect_success 'force diff with "diff"' '
after=$(git hash-object file) && after=$(git hash-object file) &&

View File

@@ -31,7 +31,8 @@ test_expect_success "$test_description" '
git config --bool diff.suppressBlankEmpty true && git config --bool diff.suppressBlankEmpty true &&
git diff f > actual && git diff f > actual &&
test_cmp exp actual && test_cmp exp actual &&
perl -i.bak -p -e "s/^\$/ /" exp && sed "s/^\$/ /" exp >exp.munged &&
mv exp.munged exp &&
git config --bool diff.suppressBlankEmpty false && git config --bool diff.suppressBlankEmpty false &&
git diff f > actual && git diff f > actual &&
test_cmp exp actual && test_cmp exp actual &&

View File

@@ -20,13 +20,10 @@ cat >expect.text <<'EOF'
+1 +1
EOF EOF
cat >hexdump <<'EOF'
#!/bin/sh
"$PERL_PATH" -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1"
EOF
chmod +x hexdump
test_expect_success 'setup binary file with history' ' test_expect_success 'setup binary file with history' '
write_script hexdump <<-\EOF &&
tr "\000\001" "01" <"$1"
EOF
test_commit --printf one file "\\0\\n" && test_commit --printf one file "\\0\\n" &&
test_commit --printf --append two file "\\01\\n" test_commit --printf --append two file "\\01\\n"
' '

View File

@@ -57,24 +57,19 @@ test_expect_success 'diff --stat counts binary rewrite as 0 lines' '
grep " rewrite file" diff grep " rewrite file" diff
' '
{
echo "#!$SHELL_PATH"
cat <<'EOF'
"$PERL_PATH" -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1"
EOF
} >dump
chmod +x dump
test_expect_success 'setup textconv' ' test_expect_success 'setup textconv' '
write_script dump <<-\EOF &&
test-tool hexdump <"$1"
EOF
echo file diff=foo >.gitattributes && echo file diff=foo >.gitattributes &&
git config diff.foo.textconv "\"$(pwd)\""/dump git config diff.foo.textconv "\"$(pwd)\""/dump
' '
test_expect_success 'rewrite diff respects textconv' ' test_expect_success 'rewrite diff respects textconv' '
git diff -B >diff && git diff -B >diff &&
grep "dissimilarity index" diff && test_grep "dissimilarity index" diff &&
grep "^-61" diff && test_grep "^-3d 0a 00" diff &&
grep "^-0" diff test_grep "^+3d 0a 01" diff
' '
test_done test_done

View File

@@ -13,6 +13,12 @@ test_description='test tree diff when trees have duplicate entries'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping diff duplicates tests; Perl not available'
test_done
fi
# make_tree_entry <mode> <mode> <sha1> # make_tree_entry <mode> <mode> <sha1>
# #
# We have to rely on perl here because not all printfs understand # We have to rely on perl here because not all printfs understand

View File

@@ -26,10 +26,10 @@ test_expect_success 'setup' '
git commit -m "Initial Version" 2>/dev/null && git commit -m "Initial Version" 2>/dev/null &&
git checkout -b binary && git checkout -b binary &&
perl -pe "y/x/\000/" <file1 >file3 && tr "x" "\000" <file1 >file3 &&
cat file3 >file4 && cat file3 >file4 &&
git add file2 && git add file2 &&
perl -pe "y/\000/v/" <file3 >file1 && tr "y" "\000" <file3 >file1 &&
rm -f file2 && rm -f file2 &&
git update-index --add --remove file1 file2 file3 file4 && git update-index --add --remove file1 file2 file3 file4 &&
git commit -m "Second Version" && git commit -m "Second Version" &&
@@ -158,7 +158,7 @@ test_expect_success 'apply binary -p0 diff' '
test -z "$(git diff --name-status binary -- file3)" test -z "$(git diff --name-status binary -- file3)"
' '
test_expect_success 'reject truncated binary diff' ' test_expect_success PERL_TEST_HELPERS 'reject truncated binary diff' '
do_reset && do_reset &&
# this length is calculated to get us very close to # this length is calculated to get us very close to

View File

@@ -13,14 +13,14 @@ test_description='git apply in reverse
test_expect_success setup ' test_expect_success setup '
test_write_lines a b c d e f g h i j k l m n >file1 && test_write_lines a b c d e f g h i j k l m n >file1 &&
perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 && tr "ijk" "\000\001\002" <file1 >file2 &&
git add file1 file2 && git add file1 file2 &&
git commit -m initial && git commit -m initial &&
git tag initial && git tag initial &&
test_write_lines a b c g h i J K L m o n p q >file1 && test_write_lines a b c g h i J K L m o n p q >file1 &&
perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 && tr "mon" "\000\001\002" <file1 >file2 &&
git commit -a -m second && git commit -a -m second &&
git tag second && git tag second &&

View File

@@ -1084,13 +1084,13 @@ test_expect_success 'am works with multi-line in-body headers' '
Body test" --author="$LONG <long@example.com>" && Body test" --author="$LONG <long@example.com>" &&
git format-patch --stdout -1 >patch && git format-patch --stdout -1 >patch &&
# bump from, date, and subject down to in-body header # bump from, date, and subject down to in-body header
perl -lpe " awk "
if (/^From:/) { /^From:/{
print \"From: x <x\@example.com>\"; print \"From: x <x\@example.com>\";
print \"Date: Sat, 1 Jan 2000 00:00:00 +0000\"; print \"Date: Sat, 1 Jan 2000 00:00:00 +0000\";
print \"Subject: x\n\"; print \"Subject: x\n\";
} }; 1
" patch >msg && " <patch >msg &&
git checkout HEAD^ && git checkout HEAD^ &&
git am msg && git am msg &&
# Ensure that the author and full message are present # Ensure that the author and full message are present

View File

@@ -81,7 +81,7 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
test_might_fail git config --unset rerere.enabled && test_might_fail git config --unset rerere.enabled &&
test_must_fail git merge first && test_must_fail git merge first &&
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && sha1=$(sed "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 && rr=.git/rr-cache/$sha1 &&
grep "^=======\$" $rr/preimage && grep "^=======\$" $rr/preimage &&
! test -f $rr/postimage && ! test -f $rr/postimage &&
@@ -94,7 +94,7 @@ test_expect_success 'rerere.enabled works, too' '
git reset --hard && git reset --hard &&
test_must_fail git merge first && test_must_fail git merge first &&
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && sha1=$(sed "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 && rr=.git/rr-cache/$sha1 &&
grep ^=======$ $rr/preimage grep ^=======$ $rr/preimage
' '
@@ -104,7 +104,7 @@ test_expect_success 'set up rr-cache' '
git config rerere.enabled true && git config rerere.enabled true &&
git reset --hard && git reset --hard &&
test_must_fail git merge first && test_must_fail git merge first &&
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) && sha1=$(sed "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 rr=.git/rr-cache/$sha1
' '
@@ -188,7 +188,7 @@ test_expect_success 'rerere updates postimage timestamp' '
test_expect_success 'rerere clear' ' test_expect_success 'rerere clear' '
mv $rr/postimage .git/post-saved && mv $rr/postimage .git/post-saved &&
echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR && echo "$sha1 a1" | tr "\012" "\000" >.git/MERGE_RR &&
git rerere clear && git rerere clear &&
! test -d $rr ! test -d $rr
' '

View File

@@ -698,7 +698,7 @@ test_expect_success '%(trailers:only=no,only=true) shows only "key: value" trail
test_cmp expect actual test_cmp expect actual
' '
test_expect_success '%(trailers:unfold) unfolds trailers' ' test_expect_success PERL_TEST_HELPERS '%(trailers:unfold) unfolds trailers' '
git log --no-walk --pretty="%(trailers:unfold)" >actual && git log --no-walk --pretty="%(trailers:unfold)" >actual &&
{ {
unfold <trailers && unfold <trailers &&
@@ -707,7 +707,7 @@ test_expect_success '%(trailers:unfold) unfolds trailers' '
test_cmp expect actual test_cmp expect actual
' '
test_expect_success ':only and :unfold work together' ' test_expect_success PERL_TEST_HELPERS ':only and :unfold work together' '
git log --no-walk --pretty="%(trailers:only,unfold)" >actual && git log --no-walk --pretty="%(trailers:only,unfold)" >actual &&
git log --no-walk --pretty="%(trailers:unfold,only)" >reverse && git log --no-walk --pretty="%(trailers:unfold,only)" >reverse &&
test_cmp actual reverse && test_cmp actual reverse &&
@@ -754,7 +754,7 @@ test_expect_success '%(trailers:key=foo) handles multiple lines even if folded'
test_cmp expect actual test_cmp expect actual
' '
test_expect_success '%(trailers:key=foo,unfold) properly unfolds' ' test_expect_success PERL_TEST_HELPERS '%(trailers:key=foo,unfold) properly unfolds' '
git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by,unfold)" >actual && git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by,unfold)" >actual &&
unfold <trailers | grep Signed-off-by >expect && unfold <trailers | grep Signed-off-by >expect &&
test_cmp expect actual test_cmp expect actual

View File

@@ -738,20 +738,20 @@ check_corrupt_graph () {
test_cmp expect.out out test_cmp expect.out out
} }
test_expect_success 'Bloom reader notices too-small data chunk' ' test_expect_success PERL_TEST_HELPERS 'Bloom reader notices too-small data chunk' '
check_corrupt_graph BDAT clear 00000000 && check_corrupt_graph BDAT clear 00000000 &&
echo "warning: ignoring too-small changed-path chunk" \ echo "warning: ignoring too-small changed-path chunk" \
"(4 < 12) in commit-graph file" >expect.err && "(4 < 12) in commit-graph file" >expect.err &&
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'Bloom reader notices out-of-bounds filter offsets' ' test_expect_success PERL_TEST_HELPERS 'Bloom reader notices out-of-bounds filter offsets' '
check_corrupt_graph BIDX 12 FFFFFFFF && check_corrupt_graph BIDX 12 FFFFFFFF &&
# use grep to avoid depending on exact chunk size # use grep to avoid depending on exact chunk size
grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err
' '
test_expect_success 'Bloom reader notices too-small index chunk' ' test_expect_success PERL_TEST_HELPERS 'Bloom reader notices too-small index chunk' '
# replace the index with a single entry, making most # replace the index with a single entry, making most
# lookups out-of-bounds # lookups out-of-bounds
check_corrupt_graph BIDX clear 00000000 && check_corrupt_graph BIDX clear 00000000 &&
@@ -760,7 +760,7 @@ test_expect_success 'Bloom reader notices too-small index chunk' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'Bloom reader notices out-of-order index offsets' ' test_expect_success PERL_TEST_HELPERS 'Bloom reader notices out-of-order index offsets' '
# we do not know any real offsets, but we can pick # we do not know any real offsets, but we can pick
# something plausible; we should not get to the point of # something plausible; we should not get to the point of
# actually reading from the bogus offsets anyway. # actually reading from the bogus offsets anyway.

View File

@@ -4,6 +4,12 @@ test_description='test corner cases of git-archive'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping archive corner cases tests; Perl not available'
test_done
fi
# the 10knuls.tar file is used to test for an empty git generated tar # the 10knuls.tar file is used to test for an empty git generated tar
# without having to invoke tar because an otherwise valid empty GNU tar # without having to invoke tar because an otherwise valid empty GNU tar
# will be considered broken by {Open,Net}BSD tar # will be considered broken by {Open,Net}BSD tar

View File

@@ -9,9 +9,9 @@ test_description='git pack-object'
test_expect_success 'setup' ' test_expect_success 'setup' '
rm -f .git/index* && rm -f .git/index* &&
perl -e "print \"a\" x 4096;" >a && test-tool genzeros 4096 | tr "\000" "a" >a &&
perl -e "print \"b\" x 4096;" >b && test-tool genzeros 4096 | tr "\000" "b" >b &&
perl -e "print \"c\" x 4096;" >c && test-tool genzeros 4096 | tr "\000" "c" >c &&
test-tool genrandom "seed a" 2097152 >a_big && test-tool genrandom "seed a" 2097152 >a_big &&
test-tool genrandom "seed b" 2097152 >b_big && test-tool genrandom "seed b" 2097152 >b_big &&
git update-index --add a a_big b b_big c && git update-index --add a a_big b b_big c &&
@@ -140,7 +140,7 @@ test_expect_success 'pack-object <stdin parsing: --stdin-packs handles garbage'
# usage: check_deltas <stderr_from_pack_objects> <cmp_op> <nr_deltas> # usage: check_deltas <stderr_from_pack_objects> <cmp_op> <nr_deltas>
# e.g.: check_deltas stderr -gt 0 # e.g.: check_deltas stderr -gt 0
check_deltas() { check_deltas() {
deltas=$(perl -lne '/delta (\d+)/ and print $1' "$1") && deltas=$(sed -n 's/Total [0-9][0-9]* (delta \([0-9][0-9]*\)).*/\1/p' "$1") &&
shift && shift &&
if ! test "$deltas" "$@" if ! test "$deltas" "$@"
then then
@@ -215,7 +215,7 @@ test_expect_success 'unpack with OFS_DELTA (core.fsyncmethod=batch)' '
check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION" check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION"
' '
test_expect_success 'compare delta flavors' ' test_expect_success PERL_TEST_HELPERS 'compare delta flavors' '
perl -e '\'' perl -e '\''
defined($_ = -s $_) or die for @ARGV; defined($_ = -s $_) or die for @ARGV;
exit 1 if $ARGV[0] <= $ARGV[1]; exit 1 if $ARGV[0] <= $ARGV[1];

View File

@@ -103,7 +103,8 @@ test_expect_success 'create corruption in data of first object' '
create_new_pack && create_new_pack &&
git prune-packed && git prune-packed &&
chmod +w ${pack}.pack && chmod +w ${pack}.pack &&
perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack && sed "s/ base /abcdef/" ${pack}.pack >${pack}.pack.munged &&
mv ${pack}.pack.munged ${pack}.pack &&
test_must_fail git cat-file blob $blob_1 > /dev/null && test_must_fail git cat-file blob $blob_1 > /dev/null &&
test_must_fail git cat-file blob $blob_2 > /dev/null && test_must_fail git cat-file blob $blob_2 > /dev/null &&
test_must_fail git cat-file blob $blob_3 > /dev/null test_must_fail git cat-file blob $blob_3 > /dev/null
@@ -160,7 +161,8 @@ test_expect_success 'create corruption in data of first delta' '
create_new_pack && create_new_pack &&
git prune-packed && git prune-packed &&
chmod +w ${pack}.pack && chmod +w ${pack}.pack &&
perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack && sed "s/ delta1 /abcdefgh/" ${pack}.pack >${pack}.pack.munged &&
mv ${pack}.pack.munged ${pack}.pack &&
git cat-file blob $blob_1 > /dev/null && git cat-file blob $blob_1 > /dev/null &&
test_must_fail git cat-file blob $blob_2 > /dev/null && test_must_fail git cat-file blob $blob_2 > /dev/null &&
test_must_fail git cat-file blob $blob_3 > /dev/null test_must_fail git cat-file blob $blob_3 > /dev/null

View File

@@ -421,7 +421,7 @@ test_bitmap_cases () {
# mark the commits which did not receive bitmaps as preferred, # mark the commits which did not receive bitmaps as preferred,
# and generate the bitmap again # and generate the bitmap again
perl -pe "s{^}{create refs/tags/include/$. }" <before | sed "s|\(.*\)|create refs/tags/include/\1 \1|" before |
git update-ref --stdin && git update-ref --stdin &&
git -c pack.preferBitmapTips=refs/tags/include repack -adb && git -c pack.preferBitmapTips=refs/tags/include repack -adb &&

View File

@@ -76,11 +76,11 @@ test_expect_success 'create series of packs' '
max_chain() { max_chain() {
git index-pack --verify-stat-only "$1" >output && git index-pack --verify-stat-only "$1" >output &&
perl -lne ' awk '
BEGIN { $len = 0 } BEGIN { len=0 }
/chain length = (\d+)/ and $len = $1; /chain length = [0-9]+:/{ len=$4 }
END { print $len } END { print len }
' output ' <output | tr -d ':'
} }
# Note that this whole setup is pretty reliant on the current # Note that this whole setup is pretty reliant on the current

View File

@@ -837,7 +837,7 @@ check_corrupt_chunk () {
test_cmp expect.out out test_cmp expect.out out
} }
test_expect_success 'reader notices too-small oid fanout chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small oid fanout chunk' '
# make it big enough that the graph file is plausible, # make it big enough that the graph file is plausible,
# otherwise we hit an earlier check # otherwise we hit an earlier check
check_corrupt_chunk OIDF clear $(printf "000000%02x" $(test_seq 250)) && check_corrupt_chunk OIDF clear $(printf "000000%02x" $(test_seq 250)) &&
@@ -848,7 +848,7 @@ test_expect_success 'reader notices too-small oid fanout chunk' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices fanout/lookup table mismatch' ' test_expect_success PERL_TEST_HELPERS 'reader notices fanout/lookup table mismatch' '
check_corrupt_chunk OIDF 1020 "FFFFFFFF" && check_corrupt_chunk OIDF 1020 "FFFFFFFF" &&
cat >expect.err <<-\EOF && cat >expect.err <<-\EOF &&
error: commit-graph OID lookup chunk is the wrong size error: commit-graph OID lookup chunk is the wrong size
@@ -857,7 +857,7 @@ test_expect_success 'reader notices fanout/lookup table mismatch' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices out-of-bounds fanout' ' test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds fanout' '
# Rather than try to corrupt a specific hash, we will just # Rather than try to corrupt a specific hash, we will just
# wreck them all. But we cannot just set them all to 0xFFFFFFFF or # wreck them all. But we cannot just set them all to 0xFFFFFFFF or
# similar, as they are used for hi/lo starts in a binary search (so if # similar, as they are used for hi/lo starts in a binary search (so if
@@ -873,7 +873,7 @@ test_expect_success 'reader notices out-of-bounds fanout' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices too-small commit data chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small commit data chunk' '
check_corrupt_chunk CDAT clear 00000000 && check_corrupt_chunk CDAT clear 00000000 &&
cat >expect.err <<-\EOF && cat >expect.err <<-\EOF &&
error: commit-graph commit data chunk is wrong size error: commit-graph commit data chunk is wrong size
@@ -882,7 +882,7 @@ test_expect_success 'reader notices too-small commit data chunk' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices out-of-bounds extra edge' ' test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds extra edge' '
check_corrupt_chunk EDGE clear && check_corrupt_chunk EDGE clear &&
cat >expect.err <<-\EOF && cat >expect.err <<-\EOF &&
error: commit-graph extra-edges pointer out of bounds error: commit-graph extra-edges pointer out of bounds
@@ -890,7 +890,7 @@ test_expect_success 'reader notices out-of-bounds extra edge' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices too-small generations chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small generations chunk' '
check_corrupt_chunk GDA2 clear 00000000 && check_corrupt_chunk GDA2 clear 00000000 &&
cat >expect.err <<-\EOF && cat >expect.err <<-\EOF &&
error: commit-graph generations chunk is wrong size error: commit-graph generations chunk is wrong size

View File

@@ -1120,7 +1120,7 @@ corrupt_chunk () {
corrupt_chunk_file $midx "$@" corrupt_chunk_file $midx "$@"
} }
test_expect_success 'reader notices too-small oid fanout chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small oid fanout chunk' '
corrupt_chunk OIDF clear 00000000 && corrupt_chunk OIDF clear 00000000 &&
test_must_fail git log 2>err && test_must_fail git log 2>err &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
@@ -1130,7 +1130,7 @@ test_expect_success 'reader notices too-small oid fanout chunk' '
test_cmp expect err test_cmp expect err
' '
test_expect_success 'reader notices too-small oid lookup chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small oid lookup chunk' '
corrupt_chunk OIDL clear 00000000 && corrupt_chunk OIDL clear 00000000 &&
test_must_fail git log 2>err && test_must_fail git log 2>err &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
@@ -1140,7 +1140,7 @@ test_expect_success 'reader notices too-small oid lookup chunk' '
test_cmp expect err test_cmp expect err
' '
test_expect_success 'reader notices too-small pack names chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small pack names chunk' '
# There is no NUL to terminate the name here, so the # There is no NUL to terminate the name here, so the
# chunk is too short. # chunk is too short.
corrupt_chunk PNAM clear 70656666 && corrupt_chunk PNAM clear 70656666 &&
@@ -1151,7 +1151,7 @@ test_expect_success 'reader notices too-small pack names chunk' '
test_cmp expect err test_cmp expect err
' '
test_expect_success 'reader handles unaligned chunks' ' test_expect_success PERL_TEST_HELPERS 'reader handles unaligned chunks' '
# A 9-byte PNAM means all of the subsequent chunks # A 9-byte PNAM means all of the subsequent chunks
# will no longer be 4-byte aligned, but it is still # will no longer be 4-byte aligned, but it is still
# a valid one-pack chunk on its own (it is "foo.pack\0"). # a valid one-pack chunk on its own (it is "foo.pack\0").
@@ -1165,7 +1165,7 @@ test_expect_success 'reader handles unaligned chunks' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices too-small object offset chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small object offset chunk' '
corrupt_chunk OOFF clear 00000000 && corrupt_chunk OOFF clear 00000000 &&
test_must_fail git log 2>err && test_must_fail git log 2>err &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
@@ -1175,7 +1175,7 @@ test_expect_success 'reader notices too-small object offset chunk' '
test_cmp expect err test_cmp expect err
' '
test_expect_success 'reader bounds-checks large offset table' ' test_expect_success PERL_TEST_HELPERS 'reader bounds-checks large offset table' '
# re-use the objects64 dir here to cheaply get access to a midx # re-use the objects64 dir here to cheaply get access to a midx
# with large offsets. # with large offsets.
git init repo && git init repo &&
@@ -1197,7 +1197,7 @@ test_expect_success 'reader bounds-checks large offset table' '
) )
' '
test_expect_success 'reader notices too-small revindex chunk' ' test_expect_success PERL_TEST_HELPERS 'reader notices too-small revindex chunk' '
# We only get a revindex with bitmaps (and likewise only # We only get a revindex with bitmaps (and likewise only
# load it when they are asked for). # load it when they are asked for).
test_config repack.writeBitmaps true && test_config repack.writeBitmaps true &&
@@ -1214,7 +1214,7 @@ test_expect_success 'reader notices too-small revindex chunk' '
test_cmp expect.err err test_cmp expect.err err
' '
test_expect_success 'reader notices out-of-bounds fanout' ' test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds fanout' '
# This is similar to the out-of-bounds fanout test in t5318. The values # This is similar to the out-of-bounds fanout test in t5318. The values
# in adjacent entries should be large but not identical (they # in adjacent entries should be large but not identical (they
# are used as hi/lo starts for a binary search, which would then abort # are used as hi/lo starts for a binary search, which would then abort

View File

@@ -401,7 +401,7 @@ test_expect_success 'verify across alternates' '
) )
' '
test_expect_success 'reader bounds-checks base-graph chunk' ' test_expect_success PERL_TEST_HELPERS 'reader bounds-checks base-graph chunk' '
git clone --no-hardlinks . corrupt-base-chunk && git clone --no-hardlinks . corrupt-base-chunk &&
( (
cd corrupt-base-chunk && cd corrupt-base-chunk &&

View File

@@ -176,8 +176,8 @@ test_midx_bitmap_cases () {
comm -13 bitmaps commits >before && comm -13 bitmaps commits >before &&
test_line_count = 1 before && test_line_count = 1 before &&
perl -ne "printf(\"create refs/tags/include/%d \", $.); print" \ sed "s|\(.*\)|create refs/tags/include/\1 \1|" before |
<before | git update-ref --stdin && git update-ref --stdin &&
rm -fr $midx-$(midx_checksum $objdir).bitmap && rm -fr $midx-$(midx_checksum $objdir).bitmap &&
rm -fr $midx && rm -fr $midx &&

View File

@@ -74,7 +74,7 @@ test_expect_success 'single commit with generation data exceeding UINT32_MAX' '
git -C repo-uint32-max commit-graph verify git -C repo-uint32-max commit-graph verify
' '
test_expect_success 'reader notices out-of-bounds generation overflow' ' test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds generation overflow' '
graph=.git/objects/info/commit-graph && graph=.git/objects/info/commit-graph &&
test_when_finished "rm -rf $graph" && test_when_finished "rm -rf $graph" &&
git commit-graph write --reachable && git commit-graph write --reachable &&

View File

@@ -28,9 +28,8 @@ test_pseudo_merges_reused () {
tag_everything () { tag_everything () {
git rev-list --all --no-object-names >in && git rev-list --all --no-object-names >in &&
perl -lne ' sed 's|\(.*\)|create refs/tags/\1 \1|' in |
print "create refs/tags/" . $. . " " . $1 if /([0-9a-f]+)/ git update-ref --stdin
' <in | git update-ref --stdin
} }
test_expect_success 'setup' ' test_expect_success 'setup' '
@@ -102,7 +101,7 @@ test_expect_success 'stale bitmap traversal with pseudo-merges' '
test_cmp expect actual test_cmp expect actual
' '
test_expect_success 'bitmapPseudoMerge.sampleRate adjusts commit selection rate' ' test_expect_success PERL_TEST_HELPERS 'bitmapPseudoMerge.sampleRate adjusts commit selection rate' '
test_config bitmapPseudoMerge.test.pattern "refs/tags/" && test_config bitmapPseudoMerge.test.pattern "refs/tags/" &&
test_config bitmapPseudoMerge.test.maxMerges 1 && test_config bitmapPseudoMerge.test.maxMerges 1 &&
test_config bitmapPseudoMerge.test.stableThreshold never && test_config bitmapPseudoMerge.test.stableThreshold never &&
@@ -235,8 +234,7 @@ test_expect_success 'pseudo-merge pattern with capture groups' '
test_commit_bulk 16 && test_commit_bulk 16 &&
git rev-list HEAD~16.. >in && git rev-list HEAD~16.. >in &&
sed "s|\(.*\)|create refs/remotes/$r/tags/\1 \1" in |
perl -lne "print \"create refs/remotes/$r/tags/\$. \$_\"" <in |
git update-ref --stdin || return 1 git update-ref --stdin || return 1
done && done &&
@@ -252,7 +250,7 @@ test_expect_success 'pseudo-merge pattern with capture groups' '
do do
test_pseudo_merge_commits $m >oids && test_pseudo_merge_commits $m >oids &&
grep -f oids refs | grep -f oids refs |
perl -lne "print \$1 if /refs\/remotes\/([0-9]+)/" | sed -n "s|refs/remotes/\([0-9][0-9]*\)/|\1|p" &&
sort -u || return 1 sort -u || return 1
done >remotes && done >remotes &&

View File

@@ -275,7 +275,7 @@ extract_ref_advertisement () {
' '
} }
test_expect_success 'receive-pack de-dupes .have lines' ' test_expect_success PERL_TEST_HELPERS 'receive-pack de-dupes .have lines' '
git init shared && git init shared &&
git -C shared commit --allow-empty -m both && git -C shared commit --allow-empty -m both &&
git clone -s shared fork && git clone -s shared fork &&

View File

@@ -17,7 +17,7 @@ test_expect_success 'setup' '
' '
extract_haves () { extract_haves () {
depacketize | perl -lne '/^(\S+) \.have/ and print $1' depacketize | sed -n 's/^\([^ ][^ ]*\) \.have/\1/p'
} }
test_expect_success 'with core.alternateRefsCommand' ' test_expect_success 'with core.alternateRefsCommand' '

View File

@@ -7,6 +7,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping tagfollow tests; Perl not available'
test_done
fi
# End state of the repository: # End state of the repository:
# #
# T - tag1 S - tag2 # T - tag1 S - tag2

View File

@@ -359,7 +359,7 @@ test_expect_success \
grep "Cannot demote unterminatedheader" act grep "Cannot demote unterminatedheader" act
' '
test_expect_success 'badFilemode is not a strict error' ' test_expect_success PERL_TEST_HELPERS 'badFilemode is not a strict error' '
git init --bare badmode.git && git init --bare badmode.git &&
tree=$( tree=$(
cd badmode.git && cd badmode.git &&

View File

@@ -8,6 +8,12 @@ test_description='Per branch config variables affects "git fetch".
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-bundle.sh . "$TEST_DIRECTORY"/lib-bundle.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping fetch tests; Perl not available'
test_done
fi
D=$(pwd) D=$(pwd)
test_expect_success setup ' test_expect_success setup '

View File

@@ -4,6 +4,12 @@ test_description='fetching via git:// using core.gitproxy'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping fetch proxy tests; Perl not available'
test_done
fi
test_expect_success 'setup remote repo' ' test_expect_success 'setup remote repo' '
git init remote && git init remote &&
(cd remote && (cd remote &&

View File

@@ -205,7 +205,7 @@ test_expect_success GPG 'inconsistent push options in signed push not allowed' '
# Tweak the push output to make the push option outside the cert # Tweak the push output to make the push option outside the cert
# different, then replay it on a fresh dst, checking that ff is not # different, then replay it on a fresh dst, checking that ff is not
# deleted. # deleted.
perl -pe "s/([^ ])bar/\$1baz/" push >push.tweak && sed "s/\([^ ]\)bar/\1baz/" push >push.tweak &&
prepare_dst && prepare_dst &&
git -C dst config receive.certnonceseed sekrit && git -C dst config receive.certnonceseed sekrit &&
git -C dst config receive.advertisepushoptions 1 && git -C dst config receive.advertisepushoptions 1 &&

View File

@@ -271,22 +271,21 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f
git -C "$REPO" config protocol.version 2 && git -C "$REPO" config protocol.version 2 &&
git -C client config protocol.version 2 && git -C client config protocol.version 2 &&
git -C client fetch --depth=2 "$HTTPD_URL/one_time_perl/repo" main:a_branch && git -C client fetch --depth=2 "$HTTPD_URL/one_time_script/repo" main:a_branch &&
# Craft a situation in which the server sends back an unshallow request # Craft a situation in which the server sends back an unshallow request
# with an empty packfile. This is done by refetching with a shorter # with an empty packfile. This is done by refetching with a shorter
# depth (to ensure that the packfile is empty), and overwriting the # depth (to ensure that the packfile is empty), and overwriting the
# shallow line in the response with the unshallow line we want. # shallow line in the response with the unshallow line we want.
printf "$(test_oid perl)" \ write_script "$HTTPD_ROOT_PATH/one-time-script" <<-EOF &&
"$(git -C "$REPO" rev-parse HEAD)" \ sed "$(printf "$(test_oid perl)" "$(git -C "$REPO" rev-parse HEAD)" "$(git -C "$REPO" rev-parse HEAD^)")" "\$1"
"$(git -C "$REPO" rev-parse HEAD^)" \ EOF
>"$HTTPD_ROOT_PATH/one-time-perl" &&
test_must_fail env GIT_TEST_SIDEBAND_ALL=0 git -C client \ test_must_fail env GIT_TEST_SIDEBAND_ALL=0 git -C client \
fetch --depth=1 "$HTTPD_URL/one_time_perl/repo" \ fetch --depth=1 "$HTTPD_URL/one_time_script/repo" \
main:a_branch && main:a_branch &&
# Ensure that the one-time-perl script was used. # Ensure that the one-time-script script was used.
! test -e "$HTTPD_ROOT_PATH/one-time-perl" && ! test -e "$HTTPD_ROOT_PATH/one-time-script" &&
# Ensure that the resulting repo is consistent, despite our failure to # Ensure that the resulting repo is consistent, despite our failure to
# fetch. # fetch.

View File

@@ -7,6 +7,13 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-httpd.sh . "$TEST_DIRECTORY"/lib-httpd.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping http fetch smart tests; Perl not available'
test_done
fi
test "$HTTP_PROTO" = "HTTP/2" && enable_http2 test "$HTTP_PROTO" = "HTTP/2" && enable_http2
start_httpd start_httpd

View File

@@ -4,6 +4,12 @@ test_description='test git-http-backend respects CONTENT_LENGTH'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping http backend content tests; Perl not available'
test_done
fi
test_lazy_prereq GZIP 'gzip --version' test_lazy_prereq GZIP 'gzip --version'
verify_http_result() { verify_http_result() {

View File

@@ -649,7 +649,7 @@ test_expect_success 'GIT_TRACE_PACKFILE produces a usable pack' '
git -C replay.git index-pack -v --stdin <tmp.pack git -C replay.git index-pack -v --stdin <tmp.pack
' '
test_expect_success 'clone on case-insensitive fs' ' test_expect_success PERL_TEST_HELPERS 'clone on case-insensitive fs' '
git init icasefs && git init icasefs &&
( (
cd icasefs && cd icasefs &&
@@ -662,7 +662,7 @@ test_expect_success 'clone on case-insensitive fs' '
) )
' '
test_expect_success CASE_INSENSITIVE_FS 'colliding file detection' ' test_expect_success PERL_TEST_HELPERS,CASE_INSENSITIVE_FS 'colliding file detection' '
grep X icasefs/warning && grep X icasefs/warning &&
grep x icasefs/warning && grep x icasefs/warning &&
test_grep "the following paths have collided" icasefs/warning test_grep "the following paths have collided" icasefs/warning

View File

@@ -737,18 +737,22 @@ intersperse () {
sed 's/\(..\)/'$1'\1/g' sed 's/\(..\)/'$1'\1/g'
} }
# Create a one-time-perl command to replace the existing packfile with $1. # Create a one-time-script command to replace the existing packfile with $1.
replace_packfile () { replace_packfile () {
# The protocol requires that the packfile be sent in sideband 1, hence cp "$1" one-time-pack &&
# the extra \x01 byte at the beginning. write_script "$HTTPD_ROOT_PATH/one-time-script" <<-EOF
cp $1 "$HTTPD_ROOT_PATH/one-time-pack" && if grep packfile "\$1" >/dev/null
echo 'if (/packfile/) { then
print; sed '/packfile/q' "\$1" &&
my $length = -s "one-time-pack"; # The protocol requires that the packfile be sent in sideband
printf "%04x\x01", $length + 5; # 1, hence the extra \001 byte at the beginning.
print `cat one-time-pack` . "0000"; printf "%04x\001" \$((\$(wc -c <"$PWD/one-time-pack") + 5)) &&
last cat "$PWD/one-time-pack" &&
}' >"$HTTPD_ROOT_PATH/one-time-perl" printf "0000"
else
cat "\$1"
fi
EOF
} }
test_expect_success 'upon cloning, check that all refs point to objects' ' test_expect_success 'upon cloning, check that all refs point to objects' '
@@ -776,12 +780,12 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
# section header. # section header.
test_config -C "$SERVER" protocol.version 2 && test_config -C "$SERVER" protocol.version 2 &&
test_must_fail git -c protocol.version=2 clone \ test_must_fail git -c protocol.version=2 clone \
--filter=blob:none $HTTPD_URL/one_time_perl/server repo 2>err && --filter=blob:none $HTTPD_URL/one_time_script/server repo 2>err &&
test_grep "did not send all necessary objects" err && test_grep "did not send all necessary objects" err &&
# Ensure that the one-time-perl script was used. # Ensure that the one-time-script script was used.
! test -e "$HTTPD_ROOT_PATH/one-time-perl" ! test -e "$HTTPD_ROOT_PATH/one-time-script"
' '
test_expect_success 'when partial cloning, tolerate server not sending target of tag' ' test_expect_success 'when partial cloning, tolerate server not sending target of tag' '
@@ -818,14 +822,14 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
# Exercise to make sure it works. # Exercise to make sure it works.
git -c protocol.version=2 clone \ git -c protocol.version=2 clone \
--filter=blob:none $HTTPD_URL/one_time_perl/server repo 2> err && --filter=blob:none $HTTPD_URL/one_time_script/server repo 2> err &&
! grep "missing object referenced by" err && ! grep "missing object referenced by" err &&
# Ensure that the one-time-perl script was used. # Ensure that the one-time-script script was used.
! test -e "$HTTPD_ROOT_PATH/one-time-perl" ! test -e "$HTTPD_ROOT_PATH/one-time-script"
' '
test_expect_success 'tolerate server sending REF_DELTA against missing promisor objects' ' test_expect_success PERL_TEST_HELPERS 'tolerate server sending REF_DELTA against missing promisor objects' '
SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
rm -rf "$SERVER" repo && rm -rf "$SERVER" repo &&
test_create_repo "$SERVER" && test_create_repo "$SERVER" &&
@@ -845,7 +849,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
# Clone. The client has deltabase_have but not deltabase_missing. # Clone. The client has deltabase_have but not deltabase_missing.
git -c protocol.version=2 clone --no-checkout \ git -c protocol.version=2 clone --no-checkout \
--filter=blob:none $HTTPD_URL/one_time_perl/server repo && --filter=blob:none $HTTPD_URL/one_time_script/server repo &&
git -C repo hash-object -w -- "$SERVER/have.txt" && git -C repo hash-object -w -- "$SERVER/have.txt" &&
# Sanity check to ensure that the client does not have # Sanity check to ensure that the client does not have
@@ -899,8 +903,8 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
grep "want $(cat deltabase_missing)" trace && grep "want $(cat deltabase_missing)" trace &&
! grep "want $(cat deltabase_have)" trace && ! grep "want $(cat deltabase_have)" trace &&
# Ensure that the one-time-perl script was used. # Ensure that the one-time-script script was used.
! test -e "$HTTPD_ROOT_PATH/one-time-perl" ! test -e "$HTTPD_ROOT_PATH/one-time-script"
' '
# DO NOT add non-httpd-specific tests here, because the last part of this # DO NOT add non-httpd-specific tests here, because the last part of this

View File

@@ -228,7 +228,10 @@ test_expect_success 'ignore very large set of prefixes' '
echo command=ls-refs && echo command=ls-refs &&
echo object-format=$(test_oid algo) && echo object-format=$(test_oid algo) &&
echo 0001 && echo 0001 &&
perl -le "print \"ref-prefix refs/heads/\$_\" for (1..65536)" && awk "{
for (i = 1; i <= 65536; i++)
print \"ref-prefix refs/heads/\", \$i
}" &&
echo 0000 echo 0000
} | } |
test-tool pkt-line pack >in && test-tool pkt-line pack >in &&

View File

@@ -1174,11 +1174,12 @@ test_expect_success 'when server sends "ready", expect DELIM' '
# After "ready" in the acknowledgments section, pretend that a FLUSH # After "ready" in the acknowledgments section, pretend that a FLUSH
# (0000) was sent instead of a DELIM (0001). # (0000) was sent instead of a DELIM (0001).
printf "\$ready = 1 if /ready/; \$ready && s/0001/0000/" \ write_script "$HTTPD_ROOT_PATH/one-time-script" <<-\EOF &&
>"$HTTPD_ROOT_PATH/one-time-perl" && sed "/ready/{n;s/0001/0000/;}" "$1"
EOF
test_must_fail git -C http_child -c protocol.version=2 \ test_must_fail git -C http_child -c protocol.version=2 \
fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err && fetch "$HTTPD_URL/one_time_script/http_parent" 2> err &&
test_grep "expected packfile to be sent after .ready." err test_grep "expected packfile to be sent after .ready." err
' '
@@ -1199,12 +1200,13 @@ test_expect_success 'when server does not send "ready", expect FLUSH' '
# After the acknowledgments section, pretend that a DELIM # After the acknowledgments section, pretend that a DELIM
# (0001) was sent instead of a FLUSH (0000). # (0001) was sent instead of a FLUSH (0000).
printf "\$ack = 1 if /acknowledgments/; \$ack && s/0000/0001/" \ write_script "$HTTPD_ROOT_PATH/one-time-script" <<-\EOF &&
>"$HTTPD_ROOT_PATH/one-time-perl" && sed "/acknowledgments/,//{s/0000/0001/;}" "$1"
EOF
test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \ test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
-c protocol.version=2 \ -c protocol.version=2 \
fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err && fetch "$HTTPD_URL/one_time_script/http_parent" 2> err &&
grep "fetch< .*acknowledgments" log && grep "fetch< .*acknowledgments" log &&
! grep "fetch< .*ready" log && ! grep "fetch< .*ready" log &&
test_grep "expected no other sections to be sent after no .ready." err test_grep "expected no other sections to be sent after no .ready." err
@@ -1490,12 +1492,13 @@ test_expect_success 'http:// --negotiate-only' '
test_expect_success 'http:// --negotiate-only without wait-for-done support' ' test_expect_success 'http:// --negotiate-only without wait-for-done support' '
SERVER="server" && SERVER="server" &&
URI="$HTTPD_URL/one_time_perl/server" && URI="$HTTPD_URL/one_time_script/server" &&
setup_negotiate_only "$SERVER" "$URI" && setup_negotiate_only "$SERVER" "$URI" &&
echo "s/ wait-for-done/ xxxx-xxx-xxxx/" \ write_script "$HTTPD_ROOT_PATH/one-time-script" <<-\EOF &&
>"$HTTPD_ROOT_PATH/one-time-perl" && sed "s/ wait-for-done/ xxxx-xxx-xxxx/" "$1"
EOF
test_must_fail git -c protocol.version=2 -C client fetch \ test_must_fail git -c protocol.version=2 -C client fetch \
--no-tags \ --no-tags \

View File

@@ -83,18 +83,15 @@ test_expect_success 'setup repository' '
test_expect_success 'config controls ref-in-want advertisement' ' test_expect_success 'config controls ref-in-want advertisement' '
test-tool serve-v2 --advertise-capabilities >out && test-tool serve-v2 --advertise-capabilities >out &&
perl -ne "/ref-in-want/ and print" out >out.filter && test_grep ! "ref-in-want" out &&
test_must_be_empty out.filter &&
git config uploadpack.allowRefInWant false && git config uploadpack.allowRefInWant false &&
test-tool serve-v2 --advertise-capabilities >out && test-tool serve-v2 --advertise-capabilities >out &&
perl -ne "/ref-in-want/ and print" out >out.filter && test_grep ! "ref-in-want" out &&
test_must_be_empty out.filter &&
git config uploadpack.allowRefInWant true && git config uploadpack.allowRefInWant true &&
test-tool serve-v2 --advertise-capabilities >out && test-tool serve-v2 --advertise-capabilities >out &&
perl -ne "/ref-in-want/ and print" out >out.filter && test_grep "ref-in-want" out
test_file_not_empty out.filter
' '
test_expect_success 'invalid want-ref line' ' test_expect_success 'invalid want-ref line' '
@@ -462,7 +459,7 @@ test_expect_success 'setup repos for change-while-negotiating test' '
test_commit m3 && test_commit m3 &&
git tag -d m2 m3 git tag -d m2 m3
) && ) &&
git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_perl/repo" && git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_script/repo" &&
git -C "$LOCAL_PRISTINE" config protocol.version 2 git -C "$LOCAL_PRISTINE" config protocol.version 2
' '
@@ -475,10 +472,12 @@ inconsistency () {
# RPCs during a single negotiation. # RPCs during a single negotiation.
oid1=$(git -C "$REPO" rev-parse $1) && oid1=$(git -C "$REPO" rev-parse $1) &&
oid2=$(git -C "$REPO" rev-parse $2) && oid2=$(git -C "$REPO" rev-parse $2) &&
echo "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-perl" write_script "$HTTPD_ROOT_PATH/one-time-script" <<-EOF
sed "s/$oid1/$oid2/" "\$1"
EOF
} }
test_expect_success 'server is initially ahead - no ref in want' ' test_expect_success PERL_TEST_HELPERS 'server is initially ahead - no ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant false && git -C "$REPO" config uploadpack.allowRefInWant false &&
rm -rf local && rm -rf local &&
cp -r "$LOCAL_PRISTINE" local && cp -r "$LOCAL_PRISTINE" local &&
@@ -487,7 +486,7 @@ test_expect_success 'server is initially ahead - no ref in want' '
test_grep "fatal: remote error: upload-pack: not our ref" err test_grep "fatal: remote error: upload-pack: not our ref" err
' '
test_expect_success 'server is initially ahead - ref in want' ' test_expect_success PERL_TEST_HELPERS 'server is initially ahead - ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant true && git -C "$REPO" config uploadpack.allowRefInWant true &&
rm -rf local && rm -rf local &&
cp -r "$LOCAL_PRISTINE" local && cp -r "$LOCAL_PRISTINE" local &&
@@ -499,7 +498,7 @@ test_expect_success 'server is initially ahead - ref in want' '
test_cmp expected actual test_cmp expected actual
' '
test_expect_success 'server is initially behind - no ref in want' ' test_expect_success PERL_TEST_HELPERS 'server is initially behind - no ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant false && git -C "$REPO" config uploadpack.allowRefInWant false &&
rm -rf local && rm -rf local &&
cp -r "$LOCAL_PRISTINE" local && cp -r "$LOCAL_PRISTINE" local &&
@@ -511,7 +510,7 @@ test_expect_success 'server is initially behind - no ref in want' '
test_cmp expected actual test_cmp expected actual
' '
test_expect_success 'server is initially behind - ref in want' ' test_expect_success PERL_TEST_HELPERS 'server is initially behind - ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant true && git -C "$REPO" config uploadpack.allowRefInWant true &&
rm -rf local && rm -rf local &&
cp -r "$LOCAL_PRISTINE" local && cp -r "$LOCAL_PRISTINE" local &&
@@ -523,11 +522,13 @@ test_expect_success 'server is initially behind - ref in want' '
test_cmp expected actual test_cmp expected actual
' '
test_expect_success 'server loses a ref - ref in want' ' test_expect_success PERL_TEST_HELPERS 'server loses a ref - ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant true && git -C "$REPO" config uploadpack.allowRefInWant true &&
rm -rf local && rm -rf local &&
cp -r "$LOCAL_PRISTINE" local && cp -r "$LOCAL_PRISTINE" local &&
echo "s/main/rain/" >"$HTTPD_ROOT_PATH/one-time-perl" && write_script "$HTTPD_ROOT_PATH/one-time-script" <<-\EOF &&
sed "s/main/rain/" "$1"
EOF
test_must_fail git -C local fetch 2>err && test_must_fail git -C local fetch 2>err &&
test_grep "fatal: remote error: unknown ref refs/heads/rain" err test_grep "fatal: remote error: unknown ref refs/heads/rain" err

View File

@@ -4,6 +4,12 @@ test_description='handling of promisor remote advertisement'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping promisor remote capabilities tests; Perl not available'
test_done
fi
GIT_TEST_MULTI_PACK_INDEX=0 GIT_TEST_MULTI_PACK_INDEX=0
GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=0 GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=0

View File

@@ -35,11 +35,15 @@ test_expect_success 'verify number of revisions' \
first_commit=$(git rev-parse HEAD~3) first_commit=$(git rev-parse HEAD~3)
' '
test_expect_success 'corrupt second commit object' \ test_expect_success 'corrupt second commit object' '
' for p in .git/objects/pack/*.pack
perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack && do
test_must_fail git fsck --full sed "s/second commit/socond commit/" "$p" >"$p.munged" &&
' mv "$p.munged" "$p" ||
return 1
done &&
test_must_fail git fsck --full
'
test_expect_success 'rev-list should fail' ' test_expect_success 'rev-list should fail' '
test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null test_must_fail env GIT_TEST_COMMIT_GRAPH=0 git -c core.commitGraph=false rev-list --all > /dev/null

View File

@@ -26,17 +26,19 @@ test_expect_success 'set up --reverse example' '
commit five commit five
' '
reverse () {
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'
}
test_expect_success '--reverse --parents --full-history combines correctly' ' test_expect_success '--reverse --parents --full-history combines correctly' '
git rev-list --parents --full-history main -- foo | git rev-list --parents --full-history main -- foo | reverse >expected &&
perl -e "print reverse <>" > expected &&
git rev-list --reverse --parents --full-history main -- foo \ git rev-list --reverse --parents --full-history main -- foo \
> actual && > actual &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success '--boundary does too' ' test_expect_success '--boundary does too' '
git rev-list --boundary --parents --full-history main ^root -- foo | git rev-list --boundary --parents --full-history main ^root -- foo | reverse >expected &&
perl -e "print reverse <>" > expected &&
git rev-list --boundary --reverse --parents --full-history \ git rev-list --boundary --reverse --parents --full-history \
main ^root -- foo > actual && main ^root -- foo > actual &&
test_cmp expected actual test_cmp expected actual

View File

@@ -4,6 +4,12 @@ test_description='git rev-list should handle unexpected object types'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping rev-list unexpected objects tests; Perl not available'
test_done
fi
test_expect_success 'setup well-formed objects' ' test_expect_success 'setup well-formed objects' '
blob="$(printf "foo" | git hash-object -w --stdin)" && blob="$(printf "foo" | git hash-object -w --stdin)" &&
tree="$(printf "100644 blob $blob\tfoo" | git mktree)" && tree="$(printf "100644 blob $blob\tfoo" | git mktree)" &&

View File

@@ -22,7 +22,7 @@ test_expect_success 'set up repository' '
disk_usage_slow () { disk_usage_slow () {
git rev-list --no-object-names "$@" | git rev-list --no-object-names "$@" |
git cat-file --batch-check="%(objectsize:disk)" | git cat-file --batch-check="%(objectsize:disk)" |
perl -lne '$total += $_; END { print $total}' awk '{ i += $1 } END { print i }'
} }
# check behavior with given rev-list options; note that # check behavior with given rev-list options; note that

View File

@@ -1216,7 +1216,7 @@ test_expect_success '%(raw) with --tcl must fail' '
test_must_fail git for-each-ref --format="%(raw)" --tcl test_must_fail git for-each-ref --format="%(raw)" --tcl
' '
test_expect_success '%(raw) with --perl' ' test_expect_success PERL_TEST_HELPERS '%(raw) with --perl' '
git for-each-ref --format="\$name= %(raw); git for-each-ref --format="\$name= %(raw);
print \"\$name\"" refs/myblobs/blob1 --perl | perl >actual && print \"\$name\"" refs/myblobs/blob1 --perl | perl >actual &&
cmp blob1 actual && cmp blob1 actual &&
@@ -1443,9 +1443,14 @@ test_expect_success 'set up trailers for next test' '
' '
test_trailer_option () { test_trailer_option () {
if test "$#" -eq 3
then
prereq="$1"
shift
fi &&
title=$1 option=$2 title=$1 option=$2
cat >expect cat >expect
test_expect_success "$title" ' test_expect_success $prereq "$title" '
git for-each-ref --format="%($option)" refs/heads/main >actual && git for-each-ref --format="%($option)" refs/heads/main >actual &&
test_cmp expect actual && test_cmp expect actual &&
git for-each-ref --format="%(contents:$option)" refs/heads/main >actual && git for-each-ref --format="%(contents:$option)" refs/heads/main >actual &&
@@ -1453,7 +1458,7 @@ test_trailer_option () {
' '
} }
test_trailer_option '%(trailers:unfold) unfolds trailers' \ test_trailer_option PERL_TEST_HELPERS '%(trailers:unfold) unfolds trailers' \
'trailers:unfold' <<-EOF 'trailers:unfold' <<-EOF
$(unfold <trailers) $(unfold <trailers)
@@ -1483,13 +1488,13 @@ test_trailer_option '%(trailers:only=no) shows all trailers' \
EOF EOF
test_trailer_option '%(trailers:only) and %(trailers:unfold) work together' \ test_trailer_option PERL_TEST_HELPERS '%(trailers:only) and %(trailers:unfold) work together' \
'trailers:only,unfold' <<-EOF 'trailers:only,unfold' <<-EOF
$(grep -v patch.description <trailers | unfold) $(grep -v patch.description <trailers | unfold)
EOF EOF
test_trailer_option '%(trailers:unfold) and %(trailers:only) work together' \ test_trailer_option PERL_TEST_HELPERS '%(trailers:unfold) and %(trailers:only) work together' \
'trailers:unfold,only' <<-EOF 'trailers:unfold,only' <<-EOF
$(grep -v patch.description <trailers | unfold) $(grep -v patch.description <trailers | unfold)

View File

@@ -662,9 +662,9 @@ test_expect_success 'setup trace2' '
' '
test_expect_success 'setup large log output' ' test_expect_success 'setup large log output' '
perl -e " test-tool genzeros 50000 |
print \"this is a long commit message\" x 50000 tr "\000" "a" |
" >commit-msg && sed "s/a/this is a long commit message/g" >commit-msg &&
git commit --allow-empty -F commit-msg git commit --allow-empty -F commit-msg
' '

View File

@@ -33,7 +33,8 @@ test_expect_success 'fsck accepts protected dash' '
' '
test_expect_success 'remove ./ protection from .gitmodules url' ' test_expect_success 'remove ./ protection from .gitmodules url' '
perl -i -pe "s{\./}{}" .gitmodules && sed "s|\./||" .gitmodules >.gitmodules.munged &&
mv .gitmodules.munged .gitmodules &&
git commit -am "drop protection" git commit -am "drop protection"
' '

View File

@@ -46,7 +46,7 @@ test_expect_success 'paths and -a do not mix' '
test_must_fail git commit -m foo -a file test_must_fail git commit -m foo -a file
' '
test_expect_success PERL 'can use paths with --interactive' ' test_expect_success 'can use paths with --interactive' '
echo bong-o-bong >file && echo bong-o-bong >file &&
# 2: update, 1:st path, that is all, 7: quit # 2: update, 1:st path, that is all, 7: quit
test_write_lines 2 1 "" 7 | test_write_lines 2 1 "" 7 |
@@ -345,12 +345,12 @@ test_expect_success 'overriding author from command line' '
grep Rubber.Duck output grep Rubber.Duck output
' '
test_expect_success PERL 'interactive add' ' test_expect_success 'interactive add' '
echo 7 | test_must_fail git commit --interactive >out && echo 7 | test_must_fail git commit --interactive >out &&
grep "What now" out grep "What now" out
' '
test_expect_success PERL "commit --interactive doesn't change index if editor aborts" ' test_expect_success "commit --interactive doesn't change index if editor aborts" '
echo zoo >file && echo zoo >file &&
test_must_fail git diff --exit-code >diff1 && test_must_fail git diff --exit-code >diff1 &&
test_write_lines u "*" q | test_write_lines u "*" q |

View File

@@ -1066,7 +1066,7 @@ test_expect_success 'status -s submodule summary (clean submodule)' '
test_expect_success 'status -z implies porcelain' ' test_expect_success 'status -z implies porcelain' '
git status --porcelain | git status --porcelain |
perl -pe "s/\012/\000/g" >expect && tr "\012" "\000" >expect &&
git status -z >output && git status -z >output &&
test_cmp expect output test_cmp expect output
' '

View File

@@ -114,13 +114,10 @@ test_expect_success 'grep respects not-binary diff attribute' '
test_cmp expect actual test_cmp expect actual
' '
cat >nul_to_q_textconv <<'EOF'
#!/bin/sh
"$PERL_PATH" -pe 'y/\000/Q/' < "$1"
EOF
chmod +x nul_to_q_textconv
test_expect_success 'setup textconv filters' ' test_expect_success 'setup textconv filters' '
write_script nul_to_q_textconv <<-\EOF &&
tr "\000" "Q" <"$1"
EOF
echo a diff=foo >.gitattributes && echo a diff=foo >.gitattributes &&
git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv
' '

View File

@@ -7,6 +7,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_CREATE_REPO_NO_TEMPLATE=1 TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping annotate tests; Perl not available'
test_done
fi
PROG='git annotate' PROG='git annotate'
. "$TEST_DIRECTORY"/annotate-tests.sh . "$TEST_DIRECTORY"/annotate-tests.sh

View File

@@ -7,6 +7,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_CREATE_REPO_NO_TEMPLATE=1 TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping blame colors tests; Perl not available'
test_done
fi
PROG='git blame -c' PROG='git blame -c'
. "$TEST_DIRECTORY"/annotate-tests.sh . "$TEST_DIRECTORY"/annotate-tests.sh
@@ -101,7 +107,7 @@ test_expect_success 'set up abbrev tests' '
expect=$1 && shift && expect=$1 && shift &&
echo $sha1 | cut -c 1-$expect >expect && echo $sha1 | cut -c 1-$expect >expect &&
git blame "$@" abbrev.t >actual && git blame "$@" abbrev.t >actual &&
perl -lne "/[0-9a-f]+/ and print \$&" <actual >actual.sha && sed -n "s/^[\^]\{0,1\}\([0-9a-f][0-9a-f]*\).*/\1/p" actual >actual.sha &&
test_cmp expect actual.sha test_cmp expect actual.sha
} }
' '

View File

@@ -11,7 +11,7 @@ find_blame() {
cat >helper <<'EOF' cat >helper <<'EOF'
#!/bin/sh #!/bin/sh
grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; } grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
"$PERL_PATH" -p -e 's/^bin: /converted: /' "$1" sed 's/^bin: /converted: /' "$1"
EOF EOF
chmod +x helper chmod +x helper

View File

@@ -81,7 +81,7 @@ do
git blame --root -C --$output combined >output git blame --root -C --$output combined >output
' '
test_expect_success "$output output finds correct commits" ' test_expect_success PERL_TEST_HELPERS "$output output finds correct commits" '
generate_expect >expect <<-\EOF && generate_expect >expect <<-\EOF &&
5 base 5 base
1 modified 1 modified
@@ -93,7 +93,7 @@ do
test_cmp expect actual test_cmp expect actual
' '
test_expect_success "$output output shows correct filenames" ' test_expect_success PERL_TEST_HELPERS "$output output shows correct filenames" '
generate_expect >expect <<-\EOF && generate_expect >expect <<-\EOF &&
11 one 11 one
11 two 11 two
@@ -102,7 +102,7 @@ do
test_cmp expect actual test_cmp expect actual
' '
test_expect_success "$output output shows correct previous pointer" ' test_expect_success PERL_TEST_HELPERS "$output output shows correct previous pointer" '
generate_expect >expect <<-EOF && generate_expect >expect <<-EOF &&
5 NONE 5 NONE
1 $(git rev-parse modified^) one 1 $(git rev-parse modified^) one

View File

@@ -7,6 +7,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_CREATE_REPO_NO_TEMPLATE=1 TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq PERL_TEST_HELPERS
then
skip_all='skipping blame colors tests; Perl not available'
test_done
fi
PROG='git blame -c' PROG='git blame -c'
. "$TEST_DIRECTORY"/annotate-tests.sh . "$TEST_DIRECTORY"/annotate-tests.sh

View File

@@ -20,8 +20,8 @@ test_expect_success '(supposedly) non-conflicting change from SVN' '
test x"$(sed -n -e 61p < file)" = x61 && test x"$(sed -n -e 61p < file)" = x61 &&
svn_cmd co "$svnrepo" tmp && svn_cmd co "$svnrepo" tmp &&
(cd tmp && (cd tmp &&
perl -i.bak -p -e "s/^58$/5588/" file && sed -e "s/^58$/5588/" -e "s/^61$/6611/" file >file.munged &&
perl -i.bak -p -e "s/^61$/6611/" file && mv file.munged file &&
poke file && poke file &&
test x"$(sed -n -e 58p < file)" = x5588 && test x"$(sed -n -e 58p < file)" = x5588 &&
test x"$(sed -n -e 61p < file)" = x6611 && test x"$(sed -n -e 61p < file)" = x6611 &&
@@ -40,8 +40,10 @@ test_expect_success 'some unrelated changes to git' "
test_expect_success 'change file but in unrelated area' " test_expect_success 'change file but in unrelated area' "
test x\"\$(sed -n -e 4p < file)\" = x4 && test x\"\$(sed -n -e 4p < file)\" = x4 &&
test x\"\$(sed -n -e 7p < file)\" = x7 && test x\"\$(sed -n -e 7p < file)\" = x7 &&
perl -i.bak -p -e 's/^4\$/4444/' file && sed -e 's/^4\$/4444/' \
perl -i.bak -p -e 's/^7\$/7777/' file && -e 's/^7\$/7777/' \
file >file.munged &&
mv file.munged file &&
test x\"\$(sed -n -e 4p < file)\" = x4444 && test x\"\$(sed -n -e 4p < file)\" = x4444 &&
test x\"\$(sed -n -e 7p < file)\" = x7777 && test x\"\$(sed -n -e 7p < file)\" = x7777 &&
git commit -m '4 => 4444, 7 => 7777' file && git commit -m '4 => 4444, 7 => 7777' file &&

View File

@@ -726,7 +726,7 @@ test_expect_success 'directory becomes symlink' '
(cd result && git show main:foo) (cd result && git show main:foo)
' '
test_expect_success 'fast-export quotes pathnames' ' test_expect_success PERL_TEST_HELPERS 'fast-export quotes pathnames' '
git init crazy-paths && git init crazy-paths &&
test_config -C crazy-paths core.protectNTFS false && test_config -C crazy-paths core.protectNTFS false &&
(cd crazy-paths && (cd crazy-paths &&

View File

@@ -30,7 +30,7 @@ test_expect_success 'shell allows interactive command' '
' '
test_expect_success 'shell complains of overlong commands' ' test_expect_success 'shell complains of overlong commands' '
perl -e "print \"a\" x 2**12 for (0..2**19)" | test-tool genzeros | tr "\000" "a" |
test_must_fail git shell 2>err && test_must_fail git shell 2>err &&
grep "too long" err grep "too long" err
' '

View File

@@ -88,15 +88,15 @@ test_decode_color () {
} }
lf_to_nul () { lf_to_nul () {
perl -pe 'y/\012/\000/' tr '\012' '\000'
} }
nul_to_q () { nul_to_q () {
perl -pe 'y/\000/Q/' tr '\000' 'Q'
} }
q_to_nul () { q_to_nul () {
perl -pe 'y/Q/\000/' tr 'Q' '\000'
} }
q_to_cr () { q_to_cr () {
@@ -1645,17 +1645,7 @@ test_match_signal () {
# Read up to "$1" bytes (or to EOF) from stdin and write them to stdout. # Read up to "$1" bytes (or to EOF) from stdin and write them to stdout.
test_copy_bytes () { test_copy_bytes () {
perl -e ' dd ibs=1 count="$1" 2>/dev/null
my $len = $ARGV[1];
while ($len > 0) {
my $s;
my $nread = sysread(STDIN, $s, $len);
die "cannot read: $!" unless defined($nread);
last unless $nread;
print $s;
$len -= $nread;
}
' - "$1"
} }
# run "$@" inside a non-git directory # run "$@" inside a non-git directory
@@ -1994,7 +1984,7 @@ test_remote_https_urls() {
# Print the destination of symlink(s) provided as arguments. Basically # Print the destination of symlink(s) provided as arguments. Basically
# the same as the readlink command, but it's not available everywhere. # the same as the readlink command, but it's not available everywhere.
test_readlink () { test_readlink () {
perl -le 'print readlink($_) for @ARGV' "$@" test-tool path-utils readlink "$@"
} }
# Set mtime to a fixed "magic" timestamp in mid February 2009, before we # Set mtime to a fixed "magic" timestamp in mid February 2009, before we

View File

@@ -499,24 +499,20 @@ EDITOR=:
# /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets
# deriving from the command substitution clustered with the other # deriving from the command substitution clustered with the other
# ones. # ones.
unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e ' unset VISUAL EMAIL LANGUAGE $(env | sed -n \
my @env = keys %ENV; -e '/^GIT_TRACE/d' \
my $ok = join("|", qw( -e '/^GIT_DEBUG/d' \
TRACE -e '/^GIT_TEST/d' \
DEBUG -e '/^GIT_.*_TEST/d' \
TEST -e '/^GIT_PROVE/d' \
.*_TEST -e '/^GIT_VALGRIND/d' \
PROVE -e '/^GIT_UNZIP/d' \
VALGRIND -e '/^GIT_PERF_/d' \
UNZIP -e '/^GIT_CURL_VERBOSE/d' \
PERF_ -e '/^GIT_TRACE_CURL/d' \
CURL_VERBOSE -e '/^GIT_BUILD_DIR/d' \
TRACE_CURL -e 's/^\(GIT_[^=]*\)=.*/\1/p'
BUILD_DIR )
));
my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
print join("\n", @vars);
')
unset XDG_CACHE_HOME unset XDG_CACHE_HOME
unset XDG_CONFIG_HOME unset XDG_CONFIG_HOME
unset GITPERLLIB unset GITPERLLIB
@@ -1523,6 +1519,22 @@ then
export LSAN_OPTIONS export LSAN_OPTIONS
fi fi
if test -z "$PERL_PATH"
then
case "${GIT_TEST_CHAIN_LINT:-unset}" in
unset)
GIT_TEST_CHAIN_LINT=0
;;
0)
# The user has explicitly disabled the chain linter, so we
# don't have anything to worry about.
;;
*)
BAIL_OUT 'You need Perl for the chain linter'
;;
esac
fi
if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 && if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&
test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0 test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0
then then
@@ -1694,6 +1706,7 @@ test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
test -z "$NO_GETTEXT" && test_set_prereq GETTEXT test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND
test -n "$PERL_PATH" && test_set_prereq PERL_TEST_HELPERS
if test -z "$GIT_TEST_CHECK_CACHE_TREE" if test -z "$GIT_TEST_CHECK_CACHE_TREE"
then then