diff: respect textconv in rewrite diffs
Currently we just skip rewrite diffs for binary files; this patch makes an exception for files which will be textconv'd, and actually performs the textconv before generating the diff. Conceptually, rewrite diffs should be in the exact same format as the a non-rewrite diff, except that we refuse to share any context. Thus it makes very little sense for "git diff" to show a textconv'd diff, but for "git diff -B" to show "Binary files differ". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
0c01857df5
commit
3aa1f7ca37
@@ -7,6 +7,8 @@ test_description='rewrite diff on binary file'
|
||||
# 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
|
||||
@@ -16,7 +18,7 @@ make_file() {
|
||||
printf "$1\n"
|
||||
done
|
||||
done
|
||||
done >file
|
||||
done >>file
|
||||
}
|
||||
|
||||
test_expect_success 'create binary file with changes' '
|
||||
@@ -42,4 +44,24 @@ test_expect_success 'rewrite diff can show binary patch' '
|
||||
grep "GIT binary patch" diff
|
||||
'
|
||||
|
||||
{
|
||||
echo "#!$SHELL_PATH"
|
||||
cat >dump <<'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
|
||||
|
||||
Reference in New Issue
Block a user