Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t3310-notes-merge-manual-resolve.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t3310-notes-merge-manual-resolve.sh` 628 lines ยท 17704 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2010 Johan Herland 4 # 5 6 test_description='Test notes merging with manual conflict resolution' 7 8 . ./test-lib.sh 9 10 # Set up a notes merge scenario with different kinds of 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 18 test_oid_cache <<-EOF 19 hash04a sha1:`6e8e3febca3c2bb896704335cc4d0c34cb2f8715` 20 hash03a sha1:`e5388c10860456ee60673025345fe2e153eb8cf8` 21 hash02a sha1:`ceefa674873670e7ecd131814d909723cce2b669` 22 hash04b sha1:`e2bfd06a37dd2031684a59a6e2b033e212239c78` 23 hash03b sha1:`5772f42408c0dd6f097a7ca2d24de0e78d1c46b1` 24 hash01b sha1:`b0a6021ec006d07e80e9b20ec9b444cbd9d560d3` 25 hash04c sha1:`cff59c793c20bb49a4e01bc06fb06bad642e0d54` 26 hash02c sha1:`283b48219aee9a4105f6cab337e789065c82c2b9` 27 hash01c sha1:`0a81da8956346e19bcb27a906f04af327e03e31b` 28 hash04d sha1:`00494adecf2d9635a02fa431308d67993f853968` 29 hash01e sha1:`f75d1df88cbfe4258d49852f26cfc83f2ad4494b` 30 hash04f sha1:`021faa20e931fb48986ffc6282b4bb05553ac946` 31 hash01f sha1:`0a59e787e6d688aa6309e56e8c1b89431a0fc1c1` 32 hash05g sha1:`304dfb4325cf243025b9957486eb605a9b51c199` 33 34 hash04a sha256:`f18a935e65866345098b3b754071dbf9f3aa3520eb27a7b036b278c5e2f1ed7e` 35 hash03a sha256:`713035dc94067a64e5fa6e4e1821b7c3bde49a77c7cb3f80eaadefa1ca41b3d2` 36 hash02a sha256:`f160a67e048b6fa75bec3952184154045076692cf5dccd3da21e3fd34b7a3f0f` 37 hash04b sha256:`c7fba0d6104917fbf35258f40b9fa4fc697cfa992deecd1570a3b08d0a5587a9` 38 hash03b sha256:`7287a2d78a3766c181b08df38951d784b08b72a44f571ed6d855bd0be22c70f6` 39 hash01b sha256:`da96cf778c15d0a2bb76f98b2a62f6c9c01730fa7030e8f08ef0191048e7d620` 40 hash04c sha256:`cb615d2def4b834d5f55b2351df97dc92bee4f5009d285201427f349081c8aca` 41 hash02c sha256:`63bb527e0b4e1c8e1dd0d54dd778ca7c3718689fd6e37c473044cfbcf1cacfdb` 42 hash01c sha256:`5b87237ac1fbae0246256fed9f9a1f077c4140fb7e6444925f8dbfa5ae406cd8` 43 hash04d sha256:`eeddc9f9f6cb3d6b39b861659853f10891dc373e0b6eecb09e03e39b6ce64714` 44 hash01e sha256:`108f521b1a74c2e6d0b52a4eda87e09162bf847f7d190cfce496ee1af0b29a5a` 45 hash04f sha256:`901acda0454502b3bbd281f130c419e6c8de78afcf72a8def8d45ad31462bce4` 46 hash01f sha256:`a2d99d1b8bf23c8af7d9d91368454adc110dfd5cc068a4cebb486ee8f5a1e16c` 47 hash05g sha256:`4fef015b01da8efe929a68e3bb9b8fbad81f53995f097befe8ebc93f12ab98ec` 48 EOF 49 ' 50 51 commit_sha1=$(git rev-parse 1st^{commit}) 52 commit_sha2=$(git rev-parse 2nd^{commit}) 53 commit_sha3=$(git rev-parse 3rd^{commit}) 54 commit_sha4=$(git rev-parse 4th^{commit}) 55 commit_sha5=$(git rev-parse 5th^{commit}) 56 57 verify_notes () { 58 notes_ref="$1" 59 git -c core.notesRef="refs/notes/$notes_ref" notes | 60 sort >"output_notes_$notes_ref" && 61 test_cmp "expect_notes_$notes_ref" "output_notes_$notes_ref" && 62 git -c core.notesRef="refs/notes/$notes_ref" log --format="%H %s%n%N" \ 63 >"output_log_$notes_ref" && 64 test_cmp "expect_log_$notes_ref" "output_log_$notes_ref" 65 } 66 67 notes_merge_files_gone () { 68 # No .git/NOTES_MERGE_* files left 69 { ls .git/NOTES_MERGE_* >output || :; } && 70 test_must_be_empty output 71 } 72 73 cat <expect_notes_x 74 $(test_oid hash04a) $commit_sha4 75 $(test_oid hash03a) $commit_sha3 76 $(test_oid hash02a) $commit_sha2 77 EOF 78 79 cat >expect_log_x <expect_notes_y 104 $(test_oid hash04b) $commit_sha4 105 $(test_oid hash03b) $commit_sha3 106 $(test_oid hash01b) $commit_sha1 107 EOF 108 109 cat >expect_log_y <expect_notes_z 136 $(test_oid hash04c) $commit_sha4 137 $(test_oid hash02c) $commit_sha2 138 $(test_oid hash01c) $commit_sha1 139 EOF 140 141 cat >expect_log_z <expect_conflicts 178 $commit_sha1 179 $commit_sha2 180 $commit_sha3 181 $commit_sha4 182 EOF 183 184 cat >expect_conflict_$commit_sha1 <>>>>>> refs/notes/z 190 EOF 191 192 cat >expect_conflict_$commit_sha2 <expect_conflict_$commit_sha3 <expect_conflict_$commit_sha4 <>>>>>> refs/notes/z 206 EOF 207 208 cp expect_notes_y expect_notes_m 209 cp expect_log_y expect_log_m 210 211 git rev-parse refs/notes/y > pre_merge_y 212 git rev-parse refs/notes/z > pre_merge_z 213 214 test_expect_success 'merge z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' ' 215 git update-ref refs/notes/m refs/notes/y && 216 git config core.notesRef refs/notes/m && 217 test_must_fail git notes merge z >output 2>&1 && 218 # Output should point to where to resolve conflicts 219 test_grep "\\.git/NOTES_MERGE_WORKTREE" output && 220 # Inspect merge conflicts 221 ls .git/NOTES_MERGE_WORKTREE >output_conflicts && 222 test_cmp expect_conflicts output_conflicts && 223 ( for f in $(cat expect_conflicts); do 224 test_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" || 225 exit 1 226 done ) && 227 # Verify that current notes tree (pre-merge) has not changed (m == y) 228 verify_notes y && 229 verify_notes m && 230 git rev-parse refs/notes/m >actual && 231 test_cmp pre_merge_y actual 232 ' 233 234 cat <expect_notes_z 235 $(test_oid hash04d) $commit_sha4 236 $(test_oid hash02c) $commit_sha2 237 $(test_oid hash01c) $commit_sha1 238 EOF 239 240 cat >expect_log_z <output 2>&1 && 266 # Output should indicate what is wrong 267 test_grep -q "\\.git/NOTES_MERGE_\\* exists" output 268 ' 269 270 # Setup non-conflicting merge between x and new notes ref w 271 272 cat <expect_notes_w 273 $(test_oid hash02a) $commit_sha2 274 $(test_oid hash01e) $commit_sha1 275 EOF 276 277 cat >expect_log_w <expect_notes_w 300 $(test_oid hash04a) $commit_sha4 301 $(test_oid hash03a) $commit_sha3 302 $(test_oid hash02a) $commit_sha2 303 $(test_oid hash01e) $commit_sha1 304 EOF 305 306 cat >expect_log_w < w)' ' 324 test_path_is_dir .git/NOTES_MERGE_WORKTREE && 325 git notes merge x && 326 verify_notes w && 327 # Verify that other notes refs has not changed (x and y) 328 verify_notes x && 329 verify_notes y 330 ' 331 332 cat <expect_notes_m 333 $(test_oid hash04f) $commit_sha4 334 $(test_oid hash03b) $commit_sha3 335 $(test_oid hash02c) $commit_sha2 336 $(test_oid hash01f) $commit_sha1 337 EOF 338 339 cat >expect_log_m < m)' ' 369 # Resolve conflicts and finalize merge 370 cat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <.git/NOTES_MERGE_WORKTREE/$commit_sha4 <actual && 380 test_cmp pre_merge_y actual && 381 git rev-parse refs/notes/m^2 >actual && 382 test_cmp pre_merge_z actual && 383 # Merge commit mentions the notes refs merged 384 git log -1 --format=%B refs/notes/m > merge_commit_msg && 385 test_grep -q refs/notes/m merge_commit_msg && 386 test_grep -q refs/notes/z merge_commit_msg && 387 # Merge commit mentions conflicting notes 388 test_grep -q "Conflicts" merge_commit_msg && 389 ( for sha1 in $(cat expect_conflicts); do 390 test_grep -q "$sha1" merge_commit_msg || 391 exit 1 392 done ) && 393 # Verify contents of merge result 394 verify_notes m && 395 # Verify that other notes refs has not changed (w, x, y and z) 396 verify_notes w && 397 verify_notes x && 398 verify_notes y && 399 verify_notes z 400 ' 401 402 cat >expect_conflict_$commit_sha4 <>>>>>> refs/notes/z 410 EOF 411 412 cp expect_notes_y expect_notes_m 413 cp expect_log_y expect_log_m 414 415 git rev-parse refs/notes/y > pre_merge_y 416 git rev-parse refs/notes/z > pre_merge_z 417 418 test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' ' 419 git update-ref refs/notes/m refs/notes/y && 420 git config core.notesRef refs/notes/m && 421 test_must_fail git notes merge z >output 2>&1 && 422 # Output should point to where to resolve conflicts 423 test_grep "\\.git/NOTES_MERGE_WORKTREE" output && 424 # Inspect merge conflicts 425 ls .git/NOTES_MERGE_WORKTREE >output_conflicts && 426 test_cmp expect_conflicts output_conflicts && 427 ( for f in $(cat expect_conflicts); do 428 test_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" || 429 exit 1 430 done ) && 431 # Verify that current notes tree (pre-merge) has not changed (m == y) 432 verify_notes y && 433 verify_notes m && 434 git rev-parse refs/notes/m >actual && 435 test_cmp pre_merge_y actual 436 ' 437 438 test_expect_success 'abort notes merge' ' 439 git notes merge --abort && 440 notes_merge_files_gone && 441 # m has not moved (still == y) 442 git rev-parse refs/notes/m >actual && 443 test_cmp pre_merge_y actual && 444 # Verify that other notes refs has not changed (w, x, y and z) 445 verify_notes w && 446 verify_notes x && 447 verify_notes y && 448 verify_notes z 449 ' 450 451 git rev-parse refs/notes/y > pre_merge_y 452 git rev-parse refs/notes/z > pre_merge_z 453 454 test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' ' 455 test_must_fail git notes merge z >output 2>&1 && 456 # Output should point to where to resolve conflicts 457 test_grep "\\.git/NOTES_MERGE_WORKTREE" output && 458 # Inspect merge conflicts 459 ls .git/NOTES_MERGE_WORKTREE >output_conflicts && 460 test_cmp expect_conflicts output_conflicts && 461 ( for f in $(cat expect_conflicts); do 462 test_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" || 463 exit 1 464 done ) && 465 # Verify that current notes tree (pre-merge) has not changed (m == y) 466 verify_notes y && 467 verify_notes m && 468 git rev-parse refs/notes/m >actual && 469 test_cmp pre_merge_y actual 470 ' 471 472 cat <expect_notes_m 473 $(test_oid hash05g) $commit_sha5 474 $(test_oid hash02c) $commit_sha2 475 $(test_oid hash01f) $commit_sha1 476 EOF 477 478 cat >expect_log_m < m)' ' 495 # Resolve one conflict 496 cat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 < .git/NOTES_MERGE_WORKTREE/$commit_sha5 && 505 # Finalize merge 506 git notes merge --commit && 507 notes_merge_files_gone && 508 # Merge commit has pre-merge y and pre-merge z as parents 509 git rev-parse refs/notes/m^1 >actual && 510 test_cmp pre_merge_y actual && 511 git rev-parse refs/notes/m^2 >actual && 512 test_cmp pre_merge_z actual && 513 # Merge commit mentions the notes refs merged 514 git log -1 --format=%B refs/notes/m > merge_commit_msg && 515 test_grep -q refs/notes/m merge_commit_msg && 516 test_grep -q refs/notes/z merge_commit_msg && 517 # Merge commit mentions conflicting notes 518 test_grep -q "Conflicts" merge_commit_msg && 519 ( for sha1 in $(cat expect_conflicts); do 520 test_grep -q "$sha1" merge_commit_msg || 521 exit 1 522 done ) && 523 # Verify contents of merge result 524 verify_notes m && 525 # Verify that other notes refs has not changed (w, x, y and z) 526 verify_notes w && 527 verify_notes x && 528 verify_notes y && 529 verify_notes z 530 ' 531 532 cp expect_notes_y expect_notes_m 533 cp expect_log_y expect_log_m 534 535 test_expect_success 'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge' ' 536 git update-ref refs/notes/m refs/notes/y && 537 test_must_fail git notes merge z >output 2>&1 && 538 # Output should point to where to resolve conflicts 539 test_grep "\\.git/NOTES_MERGE_WORKTREE" output && 540 # Inspect merge conflicts 541 ls .git/NOTES_MERGE_WORKTREE >output_conflicts && 542 test_cmp expect_conflicts output_conflicts && 543 ( for f in $(cat expect_conflicts); do 544 test_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" || 545 exit 1 546 done ) && 547 # Verify that current notes tree (pre-merge) has not changed (m == y) 548 verify_notes y && 549 verify_notes m && 550 git rev-parse refs/notes/m >actual && 551 test_cmp pre_merge_y actual 552 ' 553 554 cp expect_notes_w expect_notes_m 555 cp expect_log_w expect_log_m 556 557 test_expect_success 'reset notes ref m to somewhere else (w)' ' 558 git update-ref refs/notes/m refs/notes/w && 559 verify_notes m && 560 test_cmp_rev refs/notes/m refs/notes/w 561 ' 562 563 test_expect_success 'fail to finalize conflicting merge if underlying ref has moved in the meantime (m != NOTES_MERGE_PARTIAL^1)' ' 564 # Resolve conflicts 565 cat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <.git/NOTES_MERGE_WORKTREE/$commit_sha4 <output 2>&1 && 573 # NOTES_MERGE_* refs and .git/NOTES_MERGE_* state files must remain 574 git rev-parse --verify NOTES_MERGE_PARTIAL && 575 git rev-parse --verify NOTES_MERGE_REF && 576 test_path_is_file .git/NOTES_MERGE_WORKTREE/$commit_sha1 && 577 test_path_is_file .git/NOTES_MERGE_WORKTREE/$commit_sha2 && 578 test_path_is_file .git/NOTES_MERGE_WORKTREE/$commit_sha3 && 579 test_path_is_file .git/NOTES_MERGE_WORKTREE/$commit_sha4 && 580 # Refs are unchanged 581 test_cmp_rev refs/notes/m refs/notes/w && 582 test_cmp_rev refs/notes/y NOTES_MERGE_PARTIAL^1 && 583 test_cmp_rev ! refs/notes/m NOTES_MERGE_PARTIAL^1 && 584 # Mention refs/notes/m, and its current and expected value in output 585 test_grep -q "refs/notes/m" output && 586 oid=$(git rev-parse refs/notes/m) && 587 test_grep -q "$oid" output && 588 oid=$(git rev-parse NOTES_MERGE_PARTIAL^1) && 589 test_grep -q "$oid" output && 590 # Verify that other notes refs has not changed (w, x, y and z) 591 verify_notes w && 592 verify_notes x && 593 verify_notes y && 594 verify_notes z 595 ' 596 597 test_expect_success 'resolve situation by aborting the notes merge' ' 598 git notes merge --abort && 599 notes_merge_files_gone && 600 # m has not moved (still == w) 601 test_cmp_rev refs/notes/m refs/notes/w && 602 # Verify that other notes refs has not changed (w, x, y and z) 603 verify_notes w && 604 verify_notes x && 605 verify_notes y && 606 verify_notes z 607 ' 608 609 cat >expect_notes <"$oid" && 622 git notes merge --commit 623 ) && 624 git notes show HEAD > actual_notes && 625 test_cmp expect_notes actual_notes 626 ' 627 628 test_done