3 test_description='rewrite diff'
7 test_expect_success setup '
9 cat "$TEST_DIRECTORY"/../COPYING >test &&
12 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
13 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
14 <"$TEST_DIRECTORY"/../COPYING >test &&
15 echo "to be deleted" >test2 &&
20 test_expect_success 'detect rewrite' '
22 actual=$(git diff-files -B --summary test) &&
23 verbose expr "$actual" : " rewrite test ([0-9]*%)$"
28 diff --git a/test2 b/test2
29 deleted file mode 100644
30 index 4202011..0000000
36 test_expect_success 'show deletion diff without -D' '
39 git diff -- test2 >actual &&
40 test_cmp expect actual
44 diff --git a/test2 b/test2
45 deleted file mode 100644
46 index 4202011..0000000
48 test_expect_success 'suppress deletion diff with -D' '
50 git diff -D -- test2 >actual &&
51 test_cmp expect actual
54 test_expect_success 'show deletion diff with -B' '
56 git diff -B -- test >actual &&
57 grep "Linus Torvalds" actual
60 test_expect_success 'suppress deletion diff with -B -D' '
62 git diff -B -D -- test >actual &&
63 grep -v "Linus Torvalds" actual
66 test_expect_success 'prepare a file that ends with an incomplete line' '
73 test_expect_success 'rewrite the middle 90% of sequence file and terminate with newline' '
75 test_seq 9331 9420 >>seq &&
79 test_expect_success 'confirm that sequence file is considered a rewrite' '
80 git diff -B seq >res &&
81 grep "dissimilarity index" res
84 test_expect_success 'no newline at eof is on its own line without -B' '
87 ! grep "^..*\\\\ " res
90 test_expect_success 'no newline at eof is on its own line with -B' '
91 git diff -B seq >res &&
93 ! grep "^..*\\\\ " res