4dbfc6e8b751a6c93b1f9dfee8ce649235c98c93
[git/git.git] / t / t4023-diff-rename-typechange.sh
1 #!/bin/sh
2
3 test_description='typechange rename detection'
4
5 . ./test-lib.sh
6
7 test_expect_success setup '
8
9 rm -f foo bar &&
10 cat ../../COPYING >foo &&
11 ln -s linklink bar &&
12 git add foo bar &&
13 git commit -a -m Initial &&
14 git tag one &&
15
16 rm -f foo bar &&
17 cat ../../COPYING >bar &&
18 ln -s linklink foo &&
19 git add foo bar &&
20 git commit -a -m Second &&
21 git tag two &&
22
23 rm -f foo bar &&
24 cat ../../COPYING >foo &&
25 git add foo &&
26 git commit -a -m Third &&
27 git tag three &&
28
29 mv foo bar &&
30 ln -s linklink foo &&
31 git add foo bar &&
32 git commit -a -m Fourth &&
33 git tag four &&
34
35 # This is purely for sanity check
36
37 rm -f foo bar &&
38 cat ../../COPYING >foo &&
39 cat ../../Makefile >bar &&
40 git add foo bar &&
41 git commit -a -m Fifth &&
42 git tag five &&
43
44 rm -f foo bar &&
45 cat ../../Makefile >foo &&
46 cat ../../COPYING >bar &&
47 git add foo bar &&
48 git commit -a -m Sixth &&
49 git tag six
50
51 '
52
53 test_expect_success 'cross renames to be detected for regular files' '
54
55 git diff-tree five six -r --name-status -B -M | sort >actual &&
56 {
57 echo "R100 foo bar"
58 echo "R100 bar foo"
59 } | sort >expect &&
60 test_cmp expect actual
61
62 '
63
64 test_expect_success 'cross renames to be detected for typechange' '
65
66 git diff-tree one two -r --name-status -B -M | sort >actual &&
67 {
68 echo "R100 foo bar"
69 echo "R100 bar foo"
70 } | sort >expect &&
71 test_cmp expect actual
72
73 '
74
75 test_expect_success 'moves and renames' '
76
77 git diff-tree three four -r --name-status -B -M | sort >actual &&
78 {
79 echo "R100 foo bar"
80 echo "T100 foo"
81 } | sort >expect &&
82 test_cmp expect actual
83
84 '
85
86 test_done