Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-12-09 11:13:21 +0300
committerJunio C Hamano <gitster@pobox.com>2008-12-10 09:28:55 +0300
commit3aa1f7ca3779f73164b285c070b71abcdd7397c1 (patch)
tree5c56fd2f96e46ea62202bc063d8d21d36eb618a0 /t/t4031-diff-rewrite-binary.sh
parent0c01857df57fe8723714e49459e0c061fcaf056b (diff)
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/t4031-diff-rewrite-binary.sh')
-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 e16c355103..157ed85a79 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