Merge branch 'jk/symbolic-ref-short'
[git/gitweb.git] / t / t4022-diff-rewrite.sh
blobc00a94b9ba4498e72a31856aac9cf653bbce8ba3
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 expr "$actual" : " rewrite test ([0-9]*%)$" || {
24 echo "Eh? <<$actual>>"
25 false
30 cat >expect <<EOF
31 diff --git a/test2 b/test2
32 deleted file mode 100644
33 index 4202011..0000000
34 --- a/test2
35 +++ /dev/null
36 @@ -1 +0,0 @@
37 -to be deleted
38 EOF
39 test_expect_success 'show deletion diff without -D' '
41 rm test2 &&
42 git diff -- test2 >actual &&
43 test_cmp expect actual
46 cat >expect <<EOF
47 diff --git a/test2 b/test2
48 deleted file mode 100644
49 index 4202011..0000000
50 EOF
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_done