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