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 expr "$actual" : " rewrite test ([0-9]*%)$" || {
24 echo "Eh? <<$actual>>"
31 diff --git a/test2 b/test2
32 deleted file mode 100644
33 index 4202011..0000000
39 test_expect_success
'show deletion diff without -D' '
42 git diff -- test2 >actual &&
43 test_cmp expect actual
47 diff --git a/test2 b/test2
48 deleted file mode 100644
49 index 4202011..0000000
51 test_expect_success
'suppress deletion diff with -D' '
53 git diff -D -- test2 >actual &&
54 test_cmp expect actual
57 test_expect_success
'show deletion diff with -B' '
59 git diff -B -- test >actual &&
60 grep "Linus Torvalds" actual
63 test_expect_success
'suppress deletion diff with -B -D' '
65 git diff -B -D -- test >actual &&
66 grep -v "Linus Torvalds" actual
69 test_expect_success
'prepare a file that ends with an incomplete line' '
76 test_expect_success
'rewrite the middle 90% of sequence file and terminate with newline' '
78 test_seq 9331 9420 >>seq &&
82 test_expect_success
'confirm that sequence file is considered a rewrite' '
83 git diff -B seq >res &&
84 grep "dissimilarity index" res
87 test_expect_success
'no newline at eof is on its own line without -B' '
90 ! grep "^..*\\\\ " res
93 test_expect_success
'no newline at eof is on its own line with -B' '
94 git diff -B seq >res &&
96 ! grep "^..*\\\\ " res