t / t3309-notes-merge-auto-resolve.shon commit t7610-mergetool: use test_cmp instead of test $(cat file) = $txt (e10dffd)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Johan Herland
   4#
   5
   6test_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
  11test_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
  29commit_sha1=$(git rev-parse 1st^{commit})
  30commit_sha2=$(git rev-parse 2nd^{commit})
  31commit_sha3=$(git rev-parse 3rd^{commit})
  32commit_sha4=$(git rev-parse 4th^{commit})
  33commit_sha5=$(git rev-parse 5th^{commit})
  34commit_sha6=$(git rev-parse 6th^{commit})
  35commit_sha7=$(git rev-parse 7th^{commit})
  36commit_sha8=$(git rev-parse 8th^{commit})
  37commit_sha9=$(git rev-parse 9th^{commit})
  38commit_sha10=$(git rev-parse 10th^{commit})
  39commit_sha11=$(git rev-parse 11th^{commit})
  40commit_sha12=$(git rev-parse 12th^{commit})
  41commit_sha13=$(git rev-parse 13th^{commit})
  42commit_sha14=$(git rev-parse 14th^{commit})
  43commit_sha15=$(git rev-parse 15th^{commit})
  44
  45verify_notes () {
  46        notes_ref="$1"
  47        suffix="$2"
  48        git -c core.notesRef="refs/notes/$notes_ref" notes |
  49                sort >"output_notes_$suffix" &&
  50        test_cmp "expect_notes_$suffix" "output_notes_$suffix" &&
  51        git -c core.notesRef="refs/notes/$notes_ref" log --format="%H %s%n%N" \
  52                >"output_log_$suffix" &&
  53        test_cmp "expect_log_$suffix" "output_log_$suffix"
  54}
  55
  56test_expect_success 'setup merge base (x)' '
  57        git config core.notesRef refs/notes/x &&
  58        git notes add -m "x notes on 6th commit" 6th &&
  59        git notes add -m "x notes on 7th commit" 7th &&
  60        git notes add -m "x notes on 8th commit" 8th &&
  61        git notes add -m "x notes on 9th commit" 9th &&
  62        git notes add -m "x notes on 10th commit" 10th &&
  63        git notes add -m "x notes on 11th commit" 11th &&
  64        git notes add -m "x notes on 12th commit" 12th &&
  65        git notes add -m "x notes on 13th commit" 13th &&
  66        git notes add -m "x notes on 14th commit" 14th &&
  67        git notes add -m "x notes on 15th commit" 15th
  68'
  69
  70cat <<EOF | sort >expect_notes_x
  71457a85d6c814ea208550f15fcc48f804ac8dc023 $commit_sha15
  72b0c95b954301d69da2bc3723f4cb1680d355937c $commit_sha14
  735d30216a129eeffa97d9694ffe8c74317a560315 $commit_sha13
  74dd161bc149470fd890dd4ab52a4cbd79bbd18c36 $commit_sha12
  757abbc45126d680336fb24294f013a7cdfa3ed545 $commit_sha11
  76b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
  7720c613c835011c48a5abe29170a2402ca6354910 $commit_sha9
  78a3daf8a1e4e5dc3409a303ad8481d57bfea7f5d6 $commit_sha8
  79897003322b53bc6ca098e9324ee508362347e734 $commit_sha7
  8011d97fdebfa5ceee540a3da07bce6fa0222bc082 $commit_sha6
  81EOF
  82
  83cat >expect_log_x <<EOF
  84$commit_sha15 15th
  85x notes on 15th commit
  86
  87$commit_sha14 14th
  88x notes on 14th commit
  89
  90$commit_sha13 13th
  91x notes on 13th commit
  92
  93$commit_sha12 12th
  94x notes on 12th commit
  95
  96$commit_sha11 11th
  97x notes on 11th commit
  98
  99$commit_sha10 10th
 100x notes on 10th commit
 101
 102$commit_sha9 9th
 103x notes on 9th commit
 104
 105$commit_sha8 8th
 106x notes on 8th commit
 107
 108$commit_sha7 7th
 109x notes on 7th commit
 110
 111$commit_sha6 6th
 112x notes on 6th commit
 113
 114$commit_sha5 5th
 115
 116$commit_sha4 4th
 117
 118$commit_sha3 3rd
 119
 120$commit_sha2 2nd
 121
 122$commit_sha1 1st
 123
 124EOF
 125
 126test_expect_success 'verify state of merge base (x)' 'verify_notes x x'
 127
 128test_expect_success 'setup local branch (y)' '
 129        git update-ref refs/notes/y refs/notes/x &&
 130        git config core.notesRef refs/notes/y &&
 131        git notes add -f -m "y notes on 3rd commit" 3rd &&
 132        git notes add -f -m "y notes on 4th commit" 4th &&
 133        git notes add -f -m "y notes on 5th commit" 5th &&
 134        git notes remove 6th &&
 135        git notes remove 7th &&
 136        git notes remove 8th &&
 137        git notes add -f -m "y notes on 12th commit" 12th &&
 138        git notes add -f -m "y notes on 13th commit" 13th &&
 139        git notes add -f -m "y notes on 14th commit" 14th &&
 140        git notes add -f -m "y notes on 15th commit" 15th
 141'
 142
 143cat <<EOF | sort >expect_notes_y
 14468b8630d25516028bed862719855b3d6768d7833 $commit_sha15
 1455de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 1463a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13
 147a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12
 1487abbc45126d680336fb24294f013a7cdfa3ed545 $commit_sha11
 149b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 15020c613c835011c48a5abe29170a2402ca6354910 $commit_sha9
 151154508c7a0bcad82b6fe4b472bc4c26b3bf0825b $commit_sha5
 152e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 1535772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3
 154EOF
 155
 156cat >expect_log_y <<EOF
 157$commit_sha15 15th
 158y notes on 15th commit
 159
 160$commit_sha14 14th
 161y notes on 14th commit
 162
 163$commit_sha13 13th
 164y notes on 13th commit
 165
 166$commit_sha12 12th
 167y notes on 12th commit
 168
 169$commit_sha11 11th
 170x notes on 11th commit
 171
 172$commit_sha10 10th
 173x notes on 10th commit
 174
 175$commit_sha9 9th
 176x notes on 9th commit
 177
 178$commit_sha8 8th
 179
 180$commit_sha7 7th
 181
 182$commit_sha6 6th
 183
 184$commit_sha5 5th
 185y notes on 5th commit
 186
 187$commit_sha4 4th
 188y notes on 4th commit
 189
 190$commit_sha3 3rd
 191y notes on 3rd commit
 192
 193$commit_sha2 2nd
 194
 195$commit_sha1 1st
 196
 197EOF
 198
 199test_expect_success 'verify state of local branch (y)' 'verify_notes y y'
 200
 201test_expect_success 'setup remote branch (z)' '
 202        git update-ref refs/notes/z refs/notes/x &&
 203        git config core.notesRef refs/notes/z &&
 204        git notes add -f -m "z notes on 2nd commit" 2nd &&
 205        git notes add -f -m "y notes on 4th commit" 4th &&
 206        git notes add -f -m "z notes on 5th commit" 5th &&
 207        git notes remove 6th &&
 208        git notes add -f -m "z notes on 8th commit" 8th &&
 209        git notes remove 9th &&
 210        git notes add -f -m "z notes on 11th commit" 11th &&
 211        git notes remove 12th &&
 212        git notes add -f -m "y notes on 14th commit" 14th &&
 213        git notes add -f -m "z notes on 15th commit" 15th
 214'
 215
 216cat <<EOF | sort >expect_notes_z
 2179b4b2c61f0615412da3c10f98ff85b57c04ec765 $commit_sha15
 2185de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 2195d30216a129eeffa97d9694ffe8c74317a560315 $commit_sha13
 2207e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11
 221b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 222851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8
 223897003322b53bc6ca098e9324ee508362347e734 $commit_sha7
 22499fc34adfc400b95c67b013115e37e31aa9a6d23 $commit_sha5
 225e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 226283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2
 227EOF
 228
 229cat >expect_log_z <<EOF
 230$commit_sha15 15th
 231z notes on 15th commit
 232
 233$commit_sha14 14th
 234y notes on 14th commit
 235
 236$commit_sha13 13th
 237x notes on 13th commit
 238
 239$commit_sha12 12th
 240
 241$commit_sha11 11th
 242z notes on 11th commit
 243
 244$commit_sha10 10th
 245x notes on 10th commit
 246
 247$commit_sha9 9th
 248
 249$commit_sha8 8th
 250z notes on 8th commit
 251
 252$commit_sha7 7th
 253x notes on 7th commit
 254
 255$commit_sha6 6th
 256
 257$commit_sha5 5th
 258z notes on 5th commit
 259
 260$commit_sha4 4th
 261y notes on 4th commit
 262
 263$commit_sha3 3rd
 264
 265$commit_sha2 2nd
 266z notes on 2nd commit
 267
 268$commit_sha1 1st
 269
 270EOF
 271
 272test_expect_success 'verify state of remote branch (z)' 'verify_notes z z'
 273
 274# At this point, before merging z into y, we have the following status:
 275#
 276# commit | base/x  | local/y | remote/z | diff from x to y/z         | result
 277# -------|---------|---------|----------|----------------------------|-------
 278# 1st    | [none]  | [none]  | [none]   | unchanged / unchanged      | [none]
 279# 2nd    | [none]  | [none]  | 283b482  | unchanged / added          | 283b482
 280# 3rd    | [none]  | 5772f42 | [none]   | added     / unchanged      | 5772f42
 281# 4th    | [none]  | e2bfd06 | e2bfd06  | added     / added (same)   | e2bfd06
 282# 5th    | [none]  | 154508c | 99fc34a  | added     / added (diff)   | ???
 283# 6th    | 11d97fd | [none]  | [none]   | removed   / removed        | [none]
 284# 7th    | 8970033 | [none]  | 8970033  | removed   / unchanged      | [none]
 285# 8th    | a3daf8a | [none]  | 851e163  | removed   / changed        | ???
 286# 9th    | 20c613c | 20c613c | [none]   | unchanged / removed        | [none]
 287# 10th   | b8d03e1 | b8d03e1 | b8d03e1  | unchanged / unchanged      | b8d03e1
 288# 11th   | 7abbc45 | 7abbc45 | 7e3c535  | unchanged / changed        | 7e3c535
 289# 12th   | dd161bc | a66055f | [none]   | changed   / removed        | ???
 290# 13th   | 5d30216 | 3a631fd | 5d30216  | changed   / unchanged      | 3a631fd
 291# 14th   | b0c95b9 | 5de7ea7 | 5de7ea7  | changed   / changed (same) | 5de7ea7
 292# 15th   | 457a85d | 68b8630 | 9b4b2c6  | changed   / changed (diff) | ???
 293
 294test_expect_success 'merge z into y with invalid strategy => Fail/No changes' '
 295        git config core.notesRef refs/notes/y &&
 296        test_must_fail git notes merge --strategy=foo z &&
 297        # Verify no changes (y)
 298        verify_notes y y
 299'
 300
 301test_expect_success 'merge z into y with invalid configuration option => Fail/No changes' '
 302        git config core.notesRef refs/notes/y &&
 303        test_must_fail git -c notes.mergeStrategy="foo" notes merge z &&
 304        # Verify no changes (y)
 305        verify_notes y y
 306'
 307
 308cat <<EOF | sort >expect_notes_ours
 30968b8630d25516028bed862719855b3d6768d7833 $commit_sha15
 3105de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 3113a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13
 312a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12
 3137e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11
 314b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 315154508c7a0bcad82b6fe4b472bc4c26b3bf0825b $commit_sha5
 316e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 3175772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3
 318283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2
 319EOF
 320
 321cat >expect_log_ours <<EOF
 322$commit_sha15 15th
 323y notes on 15th commit
 324
 325$commit_sha14 14th
 326y notes on 14th commit
 327
 328$commit_sha13 13th
 329y notes on 13th commit
 330
 331$commit_sha12 12th
 332y notes on 12th commit
 333
 334$commit_sha11 11th
 335z notes on 11th commit
 336
 337$commit_sha10 10th
 338x notes on 10th commit
 339
 340$commit_sha9 9th
 341
 342$commit_sha8 8th
 343
 344$commit_sha7 7th
 345
 346$commit_sha6 6th
 347
 348$commit_sha5 5th
 349y notes on 5th commit
 350
 351$commit_sha4 4th
 352y notes on 4th commit
 353
 354$commit_sha3 3rd
 355y notes on 3rd commit
 356
 357$commit_sha2 2nd
 358z notes on 2nd commit
 359
 360$commit_sha1 1st
 361
 362EOF
 363
 364test_expect_success 'merge z into y with "ours" strategy => Non-conflicting 3-way merge' '
 365        git notes merge --strategy=ours z &&
 366        verify_notes y ours
 367'
 368
 369test_expect_success 'reset to pre-merge state (y)' '
 370        git update-ref refs/notes/y refs/notes/y^1 &&
 371        # Verify pre-merge state
 372        verify_notes y y
 373'
 374
 375test_expect_success 'merge z into y with "ours" configuration option => Non-conflicting 3-way merge' '
 376        git -c notes.mergeStrategy="ours" notes merge z &&
 377        verify_notes y ours
 378'
 379
 380test_expect_success 'reset to pre-merge state (y)' '
 381        git update-ref refs/notes/y refs/notes/y^1 &&
 382        # Verify pre-merge state
 383        verify_notes y y
 384'
 385
 386test_expect_success 'merge z into y with "ours" per-ref configuration option => Non-conflicting 3-way merge' '
 387        git -c notes.y.mergeStrategy="ours" notes merge z &&
 388        verify_notes y ours
 389'
 390
 391test_expect_success 'reset to pre-merge state (y)' '
 392        git update-ref refs/notes/y refs/notes/y^1 &&
 393        # Verify pre-merge state
 394        verify_notes y y
 395'
 396
 397cat <<EOF | sort >expect_notes_theirs
 3989b4b2c61f0615412da3c10f98ff85b57c04ec765 $commit_sha15
 3995de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 4003a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13
 4017e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11
 402b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 403851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8
 40499fc34adfc400b95c67b013115e37e31aa9a6d23 $commit_sha5
 405e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 4065772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3
 407283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2
 408EOF
 409
 410cat >expect_log_theirs <<EOF
 411$commit_sha15 15th
 412z notes on 15th commit
 413
 414$commit_sha14 14th
 415y notes on 14th commit
 416
 417$commit_sha13 13th
 418y notes on 13th commit
 419
 420$commit_sha12 12th
 421
 422$commit_sha11 11th
 423z notes on 11th commit
 424
 425$commit_sha10 10th
 426x notes on 10th commit
 427
 428$commit_sha9 9th
 429
 430$commit_sha8 8th
 431z notes on 8th commit
 432
 433$commit_sha7 7th
 434
 435$commit_sha6 6th
 436
 437$commit_sha5 5th
 438z notes on 5th commit
 439
 440$commit_sha4 4th
 441y notes on 4th commit
 442
 443$commit_sha3 3rd
 444y notes on 3rd commit
 445
 446$commit_sha2 2nd
 447z notes on 2nd commit
 448
 449$commit_sha1 1st
 450
 451EOF
 452
 453test_expect_success 'merge z into y with "theirs" strategy => Non-conflicting 3-way merge' '
 454        git notes merge --strategy=theirs z &&
 455        verify_notes y theirs
 456'
 457
 458test_expect_success 'reset to pre-merge state (y)' '
 459        git update-ref refs/notes/y refs/notes/y^1 &&
 460        # Verify pre-merge state
 461        verify_notes y y
 462'
 463
 464test_expect_success 'merge z into y with "theirs" strategy overriding configuration option "ours" => Non-conflicting 3-way merge' '
 465        git -c notes.mergeStrategy="ours" notes merge --strategy=theirs z &&
 466        verify_notes y theirs
 467'
 468
 469test_expect_success 'reset to pre-merge state (y)' '
 470        git update-ref refs/notes/y refs/notes/y^1 &&
 471        # Verify pre-merge state
 472        verify_notes y y
 473'
 474
 475cat <<EOF | sort >expect_notes_union
 4767c4e546efd0fe939f876beb262ece02797880b54 $commit_sha15
 4775de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 4783a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13
 479a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12
 4807e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11
 481b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 482851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8
 4836c841cc36ea496027290967ca96bd2bef54dbb47 $commit_sha5
 484e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 4855772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3
 486283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2
 487EOF
 488
 489cat >expect_log_union <<EOF
 490$commit_sha15 15th
 491y notes on 15th commit
 492
 493z notes on 15th commit
 494
 495$commit_sha14 14th
 496y notes on 14th commit
 497
 498$commit_sha13 13th
 499y notes on 13th commit
 500
 501$commit_sha12 12th
 502y notes on 12th commit
 503
 504$commit_sha11 11th
 505z notes on 11th commit
 506
 507$commit_sha10 10th
 508x notes on 10th commit
 509
 510$commit_sha9 9th
 511
 512$commit_sha8 8th
 513z notes on 8th commit
 514
 515$commit_sha7 7th
 516
 517$commit_sha6 6th
 518
 519$commit_sha5 5th
 520y notes on 5th commit
 521
 522z notes on 5th commit
 523
 524$commit_sha4 4th
 525y notes on 4th commit
 526
 527$commit_sha3 3rd
 528y notes on 3rd commit
 529
 530$commit_sha2 2nd
 531z notes on 2nd commit
 532
 533$commit_sha1 1st
 534
 535EOF
 536
 537test_expect_success 'merge z into y with "union" strategy => Non-conflicting 3-way merge' '
 538        git notes merge --strategy=union z &&
 539        verify_notes y union
 540'
 541
 542test_expect_success 'reset to pre-merge state (y)' '
 543        git update-ref refs/notes/y refs/notes/y^1 &&
 544        # Verify pre-merge state
 545        verify_notes y y
 546'
 547
 548test_expect_success 'merge z into y with "union" strategy overriding per-ref configuration => Non-conflicting 3-way merge' '
 549        git -c notes.y.mergeStrategy="theirs" notes merge --strategy=union z &&
 550        verify_notes y union
 551'
 552
 553test_expect_success 'reset to pre-merge state (y)' '
 554        git update-ref refs/notes/y refs/notes/y^1 &&
 555        # Verify pre-merge state
 556        verify_notes y y
 557'
 558
 559test_expect_success 'merge z into y with "union" per-ref overriding general configuration => Non-conflicting 3-way merge' '
 560        git -c notes.y.mergeStrategy="union" -c notes.mergeStrategy="theirs" notes merge z &&
 561        verify_notes y union
 562'
 563
 564test_expect_success 'reset to pre-merge state (y)' '
 565        git update-ref refs/notes/y refs/notes/y^1 &&
 566        # Verify pre-merge state
 567        verify_notes y y
 568'
 569
 570test_expect_success 'merge z into y with "manual" per-ref only checks specific ref configuration => Conflicting 3-way merge' '
 571        test_must_fail git -c notes.z.mergeStrategy="union" notes merge z &&
 572        git notes merge --abort &&
 573        verify_notes y y
 574'
 575
 576cat <<EOF | sort >expect_notes_union2
 577d682107b8bf7a7aea1e537a8d5cb6a12b60135f1 $commit_sha15
 5785de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 5793a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13
 580a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12
 5817e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11
 582b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 583851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8
 584357b6ca14c7afd59b7f8b8aaaa6b8b723771135b $commit_sha5
 585e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 5865772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3
 587283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2
 588EOF
 589
 590cat >expect_log_union2 <<EOF
 591$commit_sha15 15th
 592z notes on 15th commit
 593
 594y notes on 15th commit
 595
 596$commit_sha14 14th
 597y notes on 14th commit
 598
 599$commit_sha13 13th
 600y notes on 13th commit
 601
 602$commit_sha12 12th
 603y notes on 12th commit
 604
 605$commit_sha11 11th
 606z notes on 11th commit
 607
 608$commit_sha10 10th
 609x notes on 10th commit
 610
 611$commit_sha9 9th
 612
 613$commit_sha8 8th
 614z notes on 8th commit
 615
 616$commit_sha7 7th
 617
 618$commit_sha6 6th
 619
 620$commit_sha5 5th
 621z notes on 5th commit
 622
 623y notes on 5th commit
 624
 625$commit_sha4 4th
 626y notes on 4th commit
 627
 628$commit_sha3 3rd
 629y notes on 3rd commit
 630
 631$commit_sha2 2nd
 632z notes on 2nd commit
 633
 634$commit_sha1 1st
 635
 636EOF
 637
 638test_expect_success 'merge y into z with "union" strategy => Non-conflicting 3-way merge' '
 639        git config core.notesRef refs/notes/z &&
 640        git notes merge --strategy=union y &&
 641        verify_notes z union2
 642'
 643
 644test_expect_success 'reset to pre-merge state (z)' '
 645        git update-ref refs/notes/z refs/notes/z^1 &&
 646        # Verify pre-merge state
 647        verify_notes z z
 648'
 649
 650cat <<EOF | sort >expect_notes_cat_sort_uniq
 6516be90240b5f54594203e25d9f2f64b7567175aee $commit_sha15
 6525de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
 6533a631fdb6f41b05b55d8f4baf20728ba8f6fccbc $commit_sha13
 654a66055fa82f7a03fe0c02a6aba3287a85abf7c62 $commit_sha12
 6557e3c53503a3db8dd996cb62e37c66e070b44b54d $commit_sha11
 656b8d03e173f67f6505a76f6e00cf93440200dd9be $commit_sha10
 657851e1638784a884c7dd26c5d41f3340f6387413a $commit_sha8
 658660311d7f78dc53db12ac373a43fca7465381a7e $commit_sha5
 659e2bfd06a37dd2031684a59a6e2b033e212239c78 $commit_sha4
 6605772f42408c0dd6f097a7ca2d24de0e78d1c46b1 $commit_sha3
 661283b48219aee9a4105f6cab337e789065c82c2b9 $commit_sha2
 662EOF
 663
 664cat >expect_log_cat_sort_uniq <<EOF
 665$commit_sha15 15th
 666y notes on 15th commit
 667z notes on 15th commit
 668
 669$commit_sha14 14th
 670y notes on 14th commit
 671
 672$commit_sha13 13th
 673y notes on 13th commit
 674
 675$commit_sha12 12th
 676y notes on 12th commit
 677
 678$commit_sha11 11th
 679z notes on 11th commit
 680
 681$commit_sha10 10th
 682x notes on 10th commit
 683
 684$commit_sha9 9th
 685
 686$commit_sha8 8th
 687z notes on 8th commit
 688
 689$commit_sha7 7th
 690
 691$commit_sha6 6th
 692
 693$commit_sha5 5th
 694y notes on 5th commit
 695z notes on 5th commit
 696
 697$commit_sha4 4th
 698y notes on 4th commit
 699
 700$commit_sha3 3rd
 701y notes on 3rd commit
 702
 703$commit_sha2 2nd
 704z notes on 2nd commit
 705
 706$commit_sha1 1st
 707
 708EOF
 709
 710test_expect_success 'merge y into z with "cat_sort_uniq" strategy => Non-conflicting 3-way merge' '
 711        git notes merge --strategy=cat_sort_uniq y &&
 712        verify_notes z cat_sort_uniq
 713'
 714
 715test_expect_success 'reset to pre-merge state (z)' '
 716        git update-ref refs/notes/z refs/notes/z^1 &&
 717        # Verify pre-merge state
 718        verify_notes z z
 719'
 720
 721test_expect_success 'merge y into z with "cat_sort_uniq" strategy configuration option => Non-conflicting 3-way merge' '
 722        git -c notes.mergeStrategy="cat_sort_uniq" notes merge y &&
 723        verify_notes z cat_sort_uniq
 724'
 725
 726test_done