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/t3308-notes-merge.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 / t3308-notes-merge.sh` 394 lines ยท 10232 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2010 Johan Herland 4 # 5 6 test_description='Test merging of notes trees' 7 8 . ./test-lib.sh 9 10 test_expect_success setup ' 11 test_commit 1st && 12 test_commit 2nd && 13 test_commit 3rd && 14 test_commit 4th && 15 test_commit 5th && 16 # Create notes on 4 first commits 17 git config core.notesRef refs/notes/x && 18 git notes add -m "Notes on 1st commit" 1st && 19 git notes add -m "Notes on 2nd commit" 2nd && 20 git notes add -m "Notes on 3rd commit" 3rd && 21 git notes add -m "Notes on 4th commit" 4th && 22 # Copy notes to remote-notes 23 git fetch . refs/notes/*:refs/remote-notes/origin/* && 24 25 test_oid_cache <<-EOF 26 hash4a sha1:`5e93d24084d32e1cb61f7070505b9d2530cca987` 27 hash3a sha1:`8366731eeee53787d2bdf8fc1eff7d94757e8da0` 28 hash2a sha1:`eede89064cd42441590d6afec6c37b321ada3389` 29 hash1a sha1:`daa55ffad6cb99bf64226532147ffcaf5ce8bdd1` 30 hash5b sha1:`0f2efbd00262f2fd41dfae33df8765618eeacd99` 31 hash4b sha1:`dec2502dac3ea161543f71930044deff93fa945c` 32 hash3b sha1:`4069cdb399fd45463ec6eef8e051a16a03592d91` 33 hash2c sha1:`d000d30e6ddcfce3a8122c403226a2ce2fd04d9d` 34 hash1c sha1:`43add6bd0c8c0bc871ac7991e0f5573cfba27804` 35 hash4d sha1:`1f257a3a90328557c452f0817d6cc50c89d315d4` 36 hash3d sha1:`05a4927951bcef347f51486575b878b2b60137f2` 37 38 hash4a sha256:`eef876be1d32ac2e2e42240e0429325cec116e55e88cb2969899fac695aa762f` 39 hash3a sha256:`cf7cd1bc091d7ba4166a86df864110e42087cd893a5ae96bc50d637e0290939d` 40 hash2a sha256:`21ddde7ebce2c285213898cb04deca0fd3209610cf7aaf8222e4e2f45262fae2` 41 hash1a sha256:`f9fe0eda16c6027732ed9d4295689a03abd16f893be69b3dcbf4037ddb191921` 42 hash5b sha256:`20046f2244577797a9e3d3f790ea9eca4d8a6bafb2a5570bcb0e03aa02ce100b` 43 hash4b sha256:`f90563d134c61a95bb88afbd45d48ccc9e919c62aa6fbfcd483302b3e4d8dbcb` 44 hash3b sha256:`988f2aca9f2d87e93e6a73197c2bb99560cc44a2f92d18653968f956f01221e0` 45 hash2c sha256:`84153b777b4d42827a756c6578dcdb59d8ae5d1360b874fb37c430150c825c26` 46 hash1c sha256:`9beb2bc4eef72e4c4087be168a20573e34d993d9ab1883055f23e322afa06567` 47 hash4d sha256:`32de39dc06e679a7abb2d4a55ede7709b3124340a4a90aa305971b1c72ac319d` 48 hash3d sha256:`fa73b20e41cbb7541c4c81d1535016131dbfbeb05bf6a71f6115e9cad31c7af5` 49 EOF 50 ' 51 52 commit_sha1=$(git rev-parse 1st^{commit}) 53 commit_sha2=$(git rev-parse 2nd^{commit}) 54 commit_sha3=$(git rev-parse 3rd^{commit}) 55 commit_sha4=$(git rev-parse 4th^{commit}) 56 commit_sha5=$(git rev-parse 5th^{commit}) 57 58 verify_notes () { 59 notes_ref="$1" 60 git -c core.notesRef="refs/notes/$notes_ref" notes | 61 sort >"output_notes_$notes_ref" && 62 test_cmp "expect_notes_$notes_ref" "output_notes_$notes_ref" && 63 git -c core.notesRef="refs/notes/$notes_ref" log --format="%H %s%n%N" \ 64 >"output_log_$notes_ref" && 65 test_cmp "expect_log_$notes_ref" "output_log_$notes_ref" 66 } 67 68 cat <expect_notes_x 69 $(test_oid hash4a) $commit_sha4 70 $(test_oid hash3a) $commit_sha3 71 $(test_oid hash2a) $commit_sha2 72 $(test_oid hash1a) $commit_sha1 73 EOF 74 75 cat >expect_log_x < y)' ' 102 test_must_fail git -c "core.notesRef=refs/notes/y" notes merge z 103 ' 104 105 test_expect_success 'fail to merge into various non-notes refs' ' 106 test_must_fail git -c "core.notesRef=refs/notes" notes merge x && 107 test_must_fail git -c "core.notesRef=refs/notes/" notes merge x && 108 git update-ref refs/notes/dir/foo HEAD && 109 test_must_fail git -c "core.notesRef=refs/notes/dir" notes merge x && 110 test_must_fail git -c "core.notesRef=refs/notes/dir/" notes merge x && 111 test_must_fail git -c "core.notesRef=refs/heads/main" notes merge x && 112 test_must_fail git -c "core.notesRef=refs/notes/y:" notes merge x && 113 test_must_fail git -c "core.notesRef=refs/notes/y:foo" notes merge x && 114 test_must_fail git -c "core.notesRef=refs/notes/foo^{bar" notes merge x 115 ' 116 117 test_expect_success 'merge non-notes ref into empty notes ref (remote-notes/origin/x => v)' ' 118 git config core.notesRef refs/notes/v && 119 git notes merge refs/remote-notes/origin/x && 120 verify_notes v && 121 # refs/remote-notes/origin/x and v should point to the same notes commit 122 test "$(git rev-parse refs/remote-notes/origin/x)" = "$(git rev-parse refs/notes/v)" 123 ' 124 125 test_expect_success 'merge notes into empty notes ref (x => y)' ' 126 git config core.notesRef refs/notes/y && 127 git notes merge x && 128 verify_notes y && 129 # x and y should point to the same notes commit 130 test "$(git rev-parse refs/notes/x)" = "$(git rev-parse refs/notes/y)" 131 ' 132 133 test_expect_success 'merge empty notes ref (z => y)' ' 134 git notes merge z && 135 # y should not change (still == x) 136 test "$(git rev-parse refs/notes/x)" = "$(git rev-parse refs/notes/y)" 137 ' 138 139 test_expect_success 'change notes on other notes ref (y)' ' 140 # Not touching notes to 1st commit 141 git notes remove 2nd && 142 git notes append -m "More notes on 3rd commit" 3rd && 143 git notes add -f -m "New notes on 4th commit" 4th && 144 git notes add -m "Notes on 5th commit" 5th 145 ' 146 147 test_expect_success 'merge previous notes commit (y^ => y) => No-op' ' 148 pre_state="$(git rev-parse refs/notes/y)" && 149 git notes merge y^ && 150 # y should not move 151 test "$pre_state" = "$(git rev-parse refs/notes/y)" 152 ' 153 154 cat <expect_notes_y 155 $(test_oid hash5b) $commit_sha5 156 $(test_oid hash4b) $commit_sha4 157 $(test_oid hash3b) $commit_sha3 158 $(test_oid hash1a) $commit_sha1 159 EOF 160 161 cat >expect_log_y < No-op' ' 189 git notes merge -vvv x && 190 verify_notes y && 191 verify_notes x 192 ' 193 194 cp expect_notes_y expect_notes_x 195 cp expect_log_y expect_log_x 196 197 test_expect_success 'merge changed (y) into original (x) => Fast-forward' ' 198 git config core.notesRef refs/notes/x && 199 git notes merge y && 200 verify_notes x && 201 verify_notes y && 202 # x and y should point to same the notes commit 203 test "$(git rev-parse refs/notes/x)" = "$(git rev-parse refs/notes/y)" 204 ' 205 206 test_expect_success 'merge empty notes ref (z => y)' ' 207 # Prepare empty (but valid) notes ref (z) 208 git config core.notesRef refs/notes/z && 209 git notes add -m "foo" && 210 git notes remove && 211 git notes >output_notes_z && 212 test_must_be_empty output_notes_z && 213 # Do the merge (z => y) 214 git config core.notesRef refs/notes/y && 215 git notes merge z && 216 verify_notes y && 217 # y should no longer point to the same notes commit as x 218 test "$(git rev-parse refs/notes/x)" != "$(git rev-parse refs/notes/y)" 219 ' 220 221 cat <expect_notes_y 222 $(test_oid hash5b) $commit_sha5 223 $(test_oid hash4b) $commit_sha4 224 $(test_oid hash3b) $commit_sha3 225 $(test_oid hash2c) $commit_sha2 226 $(test_oid hash1c) $commit_sha1 227 EOF 228 229 cat >expect_log_y <expect_notes_x 260 $(test_oid hash5b) $commit_sha5 261 $(test_oid hash4d) $commit_sha4 262 $(test_oid hash1a) $commit_sha1 263 EOF 264 265 cat >expect_log_x <expect_notes_x 291 $(test_oid hash5b) $commit_sha5 292 $(test_oid hash4d) $commit_sha4 293 $(test_oid hash2c) $commit_sha2 294 $(test_oid hash1c) $commit_sha1 295 EOF 296 297 cat >expect_log_x < Non-conflicting 3-way merge' ' 319 git notes merge y && 320 verify_notes x && 321 verify_notes y 322 ' 323 324 cat <expect_notes_w 325 $(test_oid hash3d) $commit_sha3 326 $(test_oid hash2c) $commit_sha2 327 EOF 328 329 cat >expect_log_w <expect_notes_x 355 $(test_oid hash5b) $commit_sha5 356 $(test_oid hash4d) $commit_sha4 357 $(test_oid hash3d) $commit_sha3 358 $(test_oid hash2c) $commit_sha2 359 $(test_oid hash1c) $commit_sha1 360 EOF 361 362 cat >expect_log_x < Non-conflicting history-less merge' ' 385 git config core.notesRef refs/notes/x && 386 git notes merge w && 387 # Verify new state of notes on other notes ref (x) 388 verify_notes x && 389 # Also verify that nothing changed on other notes refs (y and w) 390 verify_notes y && 391 verify_notes w 392 ' 393 394 test_done