disallow branch names that start with a hyphen
[git/dkf.git] / t / t4300-merge-tree.sh
blob46c3fe76d3867be394c6b9089a4aa9a1f3f6bba0
1 #!/bin/sh
3 # Copyright (c) 2010 Will Palmer
6 test_description='git merge-tree'
7 . ./test-lib.sh
9 test_expect_success setup '
10 test_commit "initial" "initial-file" "initial"
13 test_expect_success 'file add A, !B' '
14 cat >expected <<\EXPECTED &&
15 added in remote
16 their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
17 @@ -0,0 +1 @@
18 +AAA
19 EXPECTED
21 git reset --hard initial &&
22 test_commit "add-a-not-b" "ONE" "AAA" &&
23 git merge-tree initial initial add-a-not-b >actual &&
24 test_cmp expected actual
27 test_expect_success 'file add !A, B' '
28 cat >expected <<\EXPECTED &&
29 added in local
30 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
31 EXPECTED
33 git reset --hard initial &&
34 test_commit "add-not-a-b" "ONE" "AAA" &&
35 git merge-tree initial add-not-a-b initial >actual &&
36 test_cmp expected actual
39 test_expect_success 'file add A, B (same)' '
40 cat >expected <<\EXPECTED &&
41 added in both
42 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
43 their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
44 EXPECTED
46 git reset --hard initial &&
47 test_commit "add-a-b-same-A" "ONE" "AAA" &&
48 git reset --hard initial &&
49 test_commit "add-a-b-same-B" "ONE" "AAA" &&
50 git merge-tree initial add-a-b-same-A add-a-b-same-B >actual &&
51 test_cmp expected actual
54 test_expect_success 'file add A, B (different)' '
55 cat >expected <<\EXPECTED &&
56 added in both
57 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
58 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
59 @@ -1 +1,5 @@
60 +<<<<<<< .our
61 AAA
62 +=======
63 +BBB
64 +>>>>>>> .their
65 EXPECTED
67 git reset --hard initial &&
68 test_commit "add-a-b-diff-A" "ONE" "AAA" &&
69 git reset --hard initial &&
70 test_commit "add-a-b-diff-B" "ONE" "BBB" &&
71 git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual &&
72 test_cmp expected actual
75 test_expect_success 'file change A, !B' '
76 cat >expected <<\EXPECTED &&
77 EXPECTED
79 git reset --hard initial &&
80 test_commit "change-a-not-b" "initial-file" "BBB" &&
81 git merge-tree initial change-a-not-b initial >actual &&
82 test_cmp expected actual
85 test_expect_success 'file change !A, B' '
86 cat >expected <<\EXPECTED &&
87 merged
88 result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
89 our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
90 @@ -1 +1 @@
91 -initial
92 +BBB
93 EXPECTED
95 git reset --hard initial &&
96 test_commit "change-not-a-b" "initial-file" "BBB" &&
97 git merge-tree initial initial change-not-a-b >actual &&
98 test_cmp expected actual
101 test_expect_success 'file change A, B (same)' '
102 cat >expected <<\EXPECTED &&
103 EXPECTED
105 git reset --hard initial &&
106 test_commit "change-a-b-same-A" "initial-file" "AAA" &&
107 git reset --hard initial &&
108 test_commit "change-a-b-same-B" "initial-file" "AAA" &&
109 git merge-tree initial change-a-b-same-A change-a-b-same-B >actual &&
110 test_cmp expected actual
113 test_expect_success 'file change A, B (different)' '
114 cat >expected <<\EXPECTED &&
115 changed in both
116 base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
117 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file
118 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
119 @@ -1 +1,5 @@
120 +<<<<<<< .our
122 +=======
123 +BBB
124 +>>>>>>> .their
125 EXPECTED
127 git reset --hard initial &&
128 test_commit "change-a-b-diff-A" "initial-file" "AAA" &&
129 git reset --hard initial &&
130 test_commit "change-a-b-diff-B" "initial-file" "BBB" &&
131 git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual &&
132 test_cmp expected actual
135 test_expect_success 'file change A, B (mixed)' '
136 cat >expected <<\EXPECTED &&
137 changed in both
138 base 100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE
139 our 100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE
140 their 100644 372d761493f524d44d59bd24700c3bdf914c973c ONE
141 @@ -7,7 +7,11 @@
145 +<<<<<<< .our
147 +=======
148 +CCC
149 +>>>>>>> .their
153 EXPECTED
155 git reset --hard initial &&
156 test_commit "change-a-b-mix-base" "ONE" "
171 AAA" &&
172 test_commit "change-a-b-mix-A" "ONE" \
173 "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" <ONE)" &&
174 git reset --hard change-a-b-mix-base &&
175 test_commit "change-a-b-mix-B" "ONE" \
176 "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/CCC/;}" <ONE)" &&
177 git merge-tree change-a-b-mix-base change-a-b-mix-A change-a-b-mix-B \
178 >actual &&
179 test_cmp expected actual
182 test_expect_success 'file remove A, !B' '
183 cat >expected <<\EXPECTED &&
184 removed in local
185 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
186 their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
187 EXPECTED
189 git reset --hard initial &&
190 test_commit "rm-a-not-b-base" "ONE" "AAA" &&
191 git rm ONE &&
192 git commit -m "rm-a-not-b" &&
193 git tag "rm-a-not-b" &&
194 git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual &&
195 test_cmp expected actual
198 test_expect_success 'file remove !A, B' '
199 cat >expected <<\EXPECTED &&
200 removed in remote
201 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
202 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
203 @@ -1 +0,0 @@
204 -AAA
205 EXPECTED
207 git reset --hard initial &&
208 test_commit "rm-not-a-b-base" "ONE" "AAA" &&
209 git rm ONE &&
210 git commit -m "rm-not-a-b" &&
211 git tag "rm-not-a-b" &&
212 git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual &&
213 test_cmp expected actual
216 test_expect_success 'file change A, remove B' '
217 cat >expected <<\EXPECTED &&
218 removed in remote
219 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
220 our 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
221 @@ -1 +0,0 @@
222 -BBB
223 EXPECTED
225 git reset --hard initial &&
226 test_commit "change-a-rm-b-base" "ONE" "AAA" &&
227 test_commit "change-a-rm-b-A" "ONE" "BBB" &&
228 git reset --hard change-a-rm-b-base &&
229 git rm ONE &&
230 git commit -m "change-a-rm-b-B" &&
231 git tag "change-a-rm-b-B" &&
232 git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \
233 >actual &&
234 test_cmp expected actual
237 test_expect_success 'file remove A, change B' '
238 cat >expected <<\EXPECTED &&
239 removed in local
240 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
241 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
242 EXPECTED
244 git reset --hard initial &&
245 test_commit "rm-a-change-b-base" "ONE" "AAA" &&
247 git rm ONE &&
248 git commit -m "rm-a-change-b-A" &&
249 git tag "rm-a-change-b-A" &&
250 git reset --hard rm-a-change-b-base &&
251 test_commit "rm-a-change-b-B" "ONE" "BBB" &&
252 git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \
253 >actual &&
254 test_cmp expected actual
257 test_done