]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3309-notes-merge-auto-resolve.sh
The third batch
[thirdparty/git.git] / t / t3309-notes-merge-auto-resolve.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Johan Herland
4 #
5
6 test_description='Test notes merging with auto-resolving strategies'
7
8 . ./test-lib.sh
9
10 # Set up a notes merge scenario with all kinds of potential conflicts
11 test_expect_success 'setup commits' '
12 test_commit 1st &&
13 test_commit 2nd &&
14 test_commit 3rd &&
15 test_commit 4th &&
16 test_commit 5th &&
17 test_commit 6th &&
18 test_commit 7th &&
19 test_commit 8th &&
20 test_commit 9th &&
21 test_commit 10th &&
22 test_commit 11th &&
23 test_commit 12th &&
24 test_commit 13th &&
25 test_commit 14th &&
26 test_commit 15th &&
27
28 test_oid_cache <<-EOF
29 hash15a sha1:457a85d6c814ea208550f15fcc48f804ac8dc023
30 hash14a sha1:b0c95b954301d69da2bc3723f4cb1680d355937c
31 hash13a sha1:5d30216a129eeffa97d9694ffe8c74317a560315
32 hash12a sha1:dd161bc149470fd890dd4ab52a4cbd79bbd18c36
33 hash11a sha1:7abbc45126d680336fb24294f013a7cdfa3ed545
34 hash10a sha1:b8d03e173f67f6505a76f6e00cf93440200dd9be
35 hash09a sha1:20c613c835011c48a5abe29170a2402ca6354910
36 hash08a sha1:a3daf8a1e4e5dc3409a303ad8481d57bfea7f5d6
37 hash07a sha1:897003322b53bc6ca098e9324ee508362347e734
38 hash06a sha1:11d97fdebfa5ceee540a3da07bce6fa0222bc082
39 hash15b sha1:68b8630d25516028bed862719855b3d6768d7833
40 hash14b sha1:5de7ea7ad4f47e7ff91989fb82234634730f75df
41 hash13b sha1:3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc
42 hash12b sha1:a66055fa82f7a03fe0c02a6aba3287a85abf7c62
43 hash05b sha1:154508c7a0bcad82b6fe4b472bc4c26b3bf0825b
44 hash04b sha1:e2bfd06a37dd2031684a59a6e2b033e212239c78
45 hash03b sha1:5772f42408c0dd6f097a7ca2d24de0e78d1c46b1
46 hash15c sha1:9b4b2c61f0615412da3c10f98ff85b57c04ec765
47 hash11c sha1:7e3c53503a3db8dd996cb62e37c66e070b44b54d
48 hash08c sha1:851e1638784a884c7dd26c5d41f3340f6387413a
49 hash05c sha1:99fc34adfc400b95c67b013115e37e31aa9a6d23
50 hash02c sha1:283b48219aee9a4105f6cab337e789065c82c2b9
51 hash15d sha1:7c4e546efd0fe939f876beb262ece02797880b54
52 hash05d sha1:6c841cc36ea496027290967ca96bd2bef54dbb47
53 hash15e sha1:d682107b8bf7a7aea1e537a8d5cb6a12b60135f1
54 hash05e sha1:357b6ca14c7afd59b7f8b8aaaa6b8b723771135b
55 hash15f sha1:6be90240b5f54594203e25d9f2f64b7567175aee
56 hash05f sha1:660311d7f78dc53db12ac373a43fca7465381a7e
57
58 hash15a sha256:45b1558e5c1b75f570010fa48aaa67bb2289fcd431b34ad81cb4c8b95f4f872a
59 hash14a sha256:6e7af179ea4dd28afdc83ae6912ba0098cdeff764b26a8b750b157dd81749092
60 hash13a sha256:7353089961baf555388e1bac68c67c8ea94b08ccbd97532201cf7f6790703052
61 hash12a sha256:5863e4521689ee1879ceab3b38d39e93ab5b51ec70aaf6a96ad388fbdedfa25e
62 hash11a sha256:82a0ec0338b4ecf8b44304badf4ad38d7469dc41827f38d7ba6c42e3bae3ee98
63 hash10a sha256:e84f2564e92de9792c93b8d197262c735d7ccb1de6025cef8759af8f6c3308eb
64 hash09a sha256:4dd07764bcec696f195c0ea71ae89e174876403af1637e4642b8f4453fd23028
65 hash08a sha256:02132c4546cd88a1d0aa5854dd55da120927f7904ba16afe36fe03e91a622067
66 hash07a sha256:369baf7d00c6720efdc10273493555f943051f84a4706fb24caeb353fa4789db
67 hash06a sha256:52d32c10353583b2d96a5849b1f1f43c8018e76f3e8ef1b0d46eb5cff7cdefaf
68 hash15b sha256:345e6660b345fa174738a31a7a59423c394bdf414804e200bc510c65d971ae96
69 hash14b sha256:7653a6596021c52e405cba979eea15a729993e7102b9a61ba4667e34f0ead4a1
70 hash13b sha256:0f202a0b6b9690de2349c173dfd766a37e82744f61c14f1c389306f1d69f470b
71 hash12b sha256:eb00f219c026136ea6535b16ff8ec3efa510e6bf50098ca041e1a2a1d4b79840
72 hash05b sha256:993b2290cd0c24c27c849d99f1904f3b590f77af0f539932734ad05679ac5a2f
73 hash04b sha256:c7fba0d6104917fbf35258f40b9fa4fc697cfa992deecd1570a3b08d0a5587a9
74 hash03b sha256:7287a2d78a3766c181b08df38951d784b08b72a44f571ed6d855bd0be22c70f6
75 hash15c sha256:62316660a22bf97857dc4a16709ec4d93a224e8c9f37d661ef91751e1f4c4166
76 hash11c sha256:51c3763de9b08309370adc5036d58debb331980e73097902957c444602551daa
77 hash08c sha256:22cf1fa29599898a7218c51135d66ed85d22aad584f77db3305dedce4c3d4798
78 hash05c sha256:2508fd86db980f0508893a1c1571bdf3b2ee113dc25ddb1a3a2fb94bd6cd0d58
79 hash02c sha256:63bb527e0b4e1c8e1dd0d54dd778ca7c3718689fd6e37c473044cfbcf1cacfdb
80 hash15d sha256:667acb4e2d5f8df15e5aea4506dfd16d25bc7feca70fdb0d965a7222f983bb88
81 hash05d sha256:09e6b5a6fe666c4a027674b6611a254b7d2528cd211c6b5288d1b4db6c741dfa
82 hash15e sha256:e8cbf52f6fcadc6de3c7761e64a89e9fe38d19a03d3e28ef6ca8596d93fc4f3a
83 hash05e sha256:cdb1e19f7ba1539f95af51a57edeb88a7ecc97d3c2f52da8c4c86af308595607
84 hash15f sha256:29c14cb92da448a923963b8a43994268b19c2e57913de73f3667421fd2c0eeec
85 hash05f sha256:14a6e641b2c0a9f398ebac6b4d34afa5efea4c52d2631382f45f8f662266903b
86 EOF
87 '
88
89 commit_sha1=$(git rev-parse 1st^{commit})
90 commit_sha2=$(git rev-parse 2nd^{commit})
91 commit_sha3=$(git rev-parse 3rd^{commit})
92 commit_sha4=$(git rev-parse 4th^{commit})
93 commit_sha5=$(git rev-parse 5th^{commit})
94 commit_sha6=$(git rev-parse 6th^{commit})
95 commit_sha7=$(git rev-parse 7th^{commit})
96 commit_sha8=$(git rev-parse 8th^{commit})
97 commit_sha9=$(git rev-parse 9th^{commit})
98 commit_sha10=$(git rev-parse 10th^{commit})
99 commit_sha11=$(git rev-parse 11th^{commit})
100 commit_sha12=$(git rev-parse 12th^{commit})
101 commit_sha13=$(git rev-parse 13th^{commit})
102 commit_sha14=$(git rev-parse 14th^{commit})
103 commit_sha15=$(git rev-parse 15th^{commit})
104
105 verify_notes () {
106 notes_ref="$1"
107 suffix="$2"
108 git -c core.notesRef="refs/notes/$notes_ref" notes |
109 sort >"output_notes_$suffix" &&
110 test_cmp "expect_notes_$suffix" "output_notes_$suffix" &&
111 git -c core.notesRef="refs/notes/$notes_ref" log --format="%H %s%n%N" \
112 >"output_log_$suffix" &&
113 test_cmp "expect_log_$suffix" "output_log_$suffix"
114 }
115
116 test_expect_success 'setup merge base (x)' '
117 git config core.notesRef refs/notes/x &&
118 git notes add -m "x notes on 6th commit" 6th &&
119 git notes add -m "x notes on 7th commit" 7th &&
120 git notes add -m "x notes on 8th commit" 8th &&
121 git notes add -m "x notes on 9th commit" 9th &&
122 git notes add -m "x notes on 10th commit" 10th &&
123 git notes add -m "x notes on 11th commit" 11th &&
124 git notes add -m "x notes on 12th commit" 12th &&
125 git notes add -m "x notes on 13th commit" 13th &&
126 git notes add -m "x notes on 14th commit" 14th &&
127 git notes add -m "x notes on 15th commit" 15th
128 '
129
130 cat <<EOF | sort >expect_notes_x
131 $(test_oid hash15a) $commit_sha15
132 $(test_oid hash14a) $commit_sha14
133 $(test_oid hash13a) $commit_sha13
134 $(test_oid hash12a) $commit_sha12
135 $(test_oid hash11a) $commit_sha11
136 $(test_oid hash10a) $commit_sha10
137 $(test_oid hash09a) $commit_sha9
138 $(test_oid hash08a) $commit_sha8
139 $(test_oid hash07a) $commit_sha7
140 $(test_oid hash06a) $commit_sha6
141 EOF
142
143 cat >expect_log_x <<EOF
144 $commit_sha15 15th
145 x notes on 15th commit
146
147 $commit_sha14 14th
148 x notes on 14th commit
149
150 $commit_sha13 13th
151 x notes on 13th commit
152
153 $commit_sha12 12th
154 x notes on 12th commit
155
156 $commit_sha11 11th
157 x notes on 11th commit
158
159 $commit_sha10 10th
160 x notes on 10th commit
161
162 $commit_sha9 9th
163 x notes on 9th commit
164
165 $commit_sha8 8th
166 x notes on 8th commit
167
168 $commit_sha7 7th
169 x notes on 7th commit
170
171 $commit_sha6 6th
172 x notes on 6th commit
173
174 $commit_sha5 5th
175
176 $commit_sha4 4th
177
178 $commit_sha3 3rd
179
180 $commit_sha2 2nd
181
182 $commit_sha1 1st
183
184 EOF
185
186 test_expect_success 'verify state of merge base (x)' 'verify_notes x x'
187
188 test_expect_success 'setup local branch (y)' '
189 git update-ref refs/notes/y refs/notes/x &&
190 git config core.notesRef refs/notes/y &&
191 git notes add -f -m "y notes on 3rd commit" 3rd &&
192 git notes add -f -m "y notes on 4th commit" 4th &&
193 git notes add -f -m "y notes on 5th commit" 5th &&
194 git notes remove 6th &&
195 git notes remove 7th &&
196 git notes remove 8th &&
197 git notes add -f -m "y notes on 12th commit" 12th &&
198 git notes add -f -m "y notes on 13th commit" 13th &&
199 git notes add -f -m "y notes on 14th commit" 14th &&
200 git notes add -f -m "y notes on 15th commit" 15th
201 '
202
203 cat <<EOF | sort >expect_notes_y
204 $(test_oid hash15b) $commit_sha15
205 $(test_oid hash14b) $commit_sha14
206 $(test_oid hash13b) $commit_sha13
207 $(test_oid hash12b) $commit_sha12
208 $(test_oid hash11a) $commit_sha11
209 $(test_oid hash10a) $commit_sha10
210 $(test_oid hash09a) $commit_sha9
211 $(test_oid hash05b) $commit_sha5
212 $(test_oid hash04b) $commit_sha4
213 $(test_oid hash03b) $commit_sha3
214 EOF
215
216 cat >expect_log_y <<EOF
217 $commit_sha15 15th
218 y notes on 15th commit
219
220 $commit_sha14 14th
221 y notes on 14th commit
222
223 $commit_sha13 13th
224 y notes on 13th commit
225
226 $commit_sha12 12th
227 y notes on 12th commit
228
229 $commit_sha11 11th
230 x notes on 11th commit
231
232 $commit_sha10 10th
233 x notes on 10th commit
234
235 $commit_sha9 9th
236 x notes on 9th commit
237
238 $commit_sha8 8th
239
240 $commit_sha7 7th
241
242 $commit_sha6 6th
243
244 $commit_sha5 5th
245 y notes on 5th commit
246
247 $commit_sha4 4th
248 y notes on 4th commit
249
250 $commit_sha3 3rd
251 y notes on 3rd commit
252
253 $commit_sha2 2nd
254
255 $commit_sha1 1st
256
257 EOF
258
259 test_expect_success 'verify state of local branch (y)' 'verify_notes y y'
260
261 test_expect_success 'setup remote branch (z)' '
262 git update-ref refs/notes/z refs/notes/x &&
263 git config core.notesRef refs/notes/z &&
264 git notes add -f -m "z notes on 2nd commit" 2nd &&
265 git notes add -f -m "y notes on 4th commit" 4th &&
266 git notes add -f -m "z notes on 5th commit" 5th &&
267 git notes remove 6th &&
268 git notes add -f -m "z notes on 8th commit" 8th &&
269 git notes remove 9th &&
270 git notes add -f -m "z notes on 11th commit" 11th &&
271 git notes remove 12th &&
272 git notes add -f -m "y notes on 14th commit" 14th &&
273 git notes add -f -m "z notes on 15th commit" 15th
274 '
275
276 cat <<EOF | sort >expect_notes_z
277 $(test_oid hash15c) $commit_sha15
278 $(test_oid hash14b) $commit_sha14
279 $(test_oid hash13a) $commit_sha13
280 $(test_oid hash11c) $commit_sha11
281 $(test_oid hash10a) $commit_sha10
282 $(test_oid hash08c) $commit_sha8
283 $(test_oid hash07a) $commit_sha7
284 $(test_oid hash05c) $commit_sha5
285 $(test_oid hash04b) $commit_sha4
286 $(test_oid hash02c) $commit_sha2
287 EOF
288
289 cat >expect_log_z <<EOF
290 $commit_sha15 15th
291 z notes on 15th commit
292
293 $commit_sha14 14th
294 y notes on 14th commit
295
296 $commit_sha13 13th
297 x notes on 13th commit
298
299 $commit_sha12 12th
300
301 $commit_sha11 11th
302 z notes on 11th commit
303
304 $commit_sha10 10th
305 x notes on 10th commit
306
307 $commit_sha9 9th
308
309 $commit_sha8 8th
310 z notes on 8th commit
311
312 $commit_sha7 7th
313 x notes on 7th commit
314
315 $commit_sha6 6th
316
317 $commit_sha5 5th
318 z notes on 5th commit
319
320 $commit_sha4 4th
321 y notes on 4th commit
322
323 $commit_sha3 3rd
324
325 $commit_sha2 2nd
326 z notes on 2nd commit
327
328 $commit_sha1 1st
329
330 EOF
331
332 test_expect_success 'verify state of remote branch (z)' 'verify_notes z z'
333
334 # At this point, before merging z into y, we have the following status:
335 #
336 # commit | base/x | local/y | remote/z | diff from x to y/z | result
337 # -------|---------|---------|----------|----------------------------|-------
338 # 1st | [none] | [none] | [none] | unchanged / unchanged | [none]
339 # 2nd | [none] | [none] | 283b482 | unchanged / added | 283b482
340 # 3rd | [none] | 5772f42 | [none] | added / unchanged | 5772f42
341 # 4th | [none] | e2bfd06 | e2bfd06 | added / added (same) | e2bfd06
342 # 5th | [none] | 154508c | 99fc34a | added / added (diff) | ???
343 # 6th | 11d97fd | [none] | [none] | removed / removed | [none]
344 # 7th | 8970033 | [none] | 8970033 | removed / unchanged | [none]
345 # 8th | a3daf8a | [none] | 851e163 | removed / changed | ???
346 # 9th | 20c613c | 20c613c | [none] | unchanged / removed | [none]
347 # 10th | b8d03e1 | b8d03e1 | b8d03e1 | unchanged / unchanged | b8d03e1
348 # 11th | 7abbc45 | 7abbc45 | 7e3c535 | unchanged / changed | 7e3c535
349 # 12th | dd161bc | a66055f | [none] | changed / removed | ???
350 # 13th | 5d30216 | 3a631fd | 5d30216 | changed / unchanged | 3a631fd
351 # 14th | b0c95b9 | 5de7ea7 | 5de7ea7 | changed / changed (same) | 5de7ea7
352 # 15th | 457a85d | 68b8630 | 9b4b2c6 | changed / changed (diff) | ???
353
354 test_expect_success 'merge z into y with invalid strategy => Fail/No changes' '
355 git config core.notesRef refs/notes/y &&
356 test_must_fail git notes merge --strategy=foo z &&
357 # Verify no changes (y)
358 verify_notes y y
359 '
360
361 test_expect_success 'merge z into y with invalid configuration option => Fail/No changes' '
362 git config core.notesRef refs/notes/y &&
363 cat >expect <<-\EOF &&
364 error: unknown notes merge strategy foo
365 fatal: unable to parse '\''notes.mergeStrategy'\'' from command-line config
366 EOF
367 test_must_fail git -c notes.mergeStrategy="foo" notes merge z 2>actual &&
368 test_cmp expect actual &&
369 # Verify no changes (y)
370 verify_notes y y
371 '
372
373 cat <<EOF | sort >expect_notes_ours
374 $(test_oid hash15b) $commit_sha15
375 $(test_oid hash14b) $commit_sha14
376 $(test_oid hash13b) $commit_sha13
377 $(test_oid hash12b) $commit_sha12
378 $(test_oid hash11c) $commit_sha11
379 $(test_oid hash10a) $commit_sha10
380 $(test_oid hash05b) $commit_sha5
381 $(test_oid hash04b) $commit_sha4
382 $(test_oid hash03b) $commit_sha3
383 $(test_oid hash02c) $commit_sha2
384 EOF
385
386 cat >expect_log_ours <<EOF
387 $commit_sha15 15th
388 y notes on 15th commit
389
390 $commit_sha14 14th
391 y notes on 14th commit
392
393 $commit_sha13 13th
394 y notes on 13th commit
395
396 $commit_sha12 12th
397 y notes on 12th commit
398
399 $commit_sha11 11th
400 z notes on 11th commit
401
402 $commit_sha10 10th
403 x notes on 10th commit
404
405 $commit_sha9 9th
406
407 $commit_sha8 8th
408
409 $commit_sha7 7th
410
411 $commit_sha6 6th
412
413 $commit_sha5 5th
414 y notes on 5th commit
415
416 $commit_sha4 4th
417 y notes on 4th commit
418
419 $commit_sha3 3rd
420 y notes on 3rd commit
421
422 $commit_sha2 2nd
423 z notes on 2nd commit
424
425 $commit_sha1 1st
426
427 EOF
428
429 test_expect_success 'merge z into y with "ours" strategy => Non-conflicting 3-way merge' '
430 git notes merge --strategy=ours z &&
431 verify_notes y ours
432 '
433
434 test_expect_success 'reset to pre-merge state (y)' '
435 git update-ref refs/notes/y refs/notes/y^1 &&
436 # Verify pre-merge state
437 verify_notes y y
438 '
439
440 test_expect_success 'merge z into y with "ours" configuration option => Non-conflicting 3-way merge' '
441 git -c notes.mergeStrategy="ours" notes merge z &&
442 verify_notes y ours
443 '
444
445 test_expect_success 'reset to pre-merge state (y)' '
446 git update-ref refs/notes/y refs/notes/y^1 &&
447 # Verify pre-merge state
448 verify_notes y y
449 '
450
451 test_expect_success 'merge z into y with "ours" per-ref configuration option => Non-conflicting 3-way merge' '
452 git -c notes.y.mergeStrategy="ours" notes merge z &&
453 verify_notes y ours
454 '
455
456 test_expect_success 'reset to pre-merge state (y)' '
457 git update-ref refs/notes/y refs/notes/y^1 &&
458 # Verify pre-merge state
459 verify_notes y y
460 '
461
462 cat <<EOF | sort >expect_notes_theirs
463 $(test_oid hash15c) $commit_sha15
464 $(test_oid hash14b) $commit_sha14
465 $(test_oid hash13b) $commit_sha13
466 $(test_oid hash11c) $commit_sha11
467 $(test_oid hash10a) $commit_sha10
468 $(test_oid hash08c) $commit_sha8
469 $(test_oid hash05c) $commit_sha5
470 $(test_oid hash04b) $commit_sha4
471 $(test_oid hash03b) $commit_sha3
472 $(test_oid hash02c) $commit_sha2
473 EOF
474
475 cat >expect_log_theirs <<EOF
476 $commit_sha15 15th
477 z notes on 15th commit
478
479 $commit_sha14 14th
480 y notes on 14th commit
481
482 $commit_sha13 13th
483 y notes on 13th commit
484
485 $commit_sha12 12th
486
487 $commit_sha11 11th
488 z notes on 11th commit
489
490 $commit_sha10 10th
491 x notes on 10th commit
492
493 $commit_sha9 9th
494
495 $commit_sha8 8th
496 z notes on 8th commit
497
498 $commit_sha7 7th
499
500 $commit_sha6 6th
501
502 $commit_sha5 5th
503 z notes on 5th commit
504
505 $commit_sha4 4th
506 y notes on 4th commit
507
508 $commit_sha3 3rd
509 y notes on 3rd commit
510
511 $commit_sha2 2nd
512 z notes on 2nd commit
513
514 $commit_sha1 1st
515
516 EOF
517
518 test_expect_success 'merge z into y with "theirs" strategy => Non-conflicting 3-way merge' '
519 git notes merge --strategy=theirs z &&
520 verify_notes y theirs
521 '
522
523 test_expect_success 'reset to pre-merge state (y)' '
524 git update-ref refs/notes/y refs/notes/y^1 &&
525 # Verify pre-merge state
526 verify_notes y y
527 '
528
529 test_expect_success 'merge z into y with "theirs" strategy overriding configuration option "ours" => Non-conflicting 3-way merge' '
530 git -c notes.mergeStrategy="ours" notes merge --strategy=theirs z &&
531 verify_notes y theirs
532 '
533
534 test_expect_success 'reset to pre-merge state (y)' '
535 git update-ref refs/notes/y refs/notes/y^1 &&
536 # Verify pre-merge state
537 verify_notes y y
538 '
539
540 cat <<EOF | sort >expect_notes_union
541 $(test_oid hash15d) $commit_sha15
542 $(test_oid hash14b) $commit_sha14
543 $(test_oid hash13b) $commit_sha13
544 $(test_oid hash12b) $commit_sha12
545 $(test_oid hash11c) $commit_sha11
546 $(test_oid hash10a) $commit_sha10
547 $(test_oid hash08c) $commit_sha8
548 $(test_oid hash05d) $commit_sha5
549 $(test_oid hash04b) $commit_sha4
550 $(test_oid hash03b) $commit_sha3
551 $(test_oid hash02c) $commit_sha2
552 EOF
553
554 cat >expect_log_union <<EOF
555 $commit_sha15 15th
556 y notes on 15th commit
557
558 z notes on 15th commit
559
560 $commit_sha14 14th
561 y notes on 14th commit
562
563 $commit_sha13 13th
564 y notes on 13th commit
565
566 $commit_sha12 12th
567 y notes on 12th commit
568
569 $commit_sha11 11th
570 z notes on 11th commit
571
572 $commit_sha10 10th
573 x notes on 10th commit
574
575 $commit_sha9 9th
576
577 $commit_sha8 8th
578 z notes on 8th commit
579
580 $commit_sha7 7th
581
582 $commit_sha6 6th
583
584 $commit_sha5 5th
585 y notes on 5th commit
586
587 z notes on 5th commit
588
589 $commit_sha4 4th
590 y notes on 4th commit
591
592 $commit_sha3 3rd
593 y notes on 3rd commit
594
595 $commit_sha2 2nd
596 z notes on 2nd commit
597
598 $commit_sha1 1st
599
600 EOF
601
602 test_expect_success 'merge z into y with "union" strategy => Non-conflicting 3-way merge' '
603 git notes merge --strategy=union z &&
604 verify_notes y union
605 '
606
607 test_expect_success 'reset to pre-merge state (y)' '
608 git update-ref refs/notes/y refs/notes/y^1 &&
609 # Verify pre-merge state
610 verify_notes y y
611 '
612
613 test_expect_success 'merge z into y with "union" strategy overriding per-ref configuration => Non-conflicting 3-way merge' '
614 git -c notes.y.mergeStrategy="theirs" notes merge --strategy=union z &&
615 verify_notes y union
616 '
617
618 test_expect_success 'reset to pre-merge state (y)' '
619 git update-ref refs/notes/y refs/notes/y^1 &&
620 # Verify pre-merge state
621 verify_notes y y
622 '
623
624 test_expect_success 'merge z into y with "union" per-ref overriding general configuration => Non-conflicting 3-way merge' '
625 git -c notes.y.mergeStrategy="union" -c notes.mergeStrategy="theirs" notes merge z &&
626 verify_notes y union
627 '
628
629 test_expect_success 'reset to pre-merge state (y)' '
630 git update-ref refs/notes/y refs/notes/y^1 &&
631 # Verify pre-merge state
632 verify_notes y y
633 '
634
635 test_expect_success 'merge z into y with "manual" per-ref only checks specific ref configuration => Conflicting 3-way merge' '
636 test_must_fail git -c notes.z.mergeStrategy="union" notes merge z &&
637 git notes merge --abort &&
638 verify_notes y y
639 '
640
641 cat <<EOF | sort >expect_notes_union2
642 $(test_oid hash15e) $commit_sha15
643 $(test_oid hash14b) $commit_sha14
644 $(test_oid hash13b) $commit_sha13
645 $(test_oid hash12b) $commit_sha12
646 $(test_oid hash11c) $commit_sha11
647 $(test_oid hash10a) $commit_sha10
648 $(test_oid hash08c) $commit_sha8
649 $(test_oid hash05e) $commit_sha5
650 $(test_oid hash04b) $commit_sha4
651 $(test_oid hash03b) $commit_sha3
652 $(test_oid hash02c) $commit_sha2
653 EOF
654
655 cat >expect_log_union2 <<EOF
656 $commit_sha15 15th
657 z notes on 15th commit
658
659 y notes on 15th commit
660
661 $commit_sha14 14th
662 y notes on 14th commit
663
664 $commit_sha13 13th
665 y notes on 13th commit
666
667 $commit_sha12 12th
668 y notes on 12th commit
669
670 $commit_sha11 11th
671 z notes on 11th commit
672
673 $commit_sha10 10th
674 x notes on 10th commit
675
676 $commit_sha9 9th
677
678 $commit_sha8 8th
679 z notes on 8th commit
680
681 $commit_sha7 7th
682
683 $commit_sha6 6th
684
685 $commit_sha5 5th
686 z notes on 5th commit
687
688 y notes on 5th commit
689
690 $commit_sha4 4th
691 y notes on 4th commit
692
693 $commit_sha3 3rd
694 y notes on 3rd commit
695
696 $commit_sha2 2nd
697 z notes on 2nd commit
698
699 $commit_sha1 1st
700
701 EOF
702
703 test_expect_success 'merge y into z with "union" strategy => Non-conflicting 3-way merge' '
704 git config core.notesRef refs/notes/z &&
705 git notes merge --strategy=union y &&
706 verify_notes z union2
707 '
708
709 test_expect_success 'reset to pre-merge state (z)' '
710 git update-ref refs/notes/z refs/notes/z^1 &&
711 # Verify pre-merge state
712 verify_notes z z
713 '
714
715 cat <<EOF | sort >expect_notes_cat_sort_uniq
716 $(test_oid hash15f) $commit_sha15
717 $(test_oid hash14b) $commit_sha14
718 $(test_oid hash13b) $commit_sha13
719 $(test_oid hash12b) $commit_sha12
720 $(test_oid hash11c) $commit_sha11
721 $(test_oid hash10a) $commit_sha10
722 $(test_oid hash08c) $commit_sha8
723 $(test_oid hash05f) $commit_sha5
724 $(test_oid hash04b) $commit_sha4
725 $(test_oid hash03b) $commit_sha3
726 $(test_oid hash02c) $commit_sha2
727 EOF
728
729 cat >expect_log_cat_sort_uniq <<EOF
730 $commit_sha15 15th
731 y notes on 15th commit
732 z notes on 15th commit
733
734 $commit_sha14 14th
735 y notes on 14th commit
736
737 $commit_sha13 13th
738 y notes on 13th commit
739
740 $commit_sha12 12th
741 y notes on 12th commit
742
743 $commit_sha11 11th
744 z notes on 11th commit
745
746 $commit_sha10 10th
747 x notes on 10th commit
748
749 $commit_sha9 9th
750
751 $commit_sha8 8th
752 z notes on 8th commit
753
754 $commit_sha7 7th
755
756 $commit_sha6 6th
757
758 $commit_sha5 5th
759 y notes on 5th commit
760 z notes on 5th commit
761
762 $commit_sha4 4th
763 y notes on 4th commit
764
765 $commit_sha3 3rd
766 y notes on 3rd commit
767
768 $commit_sha2 2nd
769 z notes on 2nd commit
770
771 $commit_sha1 1st
772
773 EOF
774
775 test_expect_success 'merge y into z with "cat_sort_uniq" strategy => Non-conflicting 3-way merge' '
776 git notes merge --strategy=cat_sort_uniq y &&
777 verify_notes z cat_sort_uniq
778 '
779
780 test_expect_success 'reset to pre-merge state (z)' '
781 git update-ref refs/notes/z refs/notes/z^1 &&
782 # Verify pre-merge state
783 verify_notes z z
784 '
785
786 test_expect_success 'merge y into z with "cat_sort_uniq" strategy configuration option => Non-conflicting 3-way merge' '
787 git -c notes.mergeStrategy="cat_sort_uniq" notes merge y &&
788 verify_notes z cat_sort_uniq
789 '
790
791 test_done