3 test_description
='rewrite diff'
5 TEST_PASSES_SANITIZE_LEAK
=true
7 .
"$TEST_DIRECTORY"/lib-diff-data.sh
9 test_expect_success setup
'
11 COPYING_test_data >test.data &&
15 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
16 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
18 echo "to be deleted" >test2 &&
19 blob=$(git hash-object test2) &&
20 blob=$(git rev-parse --short $blob) &&
25 test_expect_success
'detect rewrite' '
27 actual=$(git diff-files -B --summary test) &&
28 expr "$actual" : " rewrite test ([0-9]*%)$"
33 diff --git a/test2 b/test2
34 deleted file mode 100644
41 test_expect_success
'show deletion diff without -D' '
44 git diff -- test2 >actual &&
45 test_cmp expect actual
49 diff --git a/test2 b/test2
50 deleted file mode 100644
53 test_expect_success
'suppress deletion diff with -D' '
55 git diff -D -- test2 >actual &&
56 test_cmp expect actual
59 test_expect_success
'show deletion diff with -B' '
61 git diff -B -- test >actual &&
62 grep "Linus Torvalds" actual
65 test_expect_success
'suppress deletion diff with -B -D' '
67 git diff -B -D -- test >actual &&
68 grep -v "Linus Torvalds" actual
71 test_expect_success
'prepare a file that ends with an incomplete line' '
78 test_expect_success
'rewrite the middle 90% of sequence file and terminate with newline' '
80 test_seq 9331 9420 >>seq &&
84 test_expect_success
'confirm that sequence file is considered a rewrite' '
85 git diff -B seq >res &&
86 grep "dissimilarity index" res
89 test_expect_success
'no newline at eof is on its own line without -B' '
92 ! grep "^..*\\\\ " res
95 test_expect_success
'no newline at eof is on its own line with -B' '
96 git diff -B seq >res &&
98 ! grep "^..*\\\\ " res