Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4031-diff-rewrite-binary.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4031-diff-rewrite-binary.sh` 75 lines ยท 1741 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='rewrite diff on binary file' 4 5 . ./test-lib.sh 6 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 13 do 14 for j in 1 2 3 4 5 6 7 8 9 15 do 16 for k in 1 2 3 4 5 17 do 18 printf "$1\n" 19 done 20 done 21 done >>file 22 } 23 24 test_expect_success 'create binary file with changes' ' 25 make_file "\\0" && 26 git add file && 27 make_file "\\01" 28 ' 29 30 test_expect_success 'vanilla diff is binary' ' 31 git diff >diff && 32 test_grep "Binary files a/file and b/file differ" diff 33 ' 34 35 test_expect_success 'rewrite diff is binary' ' 36 git diff -B >diff && 37 test_grep "dissimilarity index" diff && 38 test_grep "Binary files a/file and b/file differ" diff 39 ' 40 41 test_expect_success 'rewrite diff can show binary patch' ' 42 git diff -B --binary >diff && 43 test_grep "dissimilarity index" diff && 44 test_grep "GIT binary patch" diff 45 ' 46 47 test_expect_success 'rewrite diff --numstat shows binary changes' ' 48 git diff -B --numstat --summary >diff && 49 test_grep -e "- - " diff && 50 test_grep " rewrite file" diff 51 ' 52 53 test_expect_success 'diff --stat counts binary rewrite as 0 lines' ' 54 git diff -B --stat --summary >diff && 55 test_grep "Bin" diff && 56 test_grep "0 insertions.*0 deletions" diff && 57 test_grep " rewrite file" diff 58 ' 59 60 test_expect_success 'setup textconv' ' 61 write_script dump <<-\EOF && 62 test-tool hexdump <"$1" 63 EOF 64 echo file diff=foo >.gitattributes && 65 git config diff.foo.textconv "\"$(pwd)\""/dump 66 ' 67 68 test_expect_success 'rewrite diff respects textconv' ' 69 git diff -B >diff && 70 test_grep "dissimilarity index" diff && 71 test_grep "^-3d 0a 00" diff && 72 test_grep "^+3d 0a 01" diff 73 ' 74 75 test_done