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 sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
53 git commit -a -m "master updates A" &&
55 git checkout yellow &&
57 git commit -a -m "yellow removes M" &&
60 sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
61 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
63 git update-index --add --remove A B M N &&
64 git commit -m "white renames A->B, M->N" &&
67 sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
68 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
70 git update-index --add --remove A B M N &&
71 git commit -m "red renames A->B, M->N" &&
74 sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
75 sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
77 git update-index --add --remove A C M N &&
78 git commit -m "blue renames A->C, M->N" &&
82 test_expect_success
'pull renaming branch into unrenaming one' \
86 echo "BAD: should have conflicted"
90 test "$(git ls-files -u B | wc -l)" -eq 3 || {
91 echo "BAD: should have left stages for B"
94 test "$(git ls-files -s N | wc -l)" -eq 1 || {
95 echo "BAD: should have merged N"
101 }" B | grep master || {
102 echo "BAD: should have listed our change first"
105 test "$(git diff white N | wc -l)" -eq 0 || {
106 echo "BAD: should have taken colored branch"
111 test_expect_success
'pull renaming branch into another renaming one' \
116 git pull . white && {
117 echo "BAD: should have conflicted"
120 test "$(git ls-files -u B | wc -l)" -eq 3 || {
121 echo "BAD: should have left stages"
124 test "$(git ls-files -s N | wc -l)" -eq 1 || {
125 echo "BAD: should have merged N"
132 echo "BAD: should have listed our change first"
135 test "$(git diff white N | wc -l)" -eq 0 || {
136 echo "BAD: should have taken colored branch"
141 test_expect_success
'pull unrenaming branch into renaming one' \
145 git pull . master && {
146 echo "BAD: should have conflicted"
149 test "$(git ls-files -u B | wc -l)" -eq 3 || {
150 echo "BAD: should have left stages"
153 test "$(git ls-files -s N | wc -l)" -eq 1 || {
154 echo "BAD: should have merged N"
161 echo "BAD: should have listed our change first"
164 test "$(git diff white N | wc -l)" -eq 0 || {
165 echo "BAD: should have taken colored branch"
170 test_expect_success
'pull conflicting renames' \
175 echo "BAD: should have conflicted"
178 test "$(git ls-files -u A | wc -l)" -eq 1 || {
179 echo "BAD: should have left a stage"
182 test "$(git ls-files -u B | wc -l)" -eq 1 || {
183 echo "BAD: should have left a stage"
186 test "$(git ls-files -u C | wc -l)" -eq 1 || {
187 echo "BAD: should have left a stage"
190 test "$(git ls-files -s N | wc -l)" -eq 1 || {
191 echo "BAD: should have merged N"
198 echo "BAD: should have listed our change first"
201 test "$(git diff white N | wc -l)" -eq 0 || {
202 echo "BAD: should have taken colored branch"
207 test_expect_success
'interference with untracked working tree file' '
211 echo >A this file should not matter
212 git pull . white && {
213 echo "BAD: should have conflicted"
217 echo "BAD: should have left A intact"
222 test_expect_success
'interference with untracked working tree file' '
228 echo >A this file should not matter
230 echo "BAD: should have conflicted"
234 echo "BAD: should have left A intact"
239 test_expect_success
'interference with untracked working tree file' '
243 git checkout -f master
246 git pull . yellow || {
247 echo "BAD: should have cleanly merged"
251 echo "BAD: should have removed M"
254 git reset --hard anchor
257 test_expect_success
'updated working tree file should prevent the merge' '
261 git checkout -f master
264 echo >>M one line addition
266 git pull . yellow && {
267 echo "BAD: should have complained"
271 echo "BAD: should have left M intact"
277 test_expect_success
'updated working tree file should prevent the merge' '
281 git checkout -f master
284 echo >>M one line addition
287 git pull . yellow && {
288 echo "BAD: should have complained"
292 echo "BAD: should have left M intact"
298 test_expect_success
'interference with untracked working tree file' '
302 git checkout -f yellow
305 echo >M this file should not matter
306 git pull . master || {
307 echo "BAD: should have cleanly merged"
311 echo "BAD: should have left M intact"
314 git ls-files -s | grep M && {
315 echo "BAD: M must be untracked in the result"
318 git reset --hard anchor