In the early days of Git, Perl was used quite prominently throughout the
project. This has changed significantly as almost all of the executables
we ship nowadays have eventually been rewritten in C. Only a handful of
subsystems remain that require Perl:
- gitweb, a read-only web interface.
- A couple of scripts that allow importing repositories from GNU Arch,
CVS and Subversion.
- git-send-email(1), which can be used to send mails.
- git-request-pull(1), which is used to request somebody to pull from
a URL by sending an email.
- git-filter-branch(1), which uses Perl with the `--state-branch`
option. This command is typically recommended against nowadays in
favor of git-filter-repo(1).
- Our Perl bindings for Git.
- The netrc Git credential helper.
None of these subsystems can really be considered to be part of the
"core" of Git, and an installation without them is fully functional.
It is more likely than not that an end user wouldn't even notice that
any features are missing if those tools weren't installed. But while
Perl nowadays very much is an optional dependency of Git, there is a
significant limitation when Perl isn't available: developers cannot run
our test suite.
Preceding commits have started to lift this restriction by removing the
strict dependency on Perl in many central parts of the test library. But
there are still many tests that rely on small Perl helpers to do various
different things.
Introduce a new PERL_TEST_HELPERS prerequisite that guards all tests
that require Perl. This prerequisite is explicitly different than the
preexisting PERL prerequisite:
- PERL records whether or not features depending on the Perl
interpreter are built.
- PERL_TEST_HELPERS records whether or not a Perl interpreter is
available for our tests.
By having these two separate prerequisites we can thus distinguish
between tests that inherently depend on Perl because the underlying
feature does, and those tests that depend on Perl because the test
itself is using Perl.
Adapt all tests to set the PERL_TEST_HELPERS prerequisite as needed.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
81 lines
1.7 KiB
Bash
Executable File
81 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='rewrite diff on binary file'
|
|
|
|
. ./test-lib.sh
|
|
|
|
# We must be large enough to meet the MINIMUM_BREAK_SIZE
|
|
# requirement.
|
|
make_file() {
|
|
# common first line to help identify rewrite versus regular diff
|
|
printf "=\n" >file
|
|
for i in 1 2 3 4 5 6 7 8 9 10
|
|
do
|
|
for j in 1 2 3 4 5 6 7 8 9
|
|
do
|
|
for k in 1 2 3 4 5
|
|
do
|
|
printf "$1\n"
|
|
done
|
|
done
|
|
done >>file
|
|
}
|
|
|
|
test_expect_success 'create binary file with changes' '
|
|
make_file "\\0" &&
|
|
git add file &&
|
|
make_file "\\01"
|
|
'
|
|
|
|
test_expect_success 'vanilla diff is binary' '
|
|
git diff >diff &&
|
|
grep "Binary files a/file and b/file differ" diff
|
|
'
|
|
|
|
test_expect_success 'rewrite diff is binary' '
|
|
git diff -B >diff &&
|
|
grep "dissimilarity index" diff &&
|
|
grep "Binary files a/file and b/file differ" diff
|
|
'
|
|
|
|
test_expect_success 'rewrite diff can show binary patch' '
|
|
git diff -B --binary >diff &&
|
|
grep "dissimilarity index" diff &&
|
|
grep "GIT binary patch" diff
|
|
'
|
|
|
|
test_expect_success 'rewrite diff --numstat shows binary changes' '
|
|
git diff -B --numstat --summary >diff &&
|
|
grep -e "- - " diff &&
|
|
grep " rewrite file" diff
|
|
'
|
|
|
|
test_expect_success 'diff --stat counts binary rewrite as 0 lines' '
|
|
git diff -B --stat --summary >diff &&
|
|
grep "Bin" diff &&
|
|
test_grep "0 insertions.*0 deletions" 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' '
|
|
echo file diff=foo >.gitattributes &&
|
|
git config diff.foo.textconv "\"$(pwd)\""/dump
|
|
'
|
|
|
|
test_expect_success PERL_TEST_HELPERS 'rewrite diff respects textconv' '
|
|
git diff -B >diff &&
|
|
grep "dissimilarity index" diff &&
|
|
grep "^-61" diff &&
|
|
grep "^-0" diff
|
|
'
|
|
|
|
test_done
|