git-svn: Add a svn-remote.<name>.pushurl config key
[git.git] / t / t4031-diff-rewrite-binary.sh
blob7d7470f21b66a937e7414f4fe5419f8830fd8e86
1 #!/bin/sh
3 test_description='rewrite diff on binary file'
5 . ./test-lib.sh
7 # We must be large enough to meet the MINIMUM_BREAK_SIZE
8 # requirement.
9 make_file() {
10 # common first line to help identify rewrite versus regular diff
11 printf "=\n" >file
12 for i in 1 2 3 4 5 6 7 8 9 10
14 for j in 1 2 3 4 5 6 7 8 9
16 for k in 1 2 3 4 5
18 printf "$1\n"
19 done
20 done
21 done >>file
24 test_expect_success 'create binary file with changes' '
25 make_file "\\0" &&
26 git add file &&
27 make_file "\\01"
30 test_expect_success 'vanilla diff is binary' '
31 git diff >diff &&
32 grep "Binary files a/file and b/file differ" diff
35 test_expect_success 'rewrite diff is binary' '
36 git diff -B >diff &&
37 grep "dissimilarity index" diff &&
38 grep "Binary files a/file and b/file differ" diff
41 test_expect_success 'rewrite diff can show binary patch' '
42 git diff -B --binary >diff &&
43 grep "dissimilarity index" diff &&
44 grep "GIT binary patch" diff
47 test_expect_success 'rewrite diff --stat shows binary changes' '
48 git diff -B --stat --summary >diff &&
49 grep "Bin" diff &&
50 grep "0 insertions.*0 deletions" diff &&
51 grep " rewrite file" diff
55 echo "#!$SHELL_PATH"
56 cat <<'EOF'
57 perl -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1"
58 EOF
59 } >dump
60 chmod +x dump
62 test_expect_success 'setup textconv' '
63 echo file diff=foo >.gitattributes &&
64 git config diff.foo.textconv "\"$(pwd)\""/dump
67 test_expect_success 'rewrite diff respects textconv' '
68 git diff -B >diff &&
69 grep "dissimilarity index" diff &&
70 grep "^-61" diff &&
71 grep "^-0" diff
74 test_done