trace: add high resolution timer function to debug performance issues
[git/raj.git] / t / t4300-merge-tree.sh
blob9015e476541dafdd6a82efcd4ace6038461d8522
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 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 &&
39 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 &&
51 added in both
52 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
53 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
54 @@ -1 +1,5 @@
55 +<<<<<<< .our
56 AAA
57 +=======
58 +BBB
59 +>>>>>>> .their
60 EXPECTED
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 &&
72 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 &&
82 merged
83 result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
84 our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
85 @@ -1 +1 @@
86 -initial
87 +BBB
88 EXPECTED
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 &&
98 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 &&
110 changed in both
111 base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
112 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file
113 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
114 @@ -1 +1,5 @@
115 +<<<<<<< .our
117 +=======
118 +BBB
119 +>>>>>>> .their
120 EXPECTED
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 &&
132 changed in both
133 base 100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE
134 our 100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE
135 their 100644 372d761493f524d44d59bd24700c3bdf914c973c ONE
136 @@ -7,7 +7,11 @@
140 +<<<<<<< .our
142 +=======
143 +CCC
144 +>>>>>>> .their
148 EXPECTED
150 git reset --hard initial &&
151 test_commit "change-a-b-mix-base" "ONE" "
166 AAA" &&
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 \
173 >actual &&
174 test_cmp expected actual
177 test_expect_success 'file remove A, !B' '
178 cat >expected <<\EXPECTED &&
179 EXPECTED
181 git reset --hard initial &&
182 test_commit "rm-a-not-b-base" "ONE" "AAA" &&
183 git rm ONE &&
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 &&
192 removed in remote
193 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
194 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
195 @@ -1 +0,0 @@
196 -AAA
197 EXPECTED
199 git reset --hard initial &&
200 test_commit "rm-not-a-b-base" "ONE" "AAA" &&
201 git rm ONE &&
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 remove A, B (same)' '
209 cat >expected <<\EXPECTED &&
210 EXPECTED
212 git reset --hard initial &&
213 test_commit "rm-a-b-base" "ONE" "AAA" &&
214 git rm ONE &&
215 git commit -m "rm-a-b" &&
216 git tag "rm-a-b" &&
217 git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&
218 test_cmp expected actual
221 test_expect_success 'file change A, remove B' '
222 cat >expected <<\EXPECTED &&
223 removed in remote
224 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
225 our 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
226 @@ -1 +0,0 @@
227 -BBB
228 EXPECTED
230 git reset --hard initial &&
231 test_commit "change-a-rm-b-base" "ONE" "AAA" &&
232 test_commit "change-a-rm-b-A" "ONE" "BBB" &&
233 git reset --hard change-a-rm-b-base &&
234 git rm ONE &&
235 git commit -m "change-a-rm-b-B" &&
236 git tag "change-a-rm-b-B" &&
237 git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \
238 >actual &&
239 test_cmp expected actual
242 test_expect_success 'file remove A, change B' '
243 cat >expected <<\EXPECTED &&
244 removed in local
245 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
246 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
247 EXPECTED
249 git reset --hard initial &&
250 test_commit "rm-a-change-b-base" "ONE" "AAA" &&
252 git rm ONE &&
253 git commit -m "rm-a-change-b-A" &&
254 git tag "rm-a-change-b-A" &&
255 git reset --hard rm-a-change-b-base &&
256 test_commit "rm-a-change-b-B" "ONE" "BBB" &&
257 git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \
258 >actual &&
259 test_cmp expected actual
262 test_expect_success 'tree add A, B (same)' '
263 cat >expect <<-\EOF &&
265 git reset --hard initial &&
266 mkdir sub &&
267 test_commit "add sub/file" "sub/file" "file" add-tree-A &&
268 git merge-tree initial add-tree-A add-tree-A >actual &&
269 test_cmp expect actual
272 test_expect_success 'tree add A, B (different)' '
273 cat >expect <<-\EOF &&
274 added in both
275 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
276 their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 sub/file
277 @@ -1 +1,5 @@
278 +<<<<<<< .our
280 +=======
281 +BBB
282 +>>>>>>> .their
284 git reset --hard initial &&
285 mkdir sub &&
286 test_commit "add sub/file" "sub/file" "AAA" add-tree-a-b-A &&
287 git reset --hard initial &&
288 mkdir sub &&
289 test_commit "add sub/file" "sub/file" "BBB" add-tree-a-b-B &&
290 git merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual &&
291 test_cmp expect actual
294 test_expect_success 'tree unchanged A, removed B' '
295 cat >expect <<-\EOF &&
296 removed in remote
297 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
298 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
299 @@ -1 +0,0 @@
300 -AAA
302 git reset --hard initial &&
303 mkdir sub &&
304 test_commit "add sub/file" "sub/file" "AAA" tree-remove-b-initial &&
305 git rm sub/file &&
306 test_tick &&
307 git commit -m "remove sub/file" &&
308 git tag tree-remove-b-B &&
309 git merge-tree tree-remove-b-initial tree-remove-b-initial tree-remove-b-B >actual &&
310 test_cmp expect actual
313 test_expect_success 'turn file to tree' '
314 git reset --hard initial &&
315 rm initial-file &&
316 mkdir initial-file &&
317 test_commit "turn-file-to-tree" "initial-file/ONE" "CCC" &&
318 git merge-tree initial initial turn-file-to-tree >actual &&
319 cat >expect <<-\EOF &&
320 added in remote
321 their 100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 initial-file/ONE
322 @@ -0,0 +1 @@
323 +CCC
324 removed in remote
325 base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
326 our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
327 @@ -1 +0,0 @@
328 -initial
330 test_cmp expect actual
333 test_expect_success 'turn tree to file' '
334 git reset --hard initial &&
335 mkdir dir &&
336 test_commit "add-tree" "dir/path" "AAA" &&
337 test_commit "add-another-tree" "dir/another" "BBB" &&
338 rm -fr dir &&
339 test_commit "make-file" "dir" "CCC" &&
340 git merge-tree add-tree add-another-tree make-file >actual &&
341 cat >expect <<-\EOF &&
342 removed in remote
343 base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
344 our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
345 @@ -1 +0,0 @@
346 -AAA
347 added in remote
348 their 100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 dir
349 @@ -0,0 +1 @@
350 +CCC
352 test_cmp expect actual
355 test_done