3 test_description
='rewrite diff'
6 .
"$TEST_DIRECTORY"/lib-diff-data.sh
8 test_expect_success setup
'
10 COPYING_test_data >test.data &&
14 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
15 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
17 echo "to be deleted" >test2 &&
18 blob=$(git hash-object test2) &&
19 blob=$(git rev-parse --short $blob) &&
24 test_expect_success
'detect rewrite' '
26 actual=$(git diff-files -B --summary test) &&
27 expr "$actual" : " rewrite test ([0-9]*%)$"
32 diff --git a/test2 b/test2
33 deleted file mode 100644
40 test_expect_success
'show deletion diff without -D' '
43 git diff -- test2 >actual &&
44 test_cmp expect actual
48 diff --git a/test2 b/test2
49 deleted file mode 100644
52 test_expect_success
'suppress deletion diff with -D' '
54 git diff -D -- test2 >actual &&
55 test_cmp expect actual
58 test_expect_success
'show deletion diff with -B' '
60 git diff -B -- test >actual &&
61 grep "Linus Torvalds" actual
64 test_expect_success
'suppress deletion diff with -B -D' '
66 git diff -B -D -- test >actual &&
67 grep -v "Linus Torvalds" actual
70 test_expect_success
'prepare a file that ends with an incomplete line' '
77 test_expect_success
'rewrite the middle 90% of sequence file and terminate with newline' '
79 test_seq 9331 9420 >>seq &&
83 test_expect_success
'confirm that sequence file is considered a rewrite' '
84 git diff -B seq >res &&
85 grep "dissimilarity index" res
88 test_expect_success
'no newline at eof is on its own line without -B' '
91 ! grep "^..*\\\\ " res
94 test_expect_success
'no newline at eof is on its own line with -B' '
95 git diff -B seq >res &&
97 ! grep "^..*\\\\ " res