]> git.ipfire.org Git - thirdparty/git.git/blob - t/t6044-merge-unrelated-index-changes.sh
Merge branch '2.16' of https://github.com/ChrisADR/git-po
[thirdparty/git.git] / t / t6044-merge-unrelated-index-changes.sh
1 #!/bin/sh
2
3 test_description="merges with unrelated index changes"
4
5 . ./test-lib.sh
6
7 # Testcase for some simple merges
8 # A
9 # o-------o B
10 # \
11 # \-----o C
12 # \
13 # \---o D
14 # \
15 # \-o E
16 # \
17 # o F
18 # Commit A: some file a
19 # Commit B: adds file b, modifies end of a
20 # Commit C: adds file c
21 # Commit D: adds file d, modifies beginning of a
22 # Commit E: renames a->subdir/a, adds subdir/e
23 # Commit F: empty commit
24
25 test_expect_success 'setup trivial merges' '
26 test_seq 1 10 >a &&
27 git add a &&
28 test_tick && git commit -m A &&
29
30 git branch A &&
31 git branch B &&
32 git branch C &&
33 git branch D &&
34 git branch E &&
35 git branch F &&
36
37 git checkout B &&
38 echo b >b &&
39 echo 11 >>a &&
40 git add a b &&
41 test_tick && git commit -m B &&
42
43 git checkout C &&
44 echo c >c &&
45 git add c &&
46 test_tick && git commit -m C &&
47
48 git checkout D &&
49 test_seq 2 10 >a &&
50 echo d >d &&
51 git add a d &&
52 test_tick && git commit -m D &&
53
54 git checkout E &&
55 mkdir subdir &&
56 git mv a subdir/a &&
57 echo e >subdir/e &&
58 git add subdir &&
59 test_tick && git commit -m E &&
60
61 git checkout F &&
62 test_tick && git commit --allow-empty -m F
63 '
64
65 test_expect_success 'ff update' '
66 git reset --hard &&
67 git checkout A^0 &&
68
69 touch random_file && git add random_file &&
70
71 git merge E^0 &&
72
73 test_must_fail git rev-parse HEAD:random_file &&
74 test "$(git diff --name-only --cached E)" = "random_file"
75 '
76
77 test_expect_success 'ff update, important file modified' '
78 git reset --hard &&
79 git checkout A^0 &&
80
81 mkdir subdir &&
82 touch subdir/e &&
83 git add subdir/e &&
84
85 test_must_fail git merge E^0
86 '
87
88 test_expect_success 'resolve, trivial' '
89 git reset --hard &&
90 git checkout B^0 &&
91
92 touch random_file && git add random_file &&
93
94 test_must_fail git merge -s resolve C^0
95 '
96
97 test_expect_success 'resolve, non-trivial' '
98 git reset --hard &&
99 git checkout B^0 &&
100
101 touch random_file && git add random_file &&
102
103 test_must_fail git merge -s resolve D^0
104 '
105
106 test_expect_success 'recursive' '
107 git reset --hard &&
108 git checkout B^0 &&
109
110 touch random_file && git add random_file &&
111
112 test_must_fail git merge -s recursive C^0
113 '
114
115 test_expect_success 'recursive, when merge branch matches merge base' '
116 git reset --hard &&
117 git checkout B^0 &&
118
119 touch random_file && git add random_file &&
120
121 test_must_fail git merge -s recursive F^0
122 '
123
124 test_expect_success 'octopus, unrelated file touched' '
125 git reset --hard &&
126 git checkout B^0 &&
127
128 touch random_file && git add random_file &&
129
130 test_must_fail git merge C^0 D^0
131 '
132
133 test_expect_success 'octopus, related file removed' '
134 git reset --hard &&
135 git checkout B^0 &&
136
137 git rm b &&
138
139 test_must_fail git merge C^0 D^0
140 '
141
142 test_expect_success 'octopus, related file modified' '
143 git reset --hard &&
144 git checkout B^0 &&
145
146 echo 12 >>a && git add a &&
147
148 test_must_fail git merge C^0 D^0
149 '
150
151 test_expect_success 'ours' '
152 git reset --hard &&
153 git checkout B^0 &&
154
155 touch random_file && git add random_file &&
156
157 test_must_fail git merge -s ours C^0
158 '
159
160 test_expect_success 'subtree' '
161 git reset --hard &&
162 git checkout B^0 &&
163
164 touch random_file && git add random_file &&
165
166 test_must_fail git merge -s subtree E^0
167 '
168
169 test_done