initial_ref_transaction_commit(): check for ref D/F conflicts
[git/mingw/j6t.git] / t / t4022-diff-rewrite.sh
blobcb51d9f9d47d61c5b73de78edeeedcc7652f262d
1 #!/bin/sh
3 test_description='rewrite diff'
5 . ./test-lib.sh
7 test_expect_success setup '
9 cat "$TEST_DIRECTORY"/../COPYING >test &&
10 git add test &&
11 tr \
12 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
13 "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
14 <"$TEST_DIRECTORY"/../COPYING >test &&
15 echo "to be deleted" >test2 &&
16 git add test2
20 test_expect_success 'detect rewrite' '
22 actual=$(git diff-files -B --summary test) &&
23 verbose expr "$actual" : " rewrite test ([0-9]*%)$"
27 cat >expect <<EOF
28 diff --git a/test2 b/test2
29 deleted file mode 100644
30 index 4202011..0000000
31 --- a/test2
32 +++ /dev/null
33 @@ -1 +0,0 @@
34 -to be deleted
35 EOF
36 test_expect_success 'show deletion diff without -D' '
38 rm test2 &&
39 git diff -- test2 >actual &&
40 test_cmp expect actual
43 cat >expect <<EOF
44 diff --git a/test2 b/test2
45 deleted file mode 100644
46 index 4202011..0000000
47 EOF
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' '
67 test_seq 1 99 >seq &&
68 printf 100 >>seq &&
69 git add seq &&
70 git commit seq -m seq
73 test_expect_success 'rewrite the middle 90% of sequence file and terminate with newline' '
74 test_seq 1 5 >seq &&
75 test_seq 9331 9420 >>seq &&
76 test_seq 96 100 >>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' '
85 git diff seq >res &&
86 grep "^\\\\ " res &&
87 ! grep "^..*\\\\ " res
90 test_expect_success 'no newline at eof is on its own line with -B' '
91 git diff -B seq >res &&
92 grep "^\\\\ " res &&
93 ! grep "^..*\\\\ " res
96 test_done