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 &&
31 git reset --hard initial &&
32 test_commit "add-not-a-b" "ONE" "AAA" &&
33 git merge-tree initial add-not-a-b initial >actual &&
34 test_cmp expected actual
37 test_expect_success
'file add A, B (same)' '
38 cat >expected <<\EXPECTED &&
41 git reset --hard initial &&
42 test_commit "add-a-b-same-A" "ONE" "AAA" &&
43 git reset --hard initial &&
44 test_commit "add-a-b-same-B" "ONE" "AAA" &&
45 git merge-tree initial add-a-b-same-A add-a-b-same-B >actual &&
46 test_cmp expected actual
49 test_expect_success
'file add A, B (different)' '
50 cat >expected <<\EXPECTED &&
52 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
53 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
62 git reset --hard initial &&
63 test_commit "add-a-b-diff-A" "ONE" "AAA" &&
64 git reset --hard initial &&
65 test_commit "add-a-b-diff-B" "ONE" "BBB" &&
66 git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual &&
67 test_cmp expected actual
70 test_expect_success
'file change A, !B' '
71 cat >expected <<\EXPECTED &&
74 git reset --hard initial &&
75 test_commit "change-a-not-b" "initial-file" "BBB" &&
76 git merge-tree initial change-a-not-b initial >actual &&
77 test_cmp expected actual
80 test_expect_success
'file change !A, B' '
81 cat >expected <<\EXPECTED &&
83 result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
84 our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
90 git reset --hard initial &&
91 test_commit "change-not-a-b" "initial-file" "BBB" &&
92 git merge-tree initial initial change-not-a-b >actual &&
93 test_cmp expected actual
96 test_expect_success
'file change A, B (same)' '
97 cat >expected <<\EXPECTED &&
100 git reset --hard initial &&
101 test_commit "change-a-b-same-A" "initial-file" "AAA" &&
102 git reset --hard initial &&
103 test_commit "change-a-b-same-B" "initial-file" "AAA" &&
104 git merge-tree initial change-a-b-same-A change-a-b-same-B >actual &&
105 test_cmp expected actual
108 test_expect_success
'file change A, B (different)' '
109 cat >expected <<\EXPECTED &&
111 base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
112 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file
113 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
122 git reset --hard initial &&
123 test_commit "change-a-b-diff-A" "initial-file" "AAA" &&
124 git reset --hard initial &&
125 test_commit "change-a-b-diff-B" "initial-file" "BBB" &&
126 git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual &&
127 test_cmp expected actual
130 test_expect_success
'file change A, B (mixed)' '
131 cat >expected <<\EXPECTED &&
133 base 100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE
134 our 100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE
135 their 100644 372d761493f524d44d59bd24700c3bdf914c973c ONE
150 git reset --hard initial &&
151 test_commit "change-a-b-mix-base" "ONE" "
167 test_commit "change-a-b-mix-A" "ONE" \
168 "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" <ONE)" &&
169 git reset --hard change-a-b-mix-base &&
170 test_commit "change-a-b-mix-B" "ONE" \
171 "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/CCC/;}" <ONE)" &&
172 git merge-tree change-a-b-mix-base change-a-b-mix-A change-a-b-mix-B \
174 test_cmp expected actual
177 test_expect_success
'file remove A, !B' '
178 cat >expected <<\EXPECTED &&
181 git reset --hard initial &&
182 test_commit "rm-a-not-b-base" "ONE" "AAA" &&
184 git commit -m "rm-a-not-b" &&
185 git tag "rm-a-not-b" &&
186 git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual &&
187 test_cmp expected actual
190 test_expect_success
'file remove !A, B' '
191 cat >expected <<\EXPECTED &&
193 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
194 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
199 git reset --hard initial &&
200 test_commit "rm-not-a-b-base" "ONE" "AAA" &&
202 git commit -m "rm-not-a-b" &&
203 git tag "rm-not-a-b" &&
204 git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual &&
205 test_cmp expected actual
208 test_expect_success
'file change A, remove B' '
209 cat >expected <<\EXPECTED &&
211 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
212 our 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
217 git reset --hard initial &&
218 test_commit "change-a-rm-b-base" "ONE" "AAA" &&
219 test_commit "change-a-rm-b-A" "ONE" "BBB" &&
220 git reset --hard change-a-rm-b-base &&
222 git commit -m "change-a-rm-b-B" &&
223 git tag "change-a-rm-b-B" &&
224 git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \
226 test_cmp expected actual
229 test_expect_success
'file remove A, change B' '
230 cat >expected <<\EXPECTED &&
232 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
233 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
236 git reset --hard initial &&
237 test_commit "rm-a-change-b-base" "ONE" "AAA" &&
240 git commit -m "rm-a-change-b-A" &&
241 git tag "rm-a-change-b-A" &&
242 git reset --hard rm-a-change-b-base &&
243 test_commit "rm-a-change-b-B" "ONE" "BBB" &&
244 git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \
246 test_cmp expected actual
249 test_expect_success
'turn file to tree' '
250 git reset --hard initial &&
252 mkdir initial-file &&
253 test_commit "turn-file-to-tree" "initial-file/ONE" "CCC" &&
254 git merge-tree initial initial turn-file-to-tree >actual &&
255 cat >expect <<-\EOF &&
257 their 100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 initial-file/ONE
261 base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
262 our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
266 test_cmp expect actual
269 test_expect_success
'turn tree to file' '
270 git reset --hard initial &&
272 test_commit "add-tree" "dir/path" "AAA" &&
273 test_commit "add-another-tree" "dir/another" "BBB" &&
275 test_commit "make-file" "dir" "CCC" &&
276 git merge-tree add-tree add-another-tree make-file >actual &&
277 cat >expect <<-\EOF &&
279 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
280 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
284 their 100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 dir
288 test_cmp expect actual