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 &&
16 blob=$(git hash-object test2) &&
17 blob=$(git rev-parse --short $blob) &&
22 test_expect_success 'detect rewrite' '
24 actual=$(git diff-files -B --summary test) &&
25 verbose expr "$actual" : " rewrite test ([0-9]*%)$"
30 diff --git a/test2 b/test2
31 deleted file mode 100644
38 test_expect_success 'show deletion diff without -D' '
41 git diff -- test2 >actual &&
42 test_cmp expect actual
46 diff --git a/test2 b/test2
47 deleted file mode 100644
50 test_expect_success 'suppress deletion diff with -D' '
52 git diff -D -- test2 >actual &&
53 test_cmp expect actual
56 test_expect_success 'show deletion diff with -B' '
58 git diff -B -- test >actual &&
59 grep "Linus Torvalds" actual
62 test_expect_success 'suppress deletion diff with -B -D' '
64 git diff -B -D -- test >actual &&
65 grep -v "Linus Torvalds" actual
68 test_expect_success 'prepare a file that ends with an incomplete line' '
75 test_expect_success 'rewrite the middle 90% of sequence file and terminate with newline' '
77 test_seq 9331 9420 >>seq &&
81 test_expect_success 'confirm that sequence file is considered a rewrite' '
82 git diff -B seq >res &&
83 grep "dissimilarity index" res
86 test_expect_success 'no newline at eof is on its own line without -B' '
89 ! grep "^..*\\\\ " res
92 test_expect_success 'no newline at eof is on its own line with -B' '
93 git diff -B seq >res &&
95 ! grep "^..*\\\\ " res