blob: 213deecab1e81685589f9041216b7044243acff3 [file] [log] [blame]
Fredrik Kuivinen70574632005-12-03 11:41:54 +01001#!/bin/sh
2#
3# Copyright (c) 2005 Fredrik Kuivinen
4#
5
Ondřej Bílkaefe6de62013-07-22 10:02:17 +02006# See http://marc.info/?l=git&m=111463358500362&w=2 for a
Pavel Roskin82e5a822006-07-10 01:50:18 -04007# nice description of what this is about.
Fredrik Kuivinen70574632005-12-03 11:41:54 +01008
9
10test_description='Test criss-cross merge'
11. ./test-lib.sh
12
Fredrik Kuivinen70574632005-12-03 11:41:54 +010013test_expect_success 'prepare repository' \
14'echo "1
152
163
174
185
196
207
218
229" > file &&
Junio C Hamanoa6080a02007-06-07 00:04:01 -070023git add file &&
Fredrik Kuivinen70574632005-12-03 11:41:54 +010024git commit -m "Initial commit" file &&
25git branch A &&
26git branch B &&
27git checkout A &&
28echo "1
292
303
314
325
336
347
358 changed in B8, branch A
369" > file &&
37git commit -m "B8" file &&
38git checkout B &&
39echo "1
402
413 changed in C3, branch B
424
435
446
457
468
479
48" > file &&
49git commit -m "C3" file &&
50git branch C3 &&
Junio C Hamanod45366e2015-03-25 21:58:45 -070051git merge -m "pre E3 merge" A &&
Fredrik Kuivinen70574632005-12-03 11:41:54 +010052echo "1
532
543 changed in E3, branch B. New file size
554
565
576
587
598 changed in B8, branch A
609
61" > file &&
62git commit -m "E3" file &&
63git checkout A &&
Junio C Hamanod45366e2015-03-25 21:58:45 -070064git merge -m "pre D8 merge" C3 &&
Fredrik Kuivinen70574632005-12-03 11:41:54 +010065echo "1
662
673 changed in C3, branch B
684
695
706
717
728 changed in D8, branch A. New file size 2
739" > file &&
74git commit -m D8 file'
75
Junio C Hamanod45366e2015-03-25 21:58:45 -070076test_expect_success 'Criss-cross merge' 'git merge -m "final merge" B'
Fredrik Kuivinen70574632005-12-03 11:41:54 +010077
78cat > file-expect <<EOF
791
802
813 changed in E3, branch B. New file size
824
835
846
857
868 changed in D8, branch A. New file size 2
879
88EOF
89
90test_expect_success 'Criss-cross merge result' 'cmp file file-expect'
91
Miklos Vajna8ec0dd62008-07-12 20:42:10 +020092test_expect_success 'Criss-cross merge fails (-s resolve)' \
93'git reset --hard A^ &&
94test_must_fail git merge -s resolve -m "final merge" B'
95
Fredrik Kuivinen70574632005-12-03 11:41:54 +010096test_done