3 test_description='merge-recursive backend test'
7 test_expect_success 'setup 1' '
10 o0=$(git hash-object a) &&
18 git commit -m initial &&
19 c0=$(git rev-parse --verify HEAD) &&
28 o1=$(git hash-object a) &&
33 git commit -m "master modifies a and d/e" &&
34 c1=$(git rev-parse --verify HEAD) &&
35 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
37 echo "100644 blob $o0 A"
38 echo "100644 blob $o1 a"
39 echo "100644 blob $o0 b"
40 echo "100644 blob $o1 d/e"
44 echo "100644 $o1 0 d/e"
46 git diff -u expected actual
49 test_expect_success 'setup 2' '
53 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
55 echo "100644 blob $o0 A"
56 echo "100644 blob $o0 a"
57 echo "100644 blob $o0 b"
58 echo "100644 blob $o0 d/e"
62 echo "100644 $o0 0 d/e"
64 git diff -u expected actual &&
67 o2=$(git hash-object a) &&
72 git commit -m "side modifies a" &&
73 c2=$(git rev-parse --verify HEAD) &&
74 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
76 echo "100644 blob $o0 A"
77 echo "100644 blob $o2 a"
78 echo "100644 blob $o0 b"
79 echo "100644 blob $o0 d/e"
83 echo "100644 $o0 0 d/e"
85 git diff -u expected actual
88 test_expect_success 'setup 3' '
92 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
94 echo "100644 blob $o0 A"
95 echo "100644 blob $o0 a"
96 echo "100644 blob $o0 b"
97 echo "100644 blob $o0 d/e"
100 echo "100644 $o0 0 b"
101 echo "100644 $o0 0 d/e"
103 git diff -u expected actual &&
105 rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
106 o3=$(git hash-object b/c) &&
109 git commit -m "df-1 makes b/c" &&
110 c3=$(git rev-parse --verify HEAD) &&
111 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
113 echo "100644 blob $o0 A"
114 echo "100644 blob $o0 a"
115 echo "100644 blob $o3 b/c"
116 echo "100644 blob $o0 d/e"
117 echo "100644 $o0 0 A"
118 echo "100644 $o0 0 a"
119 echo "100644 $o3 0 b/c"
120 echo "100644 $o0 0 d/e"
122 git diff -u expected actual
125 test_expect_success 'setup 4' '
129 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
131 echo "100644 blob $o0 A"
132 echo "100644 blob $o0 a"
133 echo "100644 blob $o0 b"
134 echo "100644 blob $o0 d/e"
135 echo "100644 $o0 0 A"
136 echo "100644 $o0 0 a"
137 echo "100644 $o0 0 b"
138 echo "100644 $o0 0 d/e"
140 git diff -u expected actual &&
142 rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
143 o4=$(git hash-object a/c) &&
146 git commit -m "df-2 makes a/c" &&
147 c4=$(git rev-parse --verify HEAD) &&
148 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
150 echo "100644 blob $o0 A"
151 echo "100644 blob $o4 a/c"
152 echo "100644 blob $o0 b"
153 echo "100644 blob $o0 d/e"
154 echo "100644 $o0 0 A"
155 echo "100644 $o4 0 a/c"
156 echo "100644 $o0 0 b"
157 echo "100644 $o0 0 d/e"
159 git diff -u expected actual
162 test_expect_success 'setup 5' '
165 git checkout remove &&
166 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
168 echo "100644 blob $o0 A"
169 echo "100644 blob $o0 a"
170 echo "100644 blob $o0 b"
171 echo "100644 blob $o0 d/e"
172 echo "100644 $o0 0 A"
173 echo "100644 $o0 0 a"
174 echo "100644 $o0 0 b"
175 echo "100644 $o0 0 d/e"
177 git diff -u expected actual &&
180 echo remove-conflict >a &&
184 o5=$(git hash-object a) &&
187 git commit -m "remove removes b and modifies a" &&
188 c5=$(git rev-parse --verify HEAD) &&
189 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
191 echo "100644 blob $o0 A"
192 echo "100644 blob $o5 a"
193 echo "100644 blob $o0 d/e"
194 echo "100644 $o0 0 A"
195 echo "100644 $o5 0 a"
196 echo "100644 $o0 0 d/e"
198 git diff -u expected actual
202 test_expect_success 'setup 6' '
206 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
208 echo "100644 blob $o0 A"
209 echo "100644 blob $o0 a"
210 echo "100644 blob $o0 b"
211 echo "100644 blob $o0 d/e"
212 echo "100644 $o0 0 A"
213 echo "100644 $o0 0 a"
214 echo "100644 $o0 0 b"
215 echo "100644 $o0 0 d/e"
217 git diff -u expected actual &&
219 rm -fr d && echo df-3 >d && git add d &&
220 o6=$(git hash-object d) &&
223 git commit -m "df-3 makes d" &&
224 c6=$(git rev-parse --verify HEAD) &&
225 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
227 echo "100644 blob $o0 A"
228 echo "100644 blob $o0 a"
229 echo "100644 blob $o0 b"
230 echo "100644 blob $o6 d"
231 echo "100644 $o0 0 A"
232 echo "100644 $o0 0 a"
233 echo "100644 $o0 0 b"
234 echo "100644 $o6 0 d"
236 git diff -u expected actual
239 test_expect_success 'merge-recursive simple' '
242 git checkout -f "$c2" &&
244 git-merge-recursive "$c0" -- "$c2" "$c1"
251 echo >&2 "why status $status!!!"
257 test_expect_success 'merge-recursive result' '
259 git ls-files -s >actual &&
261 echo "100644 $o0 0 A"
262 echo "100644 $o0 1 a"
263 echo "100644 $o2 2 a"
264 echo "100644 $o1 3 a"
265 echo "100644 $o0 0 b"
266 echo "100644 $o1 0 d/e"
268 git diff -u expected actual
272 test_expect_success 'merge-recursive remove conflict' '
275 git checkout -f "$c1" &&
277 git-merge-recursive "$c0" -- "$c1" "$c5"
284 echo >&2 "why status $status!!!"
290 test_expect_success 'merge-recursive remove conflict' '
292 git ls-files -s >actual &&
294 echo "100644 $o0 0 A"
295 echo "100644 $o0 1 a"
296 echo "100644 $o1 2 a"
297 echo "100644 $o5 3 a"
298 echo "100644 $o1 0 d/e"
300 git diff -u expected actual
304 test_expect_success 'merge-recursive d/f simple' '
307 git checkout -f "$c1" &&
309 git-merge-recursive "$c0" -- "$c1" "$c3"
312 test_expect_success 'merge-recursive result' '
314 git ls-files -s >actual &&
316 echo "100644 $o0 0 A"
317 echo "100644 $o1 0 a"
318 echo "100644 $o3 0 b/c"
319 echo "100644 $o1 0 d/e"
321 git diff -u expected actual
325 test_expect_success 'merge-recursive d/f conflict' '
329 git checkout -f "$c1" &&
331 git-merge-recursive "$c0" -- "$c1" "$c4"
338 echo >&2 "why status $status!!!"
344 test_expect_success 'merge-recursive d/f conflict result' '
346 git ls-files -s >actual &&
348 echo "100644 $o0 0 A"
349 echo "100644 $o0 1 a"
350 echo "100644 $o1 2 a"
351 echo "100644 $o4 0 a/c"
352 echo "100644 $o0 0 b"
353 echo "100644 $o1 0 d/e"
355 git diff -u expected actual
359 test_expect_success 'merge-recursive d/f conflict the other way' '
363 git checkout -f "$c4" &&
365 git-merge-recursive "$c0" -- "$c4" "$c1"
372 echo >&2 "why status $status!!!"
378 test_expect_success 'merge-recursive d/f conflict result the other way' '
380 git ls-files -s >actual &&
382 echo "100644 $o0 0 A"
383 echo "100644 $o0 1 a"
384 echo "100644 $o1 3 a"
385 echo "100644 $o4 0 a/c"
386 echo "100644 $o0 0 b"
387 echo "100644 $o1 0 d/e"
389 git diff -u expected actual
393 test_expect_success 'merge-recursive d/f conflict' '
397 git checkout -f "$c1" &&
399 git-merge-recursive "$c0" -- "$c1" "$c6"
406 echo >&2 "why status $status!!!"
412 test_expect_success 'merge-recursive d/f conflict result' '
414 git ls-files -s >actual &&
416 echo "100644 $o0 0 A"
417 echo "100644 $o1 0 a"
418 echo "100644 $o0 0 b"
419 echo "100644 $o6 3 d"
420 echo "100644 $o0 1 d/e"
421 echo "100644 $o1 2 d/e"
423 git diff -u expected actual
427 test_expect_success 'merge-recursive d/f conflict' '
431 git checkout -f "$c6" &&
433 git-merge-recursive "$c0" -- "$c6" "$c1"
440 echo >&2 "why status $status!!!"
446 test_expect_success 'merge-recursive d/f conflict result' '
448 git ls-files -s >actual &&
450 echo "100644 $o0 0 A"
451 echo "100644 $o1 0 a"
452 echo "100644 $o0 0 b"
453 echo "100644 $o6 2 d"
454 echo "100644 $o0 1 d/e"
455 echo "100644 $o1 3 d/e"
457 git diff -u expected actual
461 test_expect_success 'reset and 3-way merge' '
463 git reset --hard "$c2" &&
464 git read-tree -m "$c0" "$c2" "$c1"
468 test_expect_success 'reset and bind merge' '
470 git reset --hard master &&
471 git read-tree --prefix=M/ master &&
472 git ls-files -s >actual &&
474 echo "100644 $o0 0 A"
475 echo "100644 $o0 0 M/A"
476 echo "100644 $o1 0 M/a"
477 echo "100644 $o0 0 M/b"
478 echo "100644 $o1 0 M/d/e"
479 echo "100644 $o1 0 a"
480 echo "100644 $o0 0 b"
481 echo "100644 $o1 0 d/e"
483 git diff -u expected actual &&
485 git read-tree --prefix=a1/ master &&
486 git ls-files -s >actual &&
488 echo "100644 $o0 0 A"
489 echo "100644 $o0 0 M/A"
490 echo "100644 $o1 0 M/a"
491 echo "100644 $o0 0 M/b"
492 echo "100644 $o1 0 M/d/e"
493 echo "100644 $o1 0 a"
494 echo "100644 $o0 0 a1/A"
495 echo "100644 $o1 0 a1/a"
496 echo "100644 $o0 0 a1/b"
497 echo "100644 $o1 0 a1/d/e"
498 echo "100644 $o0 0 b"
499 echo "100644 $o1 0 d/e"
501 git diff -u expected actual
503 git read-tree --prefix=z/ master &&
504 git ls-files -s >actual &&
506 echo "100644 $o0 0 A"
507 echo "100644 $o0 0 M/A"
508 echo "100644 $o1 0 M/a"
509 echo "100644 $o0 0 M/b"
510 echo "100644 $o1 0 M/d/e"
511 echo "100644 $o1 0 a"
512 echo "100644 $o0 0 a1/A"
513 echo "100644 $o1 0 a1/a"
514 echo "100644 $o0 0 a1/b"
515 echo "100644 $o1 0 a1/d/e"
516 echo "100644 $o0 0 b"
517 echo "100644 $o1 0 d/e"
518 echo "100644 $o0 0 z/A"
519 echo "100644 $o1 0 z/a"
520 echo "100644 $o0 0 z/b"
521 echo "100644 $o1 0 z/d/e"
523 git diff -u expected actual