aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-12-09 03:13:21 -0500
committerJunio C Hamano <gitster@pobox.com>2008-12-09 22:28:55 -0800
commit3aa1f7ca3779f73164b285c070b71abcdd7397c1 (patch)
tree5c56fd2f96e46ea62202bc063d8d21d36eb618a0 /t
parent0c01857df57fe8723714e49459e0c061fcaf056b (diff)
downloadgit-3aa1f7ca3779f73164b285c070b71abcdd7397c1.tar.gz
git-3aa1f7ca3779f73164b285c070b71abcdd7397c1.tar.xz
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t4031-diff-rewrite-binary.sh24
1 files changed, 23 insertions, 1 deletions
diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh
index e16c35510..157ed85a7 100755
--- a/t/t4031-diff-rewrite-binary.sh
+++ b/t/t4031-diff-rewrite-binary.sh
@@ -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