]> git.ipfire.org Git - thirdparty/git.git/blob - t/t6401-merge-criss-cross.sh
The third batch
[thirdparty/git.git] / t / t6401-merge-criss-cross.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Fredrik Kuivinen
4 #
5
6 # See https://lore.kernel.org/git/Pine.LNX.4.44.0504271254120.4678-100000@wax.eds.org/ for a
7 # nice description of what this is about.
8
9
10 test_description='Test criss-cross merge'
11
12 TEST_PASSES_SANITIZE_LEAK=true
13 . ./test-lib.sh
14
15 test_expect_success 'prepare repository' '
16 test_write_lines 1 2 3 4 5 6 7 8 9 >file &&
17 git add file &&
18 git commit -m "Initial commit" file &&
19
20 git branch A &&
21 git branch B &&
22 git checkout A &&
23
24 test_write_lines 1 2 3 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
25 git commit -m "B8" file &&
26 git checkout B &&
27
28 test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 8 9 >file &&
29 git commit -m "C3" file &&
30 git branch C3 &&
31
32 git merge -m "pre E3 merge" A &&
33
34 test_write_lines 1 2 "3 changed in E3, branch B. New file size" 4 5 6 7 "8 changed in B8, branch A" 9 >file &&
35 git commit -m "E3" file &&
36
37 git checkout A &&
38 git merge -m "pre D8 merge" C3 &&
39 test_write_lines 1 2 "3 changed in C3, branch B" 4 5 6 7 "8 changed in D8, branch A. New file size 2" 9 >file &&
40
41 git commit -m D8 file
42 '
43
44 test_expect_success 'Criss-cross merge' '
45 git merge -m "final merge" B
46 '
47
48 test_expect_success 'Criss-cross merge result' '
49 cat <<-\EOF >file-expect &&
50 1
51 2
52 3 changed in E3, branch B. New file size
53 4
54 5
55 6
56 7
57 8 changed in D8, branch A. New file size 2
58 9
59 EOF
60
61 test_cmp file-expect file
62 '
63
64 test_expect_success 'Criss-cross merge fails (-s resolve)' '
65 git reset --hard A^ &&
66 test_must_fail git merge -s resolve -m "final merge" B
67 '
68
69 test_done