3 # Copyright (c) 2010 Will Palmer
6 test_description='git merge-tree'
9 test_expect_success setup '
10 test_commit "initial" "initial-file" "initial"
13 test_expect_success 'file add A, !B' '
14 cat >expected <<\EXPECTED &&
16 their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
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 &&
30 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
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 &&
42 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
43 their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
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 &&
57 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
58 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
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 &&
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 &&
88 result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
89 our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
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 &&
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 &&
116 base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
117 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file
118 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
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 &&
138 base 100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE
139 our 100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE
140 their 100644 372d761493f524d44d59bd24700c3bdf914c973c ONE
155 git reset --hard initial &&
156 test_commit "change-a-b-mix-base" "ONE" "
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 \
179 test_cmp expected actual
182 test_expect_success 'file remove A, !B' '
183 cat >expected <<\EXPECTED &&
185 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
186 their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
189 git reset --hard initial &&
190 test_commit "rm-a-not-b-base" "ONE" "AAA" &&
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 &&
201 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
202 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
207 git reset --hard initial &&
208 test_commit "rm-not-a-b-base" "ONE" "AAA" &&
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 &&
219 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
220 our 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
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 &&
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 \
234 test_cmp expected actual
237 test_expect_success 'file remove A, change B' '
238 cat >expected <<\EXPECTED &&
240 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
241 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
244 git reset --hard initial &&
245 test_commit "rm-a-change-b-base" "ONE" "AAA" &&
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 \
254 test_cmp expected actual