git-commit-vandalism/t/t4031-diff-rewrite-binary.sh
Johannes Sixt 6396258368 t4030, t4031: work around bogus MSYS bash path conversion
Recall that MSYS bash converts POSIX style absolute paths to Windows style
absolute paths. Unfortunately, it converts a program argument that begins
with a double-quote and otherwise looks like an absolute POSIX path, but
in doing so, it strips everything past the second double-quote[*]. This
case is triggered in the two test scripts. The work-around is to place the
Windows style path returned by $(pwd) between the quotes to avoid the path
conversion.

[*] It is already bogus that a conversion is even considered when a program
argument begins with a double-quote because it cannot be an absolute POSIX
path.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-05 23:41:51 -08:00

68 lines
1.3 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
'
{
echo "#!$SHELL_PATH"
cat <<'EOF'
perl -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 'rewrite diff respects textconv' '
git diff -B >diff &&
grep "dissimilarity index" diff &&
grep "^-61" diff &&
grep "^-0" diff
'
test_done