3 test_description
='Merge-recursive merging renames'
6 test_expect_success setup \
9 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
10 b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
11 c cccccccccccccccccccccccccccccccccccccccccccccccc
12 d dddddddddddddddddddddddddddddddddddddddddddddddd
13 e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
14 f ffffffffffffffffffffffffffffffffffffffffffffffff
15 g gggggggggggggggggggggggggggggggggggggggggggggggg
16 h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
17 i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
18 j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
19 k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
20 l llllllllllllllllllllllllllllllllllllllllllllllll
21 m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
22 n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
23 o oooooooooooooooooooooooooooooooooooooooooooooooo
27 A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
28 B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
29 C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
30 D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
31 E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
32 F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
33 G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
34 H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
35 I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
36 J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
37 K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
38 L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
39 M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
40 N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
41 O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
45 git commit -m "initial has A and M" &&
51 git branch change+rename &&
53 sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
55 git commit -a -m "master updates A" &&
57 git checkout yellow &&
59 git commit -a -m "yellow removes M" &&
62 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
63 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
65 git update-index --add --remove A B M N &&
66 git commit -m "white renames A->B, M->N" &&
69 sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
70 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
72 git update-index --add --remove A B M N &&
73 git commit -m "red renames A->B, M->N" &&
76 sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
77 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
79 git update-index --add --remove A C M N &&
80 git commit -m "blue renames A->C, M->N" &&
82 git checkout change &&
83 sed -e "/^g /s/.*/g : changed line/" <A >A+ &&
85 git commit -q -a -m "changed" &&
87 git checkout change+rename &&
88 sed -e "/^g /s/.*/g : changed line/" <A >B &&
90 git update-index --add B &&
91 git commit -q -a -m "changed and renamed" &&
95 test_expect_success
'pull renaming branch into unrenaming one' \
98 test_expect_code 1 git pull . white &&
100 git ls-files -u B >b.stages &&
101 test_line_count = 3 b.stages &&
102 git ls-files -s N >n.stages &&
103 test_line_count = 1 n.stages &&
107 }" B | grep master &&
108 git diff --exit-code white N
111 test_expect_success
'pull renaming branch into another renaming one' \
116 test_expect_code 1 git pull . white &&
117 git ls-files -u B >b.stages &&
118 test_line_count = 3 b.stages &&
119 git ls-files -s N >n.stages &&
120 test_line_count = 1 n.stages &&
125 git diff --exit-code white N
128 test_expect_success
'pull unrenaming branch into renaming one' \
132 test_expect_code 1 git pull . master &&
133 git ls-files -u B >b.stages &&
134 test_line_count = 3 b.stages &&
135 git ls-files -s N >n.stages &&
136 test_line_count = 1 n.stages &&
141 git diff --exit-code white N
144 test_expect_success
'pull conflicting renames' \
148 test_expect_code 1 git pull . blue &&
149 git ls-files -u A >a.stages &&
150 test_line_count = 1 a.stages &&
151 git ls-files -u B >b.stages &&
152 test_line_count = 1 b.stages &&
153 git ls-files -u C >c.stages &&
154 test_line_count = 1 c.stages &&
155 git ls-files -s N >n.stages &&
156 test_line_count = 1 n.stages &&
161 git diff --exit-code white N
164 test_expect_success
'interference with untracked working tree file' '
167 echo >A this file should not matter &&
168 test_expect_code 1 git pull . white &&
172 test_expect_success
'interference with untracked working tree file' '
174 git checkout white &&
177 echo >A this file should not matter &&
178 test_expect_code 1 git pull . red &&
182 test_expect_success
'interference with untracked working tree file' '
185 git checkout -f master &&
189 test_path_is_missing M &&
190 git reset --hard anchor
193 test_expect_success
'updated working tree file should prevent the merge' '
196 git checkout -f master &&
199 echo >>M one line addition &&
201 test_expect_code 128 git pull . yellow &&
202 test_cmp M M.saved &&
206 test_expect_success
'updated working tree file should prevent the merge' '
209 git checkout -f master &&
212 echo >>M one line addition &&
214 git update-index M &&
215 test_expect_code 128 git pull . yellow &&
216 test_cmp M M.saved &&
220 test_expect_success
'interference with untracked working tree file' '
223 git checkout -f yellow &&
226 echo >M this file should not matter &&
228 test_path_is_file M &&
233 git reset --hard anchor
236 test_expect_success
'merge of identical changes in a renamed file' '
239 git checkout change+rename &&
240 GIT_MERGE_VERBOSITY=3 git merge change | grep "^Skipped B" &&
241 git reset --hard HEAD^ &&
242 git checkout change &&
243 GIT_MERGE_VERBOSITY=3 git merge change+rename | grep "^Skipped B"