reftable/reader: introduce refcounting
[git/gitster.git] / t / t3309-notes-merge-auto-resolve.sh
blobf55277f499dd57661e166bf3487c792df1cb1bf3
1 #!/bin/sh
3 # Copyright (c) 2010 Johan Herland
6 test_description='Test notes merging with auto-resolving strategies'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 # Set up a notes merge scenario with all kinds of potential conflicts
12 test_expect_success 'setup commits' '
13 test_commit 1st &&
14 test_commit 2nd &&
15 test_commit 3rd &&
16 test_commit 4th &&
17 test_commit 5th &&
18 test_commit 6th &&
19 test_commit 7th &&
20 test_commit 8th &&
21 test_commit 9th &&
22 test_commit 10th &&
23 test_commit 11th &&
24 test_commit 12th &&
25 test_commit 13th &&
26 test_commit 14th &&
27 test_commit 15th &&
29 test_oid_cache <<-EOF
30 hash15a sha1:457a85d6c814ea208550f15fcc48f804ac8dc023
31 hash14a sha1:b0c95b954301d69da2bc3723f4cb1680d355937c
32 hash13a sha1:5d30216a129eeffa97d9694ffe8c74317a560315
33 hash12a sha1:dd161bc149470fd890dd4ab52a4cbd79bbd18c36
34 hash11a sha1:7abbc45126d680336fb24294f013a7cdfa3ed545
35 hash10a sha1:b8d03e173f67f6505a76f6e00cf93440200dd9be
36 hash09a sha1:20c613c835011c48a5abe29170a2402ca6354910
37 hash08a sha1:a3daf8a1e4e5dc3409a303ad8481d57bfea7f5d6
38 hash07a sha1:897003322b53bc6ca098e9324ee508362347e734
39 hash06a sha1:11d97fdebfa5ceee540a3da07bce6fa0222bc082
40 hash15b sha1:68b8630d25516028bed862719855b3d6768d7833
41 hash14b sha1:5de7ea7ad4f47e7ff91989fb82234634730f75df
42 hash13b sha1:3a631fdb6f41b05b55d8f4baf20728ba8f6fccbc
43 hash12b sha1:a66055fa82f7a03fe0c02a6aba3287a85abf7c62
44 hash05b sha1:154508c7a0bcad82b6fe4b472bc4c26b3bf0825b
45 hash04b sha1:e2bfd06a37dd2031684a59a6e2b033e212239c78
46 hash03b sha1:5772f42408c0dd6f097a7ca2d24de0e78d1c46b1
47 hash15c sha1:9b4b2c61f0615412da3c10f98ff85b57c04ec765
48 hash11c sha1:7e3c53503a3db8dd996cb62e37c66e070b44b54d
49 hash08c sha1:851e1638784a884c7dd26c5d41f3340f6387413a
50 hash05c sha1:99fc34adfc400b95c67b013115e37e31aa9a6d23
51 hash02c sha1:283b48219aee9a4105f6cab337e789065c82c2b9
52 hash15d sha1:7c4e546efd0fe939f876beb262ece02797880b54
53 hash05d sha1:6c841cc36ea496027290967ca96bd2bef54dbb47
54 hash15e sha1:d682107b8bf7a7aea1e537a8d5cb6a12b60135f1
55 hash05e sha1:357b6ca14c7afd59b7f8b8aaaa6b8b723771135b
56 hash15f sha1:6be90240b5f54594203e25d9f2f64b7567175aee
57 hash05f sha1:660311d7f78dc53db12ac373a43fca7465381a7e
59 hash15a sha256:45b1558e5c1b75f570010fa48aaa67bb2289fcd431b34ad81cb4c8b95f4f872a
60 hash14a sha256:6e7af179ea4dd28afdc83ae6912ba0098cdeff764b26a8b750b157dd81749092
61 hash13a sha256:7353089961baf555388e1bac68c67c8ea94b08ccbd97532201cf7f6790703052
62 hash12a sha256:5863e4521689ee1879ceab3b38d39e93ab5b51ec70aaf6a96ad388fbdedfa25e
63 hash11a sha256:82a0ec0338b4ecf8b44304badf4ad38d7469dc41827f38d7ba6c42e3bae3ee98
64 hash10a sha256:e84f2564e92de9792c93b8d197262c735d7ccb1de6025cef8759af8f6c3308eb
65 hash09a sha256:4dd07764bcec696f195c0ea71ae89e174876403af1637e4642b8f4453fd23028
66 hash08a sha256:02132c4546cd88a1d0aa5854dd55da120927f7904ba16afe36fe03e91a622067
67 hash07a sha256:369baf7d00c6720efdc10273493555f943051f84a4706fb24caeb353fa4789db
68 hash06a sha256:52d32c10353583b2d96a5849b1f1f43c8018e76f3e8ef1b0d46eb5cff7cdefaf
69 hash15b sha256:345e6660b345fa174738a31a7a59423c394bdf414804e200bc510c65d971ae96
70 hash14b sha256:7653a6596021c52e405cba979eea15a729993e7102b9a61ba4667e34f0ead4a1
71 hash13b sha256:0f202a0b6b9690de2349c173dfd766a37e82744f61c14f1c389306f1d69f470b
72 hash12b sha256:eb00f219c026136ea6535b16ff8ec3efa510e6bf50098ca041e1a2a1d4b79840
73 hash05b sha256:993b2290cd0c24c27c849d99f1904f3b590f77af0f539932734ad05679ac5a2f
74 hash04b sha256:c7fba0d6104917fbf35258f40b9fa4fc697cfa992deecd1570a3b08d0a5587a9
75 hash03b sha256:7287a2d78a3766c181b08df38951d784b08b72a44f571ed6d855bd0be22c70f6
76 hash15c sha256:62316660a22bf97857dc4a16709ec4d93a224e8c9f37d661ef91751e1f4c4166
77 hash11c sha256:51c3763de9b08309370adc5036d58debb331980e73097902957c444602551daa
78 hash08c sha256:22cf1fa29599898a7218c51135d66ed85d22aad584f77db3305dedce4c3d4798
79 hash05c sha256:2508fd86db980f0508893a1c1571bdf3b2ee113dc25ddb1a3a2fb94bd6cd0d58
80 hash02c sha256:63bb527e0b4e1c8e1dd0d54dd778ca7c3718689fd6e37c473044cfbcf1cacfdb
81 hash15d sha256:667acb4e2d5f8df15e5aea4506dfd16d25bc7feca70fdb0d965a7222f983bb88
82 hash05d sha256:09e6b5a6fe666c4a027674b6611a254b7d2528cd211c6b5288d1b4db6c741dfa
83 hash15e sha256:e8cbf52f6fcadc6de3c7761e64a89e9fe38d19a03d3e28ef6ca8596d93fc4f3a
84 hash05e sha256:cdb1e19f7ba1539f95af51a57edeb88a7ecc97d3c2f52da8c4c86af308595607
85 hash15f sha256:29c14cb92da448a923963b8a43994268b19c2e57913de73f3667421fd2c0eeec
86 hash05f sha256:14a6e641b2c0a9f398ebac6b4d34afa5efea4c52d2631382f45f8f662266903b
87 EOF
90 commit_sha1=$(git rev-parse 1st^{commit})
91 commit_sha2=$(git rev-parse 2nd^{commit})
92 commit_sha3=$(git rev-parse 3rd^{commit})
93 commit_sha4=$(git rev-parse 4th^{commit})
94 commit_sha5=$(git rev-parse 5th^{commit})
95 commit_sha6=$(git rev-parse 6th^{commit})
96 commit_sha7=$(git rev-parse 7th^{commit})
97 commit_sha8=$(git rev-parse 8th^{commit})
98 commit_sha9=$(git rev-parse 9th^{commit})
99 commit_sha10=$(git rev-parse 10th^{commit})
100 commit_sha11=$(git rev-parse 11th^{commit})
101 commit_sha12=$(git rev-parse 12th^{commit})
102 commit_sha13=$(git rev-parse 13th^{commit})
103 commit_sha14=$(git rev-parse 14th^{commit})
104 commit_sha15=$(git rev-parse 15th^{commit})
106 verify_notes () {
107 notes_ref="$1"
108 suffix="$2"
109 git -c core.notesRef="refs/notes/$notes_ref" notes |
110 sort >"output_notes_$suffix" &&
111 test_cmp "expect_notes_$suffix" "output_notes_$suffix" &&
112 git -c core.notesRef="refs/notes/$notes_ref" log --format="%H %s%n%N" \
113 >"output_log_$suffix" &&
114 test_cmp "expect_log_$suffix" "output_log_$suffix"
117 test_expect_success 'setup merge base (x)' '
118 git config core.notesRef refs/notes/x &&
119 git notes add -m "x notes on 6th commit" 6th &&
120 git notes add -m "x notes on 7th commit" 7th &&
121 git notes add -m "x notes on 8th commit" 8th &&
122 git notes add -m "x notes on 9th commit" 9th &&
123 git notes add -m "x notes on 10th commit" 10th &&
124 git notes add -m "x notes on 11th commit" 11th &&
125 git notes add -m "x notes on 12th commit" 12th &&
126 git notes add -m "x notes on 13th commit" 13th &&
127 git notes add -m "x notes on 14th commit" 14th &&
128 git notes add -m "x notes on 15th commit" 15th
131 cat <<EOF | sort >expect_notes_x
132 $(test_oid hash15a) $commit_sha15
133 $(test_oid hash14a) $commit_sha14
134 $(test_oid hash13a) $commit_sha13
135 $(test_oid hash12a) $commit_sha12
136 $(test_oid hash11a) $commit_sha11
137 $(test_oid hash10a) $commit_sha10
138 $(test_oid hash09a) $commit_sha9
139 $(test_oid hash08a) $commit_sha8
140 $(test_oid hash07a) $commit_sha7
141 $(test_oid hash06a) $commit_sha6
144 cat >expect_log_x <<EOF
145 $commit_sha15 15th
146 x notes on 15th commit
148 $commit_sha14 14th
149 x notes on 14th commit
151 $commit_sha13 13th
152 x notes on 13th commit
154 $commit_sha12 12th
155 x notes on 12th commit
157 $commit_sha11 11th
158 x notes on 11th commit
160 $commit_sha10 10th
161 x notes on 10th commit
163 $commit_sha9 9th
164 x notes on 9th commit
166 $commit_sha8 8th
167 x notes on 8th commit
169 $commit_sha7 7th
170 x notes on 7th commit
172 $commit_sha6 6th
173 x notes on 6th commit
175 $commit_sha5 5th
177 $commit_sha4 4th
179 $commit_sha3 3rd
181 $commit_sha2 2nd
183 $commit_sha1 1st
187 test_expect_success 'verify state of merge base (x)' 'verify_notes x x'
189 test_expect_success 'setup local branch (y)' '
190 git update-ref refs/notes/y refs/notes/x &&
191 git config core.notesRef refs/notes/y &&
192 git notes add -f -m "y notes on 3rd commit" 3rd &&
193 git notes add -f -m "y notes on 4th commit" 4th &&
194 git notes add -f -m "y notes on 5th commit" 5th &&
195 git notes remove 6th &&
196 git notes remove 7th &&
197 git notes remove 8th &&
198 git notes add -f -m "y notes on 12th commit" 12th &&
199 git notes add -f -m "y notes on 13th commit" 13th &&
200 git notes add -f -m "y notes on 14th commit" 14th &&
201 git notes add -f -m "y notes on 15th commit" 15th
204 cat <<EOF | sort >expect_notes_y
205 $(test_oid hash15b) $commit_sha15
206 $(test_oid hash14b) $commit_sha14
207 $(test_oid hash13b) $commit_sha13
208 $(test_oid hash12b) $commit_sha12
209 $(test_oid hash11a) $commit_sha11
210 $(test_oid hash10a) $commit_sha10
211 $(test_oid hash09a) $commit_sha9
212 $(test_oid hash05b) $commit_sha5
213 $(test_oid hash04b) $commit_sha4
214 $(test_oid hash03b) $commit_sha3
217 cat >expect_log_y <<EOF
218 $commit_sha15 15th
219 y notes on 15th commit
221 $commit_sha14 14th
222 y notes on 14th commit
224 $commit_sha13 13th
225 y notes on 13th commit
227 $commit_sha12 12th
228 y notes on 12th commit
230 $commit_sha11 11th
231 x notes on 11th commit
233 $commit_sha10 10th
234 x notes on 10th commit
236 $commit_sha9 9th
237 x notes on 9th commit
239 $commit_sha8 8th
241 $commit_sha7 7th
243 $commit_sha6 6th
245 $commit_sha5 5th
246 y notes on 5th commit
248 $commit_sha4 4th
249 y notes on 4th commit
251 $commit_sha3 3rd
252 y notes on 3rd commit
254 $commit_sha2 2nd
256 $commit_sha1 1st
260 test_expect_success 'verify state of local branch (y)' 'verify_notes y y'
262 test_expect_success 'setup remote branch (z)' '
263 git update-ref refs/notes/z refs/notes/x &&
264 git config core.notesRef refs/notes/z &&
265 git notes add -f -m "z notes on 2nd commit" 2nd &&
266 git notes add -f -m "y notes on 4th commit" 4th &&
267 git notes add -f -m "z notes on 5th commit" 5th &&
268 git notes remove 6th &&
269 git notes add -f -m "z notes on 8th commit" 8th &&
270 git notes remove 9th &&
271 git notes add -f -m "z notes on 11th commit" 11th &&
272 git notes remove 12th &&
273 git notes add -f -m "y notes on 14th commit" 14th &&
274 git notes add -f -m "z notes on 15th commit" 15th
277 cat <<EOF | sort >expect_notes_z
278 $(test_oid hash15c) $commit_sha15
279 $(test_oid hash14b) $commit_sha14
280 $(test_oid hash13a) $commit_sha13
281 $(test_oid hash11c) $commit_sha11
282 $(test_oid hash10a) $commit_sha10
283 $(test_oid hash08c) $commit_sha8
284 $(test_oid hash07a) $commit_sha7
285 $(test_oid hash05c) $commit_sha5
286 $(test_oid hash04b) $commit_sha4
287 $(test_oid hash02c) $commit_sha2
290 cat >expect_log_z <<EOF
291 $commit_sha15 15th
292 z notes on 15th commit
294 $commit_sha14 14th
295 y notes on 14th commit
297 $commit_sha13 13th
298 x notes on 13th commit
300 $commit_sha12 12th
302 $commit_sha11 11th
303 z notes on 11th commit
305 $commit_sha10 10th
306 x notes on 10th commit
308 $commit_sha9 9th
310 $commit_sha8 8th
311 z notes on 8th commit
313 $commit_sha7 7th
314 x notes on 7th commit
316 $commit_sha6 6th
318 $commit_sha5 5th
319 z notes on 5th commit
321 $commit_sha4 4th
322 y notes on 4th commit
324 $commit_sha3 3rd
326 $commit_sha2 2nd
327 z notes on 2nd commit
329 $commit_sha1 1st
333 test_expect_success 'verify state of remote branch (z)' 'verify_notes z z'
335 # At this point, before merging z into y, we have the following status:
337 # commit | base/x | local/y | remote/z | diff from x to y/z | result
338 # -------|---------|---------|----------|----------------------------|-------
339 # 1st | [none] | [none] | [none] | unchanged / unchanged | [none]
340 # 2nd | [none] | [none] | 283b482 | unchanged / added | 283b482
341 # 3rd | [none] | 5772f42 | [none] | added / unchanged | 5772f42
342 # 4th | [none] | e2bfd06 | e2bfd06 | added / added (same) | e2bfd06
343 # 5th | [none] | 154508c | 99fc34a | added / added (diff) | ???
344 # 6th | 11d97fd | [none] | [none] | removed / removed | [none]
345 # 7th | 8970033 | [none] | 8970033 | removed / unchanged | [none]
346 # 8th | a3daf8a | [none] | 851e163 | removed / changed | ???
347 # 9th | 20c613c | 20c613c | [none] | unchanged / removed | [none]
348 # 10th | b8d03e1 | b8d03e1 | b8d03e1 | unchanged / unchanged | b8d03e1
349 # 11th | 7abbc45 | 7abbc45 | 7e3c535 | unchanged / changed | 7e3c535
350 # 12th | dd161bc | a66055f | [none] | changed / removed | ???
351 # 13th | 5d30216 | 3a631fd | 5d30216 | changed / unchanged | 3a631fd
352 # 14th | b0c95b9 | 5de7ea7 | 5de7ea7 | changed / changed (same) | 5de7ea7
353 # 15th | 457a85d | 68b8630 | 9b4b2c6 | changed / changed (diff) | ???
355 test_expect_success 'merge z into y with invalid strategy => Fail/No changes' '
356 git config core.notesRef refs/notes/y &&
357 test_must_fail git notes merge --strategy=foo z &&
358 # Verify no changes (y)
359 verify_notes y y
362 test_expect_success 'merge z into y with invalid configuration option => Fail/No changes' '
363 git config core.notesRef refs/notes/y &&
364 cat >expect <<-\EOF &&
365 error: unknown notes merge strategy foo
366 fatal: unable to parse '\''notes.mergeStrategy'\'' from command-line config
368 test_must_fail git -c notes.mergeStrategy="foo" notes merge z 2>actual &&
369 test_cmp expect actual &&
370 # Verify no changes (y)
371 verify_notes y y
374 cat <<EOF | sort >expect_notes_ours
375 $(test_oid hash15b) $commit_sha15
376 $(test_oid hash14b) $commit_sha14
377 $(test_oid hash13b) $commit_sha13
378 $(test_oid hash12b) $commit_sha12
379 $(test_oid hash11c) $commit_sha11
380 $(test_oid hash10a) $commit_sha10
381 $(test_oid hash05b) $commit_sha5
382 $(test_oid hash04b) $commit_sha4
383 $(test_oid hash03b) $commit_sha3
384 $(test_oid hash02c) $commit_sha2
387 cat >expect_log_ours <<EOF
388 $commit_sha15 15th
389 y notes on 15th commit
391 $commit_sha14 14th
392 y notes on 14th commit
394 $commit_sha13 13th
395 y notes on 13th commit
397 $commit_sha12 12th
398 y notes on 12th commit
400 $commit_sha11 11th
401 z notes on 11th commit
403 $commit_sha10 10th
404 x notes on 10th commit
406 $commit_sha9 9th
408 $commit_sha8 8th
410 $commit_sha7 7th
412 $commit_sha6 6th
414 $commit_sha5 5th
415 y notes on 5th commit
417 $commit_sha4 4th
418 y notes on 4th commit
420 $commit_sha3 3rd
421 y notes on 3rd commit
423 $commit_sha2 2nd
424 z notes on 2nd commit
426 $commit_sha1 1st
430 test_expect_success 'merge z into y with "ours" strategy => Non-conflicting 3-way merge' '
431 git notes merge --strategy=ours z &&
432 verify_notes y ours
435 test_expect_success 'reset to pre-merge state (y)' '
436 git update-ref refs/notes/y refs/notes/y^1 &&
437 # Verify pre-merge state
438 verify_notes y y
441 test_expect_success 'merge z into y with "ours" configuration option => Non-conflicting 3-way merge' '
442 git -c notes.mergeStrategy="ours" notes merge z &&
443 verify_notes y ours
446 test_expect_success 'reset to pre-merge state (y)' '
447 git update-ref refs/notes/y refs/notes/y^1 &&
448 # Verify pre-merge state
449 verify_notes y y
452 test_expect_success 'merge z into y with "ours" per-ref configuration option => Non-conflicting 3-way merge' '
453 git -c notes.y.mergeStrategy="ours" notes merge z &&
454 verify_notes y ours
457 test_expect_success 'reset to pre-merge state (y)' '
458 git update-ref refs/notes/y refs/notes/y^1 &&
459 # Verify pre-merge state
460 verify_notes y y
463 cat <<EOF | sort >expect_notes_theirs
464 $(test_oid hash15c) $commit_sha15
465 $(test_oid hash14b) $commit_sha14
466 $(test_oid hash13b) $commit_sha13
467 $(test_oid hash11c) $commit_sha11
468 $(test_oid hash10a) $commit_sha10
469 $(test_oid hash08c) $commit_sha8
470 $(test_oid hash05c) $commit_sha5
471 $(test_oid hash04b) $commit_sha4
472 $(test_oid hash03b) $commit_sha3
473 $(test_oid hash02c) $commit_sha2
476 cat >expect_log_theirs <<EOF
477 $commit_sha15 15th
478 z notes on 15th commit
480 $commit_sha14 14th
481 y notes on 14th commit
483 $commit_sha13 13th
484 y notes on 13th commit
486 $commit_sha12 12th
488 $commit_sha11 11th
489 z notes on 11th commit
491 $commit_sha10 10th
492 x notes on 10th commit
494 $commit_sha9 9th
496 $commit_sha8 8th
497 z notes on 8th commit
499 $commit_sha7 7th
501 $commit_sha6 6th
503 $commit_sha5 5th
504 z notes on 5th commit
506 $commit_sha4 4th
507 y notes on 4th commit
509 $commit_sha3 3rd
510 y notes on 3rd commit
512 $commit_sha2 2nd
513 z notes on 2nd commit
515 $commit_sha1 1st
519 test_expect_success 'merge z into y with "theirs" strategy => Non-conflicting 3-way merge' '
520 git notes merge --strategy=theirs z &&
521 verify_notes y theirs
524 test_expect_success 'reset to pre-merge state (y)' '
525 git update-ref refs/notes/y refs/notes/y^1 &&
526 # Verify pre-merge state
527 verify_notes y y
530 test_expect_success 'merge z into y with "theirs" strategy overriding configuration option "ours" => Non-conflicting 3-way merge' '
531 git -c notes.mergeStrategy="ours" notes merge --strategy=theirs z &&
532 verify_notes y theirs
535 test_expect_success 'reset to pre-merge state (y)' '
536 git update-ref refs/notes/y refs/notes/y^1 &&
537 # Verify pre-merge state
538 verify_notes y y
541 cat <<EOF | sort >expect_notes_union
542 $(test_oid hash15d) $commit_sha15
543 $(test_oid hash14b) $commit_sha14
544 $(test_oid hash13b) $commit_sha13
545 $(test_oid hash12b) $commit_sha12
546 $(test_oid hash11c) $commit_sha11
547 $(test_oid hash10a) $commit_sha10
548 $(test_oid hash08c) $commit_sha8
549 $(test_oid hash05d) $commit_sha5
550 $(test_oid hash04b) $commit_sha4
551 $(test_oid hash03b) $commit_sha3
552 $(test_oid hash02c) $commit_sha2
555 cat >expect_log_union <<EOF
556 $commit_sha15 15th
557 y notes on 15th commit
559 z notes on 15th commit
561 $commit_sha14 14th
562 y notes on 14th commit
564 $commit_sha13 13th
565 y notes on 13th commit
567 $commit_sha12 12th
568 y notes on 12th commit
570 $commit_sha11 11th
571 z notes on 11th commit
573 $commit_sha10 10th
574 x notes on 10th commit
576 $commit_sha9 9th
578 $commit_sha8 8th
579 z notes on 8th commit
581 $commit_sha7 7th
583 $commit_sha6 6th
585 $commit_sha5 5th
586 y notes on 5th commit
588 z notes on 5th commit
590 $commit_sha4 4th
591 y notes on 4th commit
593 $commit_sha3 3rd
594 y notes on 3rd commit
596 $commit_sha2 2nd
597 z notes on 2nd commit
599 $commit_sha1 1st
603 test_expect_success 'merge z into y with "union" strategy => Non-conflicting 3-way merge' '
604 git notes merge --strategy=union z &&
605 verify_notes y union
608 test_expect_success 'reset to pre-merge state (y)' '
609 git update-ref refs/notes/y refs/notes/y^1 &&
610 # Verify pre-merge state
611 verify_notes y y
614 test_expect_success 'merge z into y with "union" strategy overriding per-ref configuration => Non-conflicting 3-way merge' '
615 git -c notes.y.mergeStrategy="theirs" notes merge --strategy=union z &&
616 verify_notes y union
619 test_expect_success 'reset to pre-merge state (y)' '
620 git update-ref refs/notes/y refs/notes/y^1 &&
621 # Verify pre-merge state
622 verify_notes y y
625 test_expect_success 'merge z into y with "union" per-ref overriding general configuration => Non-conflicting 3-way merge' '
626 git -c notes.y.mergeStrategy="union" -c notes.mergeStrategy="theirs" notes merge z &&
627 verify_notes y union
630 test_expect_success 'reset to pre-merge state (y)' '
631 git update-ref refs/notes/y refs/notes/y^1 &&
632 # Verify pre-merge state
633 verify_notes y y
636 test_expect_success 'merge z into y with "manual" per-ref only checks specific ref configuration => Conflicting 3-way merge' '
637 test_must_fail git -c notes.z.mergeStrategy="union" notes merge z &&
638 git notes merge --abort &&
639 verify_notes y y
642 cat <<EOF | sort >expect_notes_union2
643 $(test_oid hash15e) $commit_sha15
644 $(test_oid hash14b) $commit_sha14
645 $(test_oid hash13b) $commit_sha13
646 $(test_oid hash12b) $commit_sha12
647 $(test_oid hash11c) $commit_sha11
648 $(test_oid hash10a) $commit_sha10
649 $(test_oid hash08c) $commit_sha8
650 $(test_oid hash05e) $commit_sha5
651 $(test_oid hash04b) $commit_sha4
652 $(test_oid hash03b) $commit_sha3
653 $(test_oid hash02c) $commit_sha2
656 cat >expect_log_union2 <<EOF
657 $commit_sha15 15th
658 z notes on 15th commit
660 y notes on 15th commit
662 $commit_sha14 14th
663 y notes on 14th commit
665 $commit_sha13 13th
666 y notes on 13th commit
668 $commit_sha12 12th
669 y notes on 12th commit
671 $commit_sha11 11th
672 z notes on 11th commit
674 $commit_sha10 10th
675 x notes on 10th commit
677 $commit_sha9 9th
679 $commit_sha8 8th
680 z notes on 8th commit
682 $commit_sha7 7th
684 $commit_sha6 6th
686 $commit_sha5 5th
687 z notes on 5th commit
689 y notes on 5th commit
691 $commit_sha4 4th
692 y notes on 4th commit
694 $commit_sha3 3rd
695 y notes on 3rd commit
697 $commit_sha2 2nd
698 z notes on 2nd commit
700 $commit_sha1 1st
704 test_expect_success 'merge y into z with "union" strategy => Non-conflicting 3-way merge' '
705 git config core.notesRef refs/notes/z &&
706 git notes merge --strategy=union y &&
707 verify_notes z union2
710 test_expect_success 'reset to pre-merge state (z)' '
711 git update-ref refs/notes/z refs/notes/z^1 &&
712 # Verify pre-merge state
713 verify_notes z z
716 cat <<EOF | sort >expect_notes_cat_sort_uniq
717 $(test_oid hash15f) $commit_sha15
718 $(test_oid hash14b) $commit_sha14
719 $(test_oid hash13b) $commit_sha13
720 $(test_oid hash12b) $commit_sha12
721 $(test_oid hash11c) $commit_sha11
722 $(test_oid hash10a) $commit_sha10
723 $(test_oid hash08c) $commit_sha8
724 $(test_oid hash05f) $commit_sha5
725 $(test_oid hash04b) $commit_sha4
726 $(test_oid hash03b) $commit_sha3
727 $(test_oid hash02c) $commit_sha2
730 cat >expect_log_cat_sort_uniq <<EOF
731 $commit_sha15 15th
732 y notes on 15th commit
733 z notes on 15th commit
735 $commit_sha14 14th
736 y notes on 14th commit
738 $commit_sha13 13th
739 y notes on 13th commit
741 $commit_sha12 12th
742 y notes on 12th commit
744 $commit_sha11 11th
745 z notes on 11th commit
747 $commit_sha10 10th
748 x notes on 10th commit
750 $commit_sha9 9th
752 $commit_sha8 8th
753 z notes on 8th commit
755 $commit_sha7 7th
757 $commit_sha6 6th
759 $commit_sha5 5th
760 y notes on 5th commit
761 z notes on 5th commit
763 $commit_sha4 4th
764 y notes on 4th commit
766 $commit_sha3 3rd
767 y notes on 3rd commit
769 $commit_sha2 2nd
770 z notes on 2nd commit
772 $commit_sha1 1st
776 test_expect_success 'merge y into z with "cat_sort_uniq" strategy => Non-conflicting 3-way merge' '
777 git notes merge --strategy=cat_sort_uniq y &&
778 verify_notes z cat_sort_uniq
781 test_expect_success 'reset to pre-merge state (z)' '
782 git update-ref refs/notes/z refs/notes/z^1 &&
783 # Verify pre-merge state
784 verify_notes z z
787 test_expect_success 'merge y into z with "cat_sort_uniq" strategy configuration option => Non-conflicting 3-way merge' '
788 git -c notes.mergeStrategy="cat_sort_uniq" notes merge y &&
789 verify_notes z cat_sort_uniq
792 test_done