Sync with 'maint'
[alt-git.git] / t / t4023-diff-rename-typechange.sh
blobe6f4fe441e1b0dc8516d930250cba1121fc46251
1 #!/bin/sh
3 test_description='typechange rename detection'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-diff.sh
9 test_expect_success setup '
11 rm -f foo bar &&
12 COPYING_test_data >foo &&
13 test_ln_s_add linklink bar &&
14 git add foo &&
15 git commit -a -m Initial &&
16 git tag one &&
18 git rm -f foo bar &&
19 COPYING_test_data >bar &&
20 test_ln_s_add linklink foo &&
21 git add bar &&
22 git commit -a -m Second &&
23 git tag two &&
25 git rm -f foo bar &&
26 COPYING_test_data >foo &&
27 git add foo &&
28 git commit -a -m Third &&
29 git tag three &&
31 mv foo bar &&
32 test_ln_s_add linklink foo &&
33 git add bar &&
34 git commit -a -m Fourth &&
35 git tag four &&
37 # This is purely for sanity check
39 git rm -f foo bar &&
40 COPYING_test_data >foo &&
41 cat "$TEST_DIRECTORY"/../Makefile >bar &&
42 git add foo bar &&
43 git commit -a -m Fifth &&
44 git tag five &&
46 git rm -f foo bar &&
47 cat "$TEST_DIRECTORY"/../Makefile >foo &&
48 COPYING_test_data >bar &&
49 git add foo bar &&
50 git commit -a -m Sixth &&
51 git tag six
55 test_expect_success 'cross renames to be detected for regular files' '
56 git diff-tree five six -r --name-status -B -M >out &&
57 sort out >actual &&
59 echo "R100 foo bar" &&
60 echo "R100 bar foo"
61 } | sort >expect &&
62 test_cmp expect actual
66 test_expect_success 'cross renames to be detected for typechange' '
67 git diff-tree one two -r --name-status -B -M >out &&
68 sort out >actual &&
70 echo "R100 foo bar" &&
71 echo "R100 bar foo"
72 } | sort >expect &&
73 test_cmp expect actual
77 test_expect_success 'moves and renames' '
78 git diff-tree three four -r --name-status -B -M >out &&
79 sort out >actual &&
81 # see -B -M (#6) in t4008
82 echo "C100 foo bar" &&
83 echo "T100 foo"
84 } | sort >expect &&
85 test_cmp expect actual
89 test_done