| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Shawn Pearce |
| 4 | # |
| 5 | |
| 6 | test_description='test git fast-import utility' |
| 7 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 8 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 9 | |
| 10 | . ./test-lib.sh |
| 11 | . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash |
| 12 | |
| 13 | verify_packs () { |
| 14 | for p in .git/objects/pack/*.pack |
| 15 | do |
| 16 | git verify-pack "$@" "$p" || return |
| 17 | done |
| 18 | } |
| 19 | |
| 20 | file2_data='file2 |
| 21 | second line of EOF' |
| 22 | |
| 23 | file3_data='EOF |
| 24 | in 3rd file |
| 25 | END' |
| 26 | |
| 27 | file4_data=abcd |
| 28 | file4_len=4 |
| 29 | |
| 30 | file5_data='an inline file. |
| 31 | we should see it later.' |
| 32 | |
| 33 | file6_data='#!/bin/sh |
| 34 | echo "$@"' |
| 35 | |
| 36 | ### |
| 37 | ### series A |
| 38 | ### |
| 39 | |
| 40 | test_expect_success 'empty stream succeeds' ' |
| 41 | git config fastimport.unpackLimit 0 && |
| 42 | git fast-import </dev/null |
| 43 | ' |
| 44 | |
| 45 | test_expect_success 'truncated stream complains' ' |
| 46 | echo "tag foo" | test_must_fail git fast-import |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'A: create pack from stdin' ' |
| 50 | test_tick && |
| 51 | cat >input <<-INPUT_END && |
| 52 | blob |
| 53 | mark :2 |
| 54 | data <<EOF |
| 55 | $file2_data |
| 56 | EOF |
| 57 | |
| 58 | blob |
| 59 | mark :3 |
| 60 | data <<END |
| 61 | $file3_data |
| 62 | END |
| 63 | |
| 64 | blob |
| 65 | mark :4 |
| 66 | data $file4_len |
| 67 | $file4_data |
| 68 | commit refs/heads/main |
| 69 | mark :5 |
| 70 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 71 | data <<COMMIT |
| 72 | initial |
| 73 | COMMIT |
| 74 | |
| 75 | M 644 :2 file2 |
| 76 | M 644 :3 file3 |
| 77 | M 755 :4 file4 |
| 78 | |
| 79 | tag series-A |
| 80 | from :5 |
| 81 | data <<EOF |
| 82 | An annotated tag without a tagger |
| 83 | EOF |
| 84 | |
| 85 | tag series-A-blob |
| 86 | from :3 |
| 87 | data <<EOF |
| 88 | An annotated tag that annotates a blob. |
| 89 | EOF |
| 90 | |
| 91 | tag to-be-deleted |
| 92 | from :3 |
| 93 | data <<EOF |
| 94 | Another annotated tag that annotates a blob. |
| 95 | EOF |
| 96 | |
| 97 | reset refs/tags/to-be-deleted |
| 98 | from $ZERO_OID |
| 99 | |
| 100 | tag nested |
| 101 | mark :6 |
| 102 | from :4 |
| 103 | data <<EOF |
| 104 | Tag of our lovely commit |
| 105 | EOF |
| 106 | |
| 107 | reset refs/tags/nested |
| 108 | from $ZERO_OID |
| 109 | |
| 110 | tag nested |
| 111 | mark :7 |
| 112 | from :6 |
| 113 | data <<EOF |
| 114 | Tag of tag of our lovely commit |
| 115 | EOF |
| 116 | |
| 117 | alias |
| 118 | mark :8 |
| 119 | to :5 |
| 120 | |
| 121 | INPUT_END |
| 122 | git fast-import --export-marks=marks.out <input && |
| 123 | git log --raw main |
| 124 | ' |
| 125 | |
| 126 | test_expect_success 'A: verify pack' ' |
| 127 | verify_packs |
| 128 | ' |
| 129 | |
| 130 | test_expect_success 'A: verify commit' ' |
| 131 | cat >expect <<-EOF && |
| 132 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 133 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 134 | |
| 135 | initial |
| 136 | EOF |
| 137 | git cat-file commit main | sed 1d >actual && |
| 138 | test_cmp expect actual |
| 139 | ' |
| 140 | |
| 141 | test_expect_success 'A: verify tree' ' |
| 142 | cat >expect <<-EOF && |
| 143 | 100644 blob file2 |
| 144 | 100644 blob file3 |
| 145 | 100755 blob file4 |
| 146 | EOF |
| 147 | git cat-file -p main^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 148 | test_cmp expect actual |
| 149 | ' |
| 150 | |
| 151 | test_expect_success 'A: verify file2' ' |
| 152 | echo "$file2_data" >expect && |
| 153 | git cat-file blob main:file2 >actual && |
| 154 | test_cmp expect actual |
| 155 | ' |
| 156 | |
| 157 | test_expect_success 'A: verify file3' ' |
| 158 | echo "$file3_data" >expect && |
| 159 | git cat-file blob main:file3 >actual && |
| 160 | test_cmp expect actual |
| 161 | ' |
| 162 | |
| 163 | test_expect_success 'A: verify file4' ' |
| 164 | printf "$file4_data" >expect && |
| 165 | git cat-file blob main:file4 >actual && |
| 166 | test_cmp expect actual |
| 167 | ' |
| 168 | |
| 169 | test_expect_success 'A: verify tag/series-A' ' |
| 170 | cat >expect <<-EOF && |
| 171 | object $(git rev-parse refs/heads/main) |
| 172 | type commit |
| 173 | tag series-A |
| 174 | |
| 175 | An annotated tag without a tagger |
| 176 | EOF |
| 177 | git cat-file tag tags/series-A >actual && |
| 178 | test_cmp expect actual |
| 179 | ' |
| 180 | |
| 181 | test_expect_success 'A: verify tag/series-A-blob' ' |
| 182 | cat >expect <<-EOF && |
| 183 | object $(git rev-parse refs/heads/main:file3) |
| 184 | type blob |
| 185 | tag series-A-blob |
| 186 | |
| 187 | An annotated tag that annotates a blob. |
| 188 | EOF |
| 189 | git cat-file tag tags/series-A-blob >actual && |
| 190 | test_cmp expect actual |
| 191 | ' |
| 192 | |
| 193 | test_expect_success 'A: verify tag deletion is successful' ' |
| 194 | test_must_fail git rev-parse --verify refs/tags/to-be-deleted |
| 195 | ' |
| 196 | |
| 197 | test_expect_success 'A: verify marks output' ' |
| 198 | cat >expect <<-EOF && |
| 199 | :2 $(git rev-parse --verify main:file2) |
| 200 | :3 $(git rev-parse --verify main:file3) |
| 201 | :4 $(git rev-parse --verify main:file4) |
| 202 | :5 $(git rev-parse --verify main^0) |
| 203 | :6 $(git cat-file tag nested | grep object | cut -d" " -f 2) |
| 204 | :7 $(git rev-parse --verify nested) |
| 205 | :8 $(git rev-parse --verify main^0) |
| 206 | EOF |
| 207 | test_cmp expect marks.out |
| 208 | ' |
| 209 | |
| 210 | test_expect_success 'A: verify marks import' ' |
| 211 | git fast-import \ |
| 212 | --import-marks=marks.out \ |
| 213 | --export-marks=marks.new \ |
| 214 | </dev/null && |
| 215 | test_cmp expect marks.new |
| 216 | ' |
| 217 | |
| 218 | test_expect_success 'A: tag blob by sha1' ' |
| 219 | test_tick && |
| 220 | new_blob=$(echo testing | git hash-object --stdin) && |
| 221 | cat >input <<-INPUT_END && |
| 222 | tag series-A-blob-2 |
| 223 | from $(git rev-parse refs/heads/main:file3) |
| 224 | data <<EOF |
| 225 | Tag blob by sha1. |
| 226 | EOF |
| 227 | |
| 228 | blob |
| 229 | mark :6 |
| 230 | data <<EOF |
| 231 | testing |
| 232 | EOF |
| 233 | |
| 234 | commit refs/heads/new_blob |
| 235 | committer <> 0 +0000 |
| 236 | data 0 |
| 237 | M 644 :6 new_blob |
| 238 | #pretend we got sha1 from fast-import |
| 239 | ls "new_blob" |
| 240 | |
| 241 | tag series-A-blob-3 |
| 242 | from $new_blob |
| 243 | data <<EOF |
| 244 | Tag new_blob. |
| 245 | EOF |
| 246 | INPUT_END |
| 247 | |
| 248 | cat >expect <<-EOF && |
| 249 | object $(git rev-parse refs/heads/main:file3) |
| 250 | type blob |
| 251 | tag series-A-blob-2 |
| 252 | |
| 253 | Tag blob by sha1. |
| 254 | object $new_blob |
| 255 | type blob |
| 256 | tag series-A-blob-3 |
| 257 | |
| 258 | Tag new_blob. |
| 259 | EOF |
| 260 | |
| 261 | git fast-import <input && |
| 262 | git cat-file tag tags/series-A-blob-2 >actual && |
| 263 | git cat-file tag tags/series-A-blob-3 >>actual && |
| 264 | test_cmp expect actual |
| 265 | ' |
| 266 | |
| 267 | test_expect_success 'A: verify marks import does not crash' ' |
| 268 | test_tick && |
| 269 | cat >input <<-INPUT_END && |
| 270 | commit refs/heads/verify--import-marks |
| 271 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 272 | data <<COMMIT |
| 273 | recreate from :5 |
| 274 | COMMIT |
| 275 | |
| 276 | from :5 |
| 277 | M 755 :2 copy-of-file2 |
| 278 | |
| 279 | INPUT_END |
| 280 | |
| 281 | git fast-import --import-marks=marks.out <input && |
| 282 | git log --raw verify--import-marks |
| 283 | ' |
| 284 | |
| 285 | test_expect_success 'A: verify pack' ' |
| 286 | verify_packs |
| 287 | ' |
| 288 | |
| 289 | test_expect_success 'A: verify diff' ' |
| 290 | copy=$(git rev-parse --verify main:file2) && |
| 291 | cat >expect <<-EOF && |
| 292 | :000000 100755 $ZERO_OID $copy A copy-of-file2 |
| 293 | EOF |
| 294 | git diff-tree -M -r main verify--import-marks >actual && |
| 295 | compare_diff_raw expect actual && |
| 296 | test $(git rev-parse --verify main:file2) \ |
| 297 | = $(git rev-parse --verify verify--import-marks:copy-of-file2) |
| 298 | ' |
| 299 | |
| 300 | test_expect_success 'A: export marks with large values' ' |
| 301 | test_tick && |
| 302 | mt=$(git hash-object --stdin < /dev/null) && |
| 303 | >input.blob && |
| 304 | >marks.exp && |
| 305 | >tree.exp && |
| 306 | |
| 307 | cat >input.commit <<-EOF && |
| 308 | commit refs/heads/verify--dump-marks |
| 309 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 310 | data <<COMMIT |
| 311 | test the sparse array dumping routines with exponentially growing marks |
| 312 | COMMIT |
| 313 | EOF |
| 314 | |
| 315 | i=0 l=4 m=6 n=7 && |
| 316 | while test "$i" -lt 27 |
| 317 | do |
| 318 | cat >>input.blob <<-EOF && |
| 319 | blob |
| 320 | mark :$l |
| 321 | data 0 |
| 322 | blob |
| 323 | mark :$m |
| 324 | data 0 |
| 325 | blob |
| 326 | mark :$n |
| 327 | data 0 |
| 328 | EOF |
| 329 | echo "M 100644 :$l l$i" >>input.commit && |
| 330 | echo "M 100644 :$m m$i" >>input.commit && |
| 331 | echo "M 100644 :$n n$i" >>input.commit && |
| 332 | |
| 333 | echo ":$l $mt" >>marks.exp && |
| 334 | echo ":$m $mt" >>marks.exp && |
| 335 | echo ":$n $mt" >>marks.exp && |
| 336 | |
| 337 | printf "100644 blob $mt\tl$i\n" >>tree.exp && |
| 338 | printf "100644 blob $mt\tm$i\n" >>tree.exp && |
| 339 | printf "100644 blob $mt\tn$i\n" >>tree.exp && |
| 340 | |
| 341 | l=$(($l + $l)) && |
| 342 | m=$(($m + $m)) && |
| 343 | n=$(($l + $n)) && |
| 344 | |
| 345 | i=$((1 + $i)) || return 1 |
| 346 | done && |
| 347 | |
| 348 | sort tree.exp > tree.exp_s && |
| 349 | |
| 350 | cat input.blob input.commit | git fast-import --export-marks=marks.large && |
| 351 | git ls-tree refs/heads/verify--dump-marks >tree.out && |
| 352 | test_cmp tree.exp_s tree.out && |
| 353 | test_cmp marks.exp marks.large |
| 354 | ' |
| 355 | |
| 356 | ### |
| 357 | ### series B |
| 358 | ### |
| 359 | |
| 360 | test_expect_success 'B: fail on invalid blob sha1' ' |
| 361 | test_tick && |
| 362 | cat >input <<-INPUT_END && |
| 363 | commit refs/heads/branch |
| 364 | mark :1 |
| 365 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 366 | data <<COMMIT |
| 367 | corrupt |
| 368 | COMMIT |
| 369 | |
| 370 | from refs/heads/main |
| 371 | M 755 $(echo $ZERO_OID | sed -e "s/0$/1/") zero1 |
| 372 | |
| 373 | INPUT_END |
| 374 | |
| 375 | test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" && |
| 376 | test_must_fail git fast-import <input |
| 377 | ' |
| 378 | |
| 379 | test_expect_success 'B: accept branch name "TEMP_TAG"' ' |
| 380 | cat >input <<-INPUT_END && |
| 381 | commit TEMP_TAG |
| 382 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 383 | data <<COMMIT |
| 384 | tag base |
| 385 | COMMIT |
| 386 | |
| 387 | from refs/heads/main |
| 388 | |
| 389 | INPUT_END |
| 390 | |
| 391 | test_when_finished "rm -f .git/TEMP_TAG && git gc --prune=now" && |
| 392 | git fast-import <input && |
| 393 | test $(test-tool ref-store main resolve-ref TEMP_TAG 0 | cut -f1 -d " " ) != "$ZERO_OID" && |
| 394 | test $(git rev-parse main) = $(git rev-parse TEMP_TAG^) |
| 395 | ' |
| 396 | |
| 397 | test_expect_success 'B: accept empty committer' ' |
| 398 | cat >input <<-INPUT_END && |
| 399 | commit refs/heads/empty-committer-1 |
| 400 | committer <> $GIT_COMMITTER_DATE |
| 401 | data <<COMMIT |
| 402 | empty commit |
| 403 | COMMIT |
| 404 | INPUT_END |
| 405 | |
| 406 | test_when_finished "git update-ref -d refs/heads/empty-committer-1 |
| 407 | git gc --prune=now" && |
| 408 | git fast-import <input && |
| 409 | out=$(git fsck) && |
| 410 | echo "$out" && |
| 411 | test -z "$out" |
| 412 | ' |
| 413 | |
| 414 | test_expect_success 'B: reject invalid timezone' ' |
| 415 | cat >input <<-INPUT_END && |
| 416 | commit refs/heads/invalid-timezone |
| 417 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1234567890 +051800 |
| 418 | data <<COMMIT |
| 419 | empty commit |
| 420 | COMMIT |
| 421 | INPUT_END |
| 422 | |
| 423 | test_when_finished "git update-ref -d refs/heads/invalid-timezone" && |
| 424 | test_must_fail git fast-import <input |
| 425 | ' |
| 426 | |
| 427 | test_expect_success 'B: accept invalid timezone with raw-permissive' ' |
| 428 | cat >input <<-INPUT_END && |
| 429 | commit refs/heads/invalid-timezone |
| 430 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1234567890 +051800 |
| 431 | data <<COMMIT |
| 432 | empty commit |
| 433 | COMMIT |
| 434 | INPUT_END |
| 435 | |
| 436 | git init invalid-timezone && |
| 437 | git -C invalid-timezone fast-import --date-format=raw-permissive <input && |
| 438 | git -C invalid-timezone cat-file -p invalid-timezone >out && |
| 439 | grep "1234567890 [+]051800" out |
| 440 | ' |
| 441 | |
| 442 | test_expect_success 'B: accept and fixup committer with no name' ' |
| 443 | cat >input <<-INPUT_END && |
| 444 | commit refs/heads/empty-committer-2 |
| 445 | committer <a@b.com> $GIT_COMMITTER_DATE |
| 446 | data <<COMMIT |
| 447 | empty commit |
| 448 | COMMIT |
| 449 | INPUT_END |
| 450 | |
| 451 | test_when_finished "git update-ref -d refs/heads/empty-committer-2 |
| 452 | git gc --prune=now" && |
| 453 | git fast-import <input && |
| 454 | out=$(git fsck) && |
| 455 | echo "$out" && |
| 456 | test -z "$out" |
| 457 | ' |
| 458 | |
| 459 | test_expect_success 'B: fail on invalid committer (1)' ' |
| 460 | cat >input <<-INPUT_END && |
| 461 | commit refs/heads/invalid-committer |
| 462 | committer Name email> $GIT_COMMITTER_DATE |
| 463 | data <<COMMIT |
| 464 | empty commit |
| 465 | COMMIT |
| 466 | INPUT_END |
| 467 | |
| 468 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
| 469 | test_must_fail git fast-import <input |
| 470 | ' |
| 471 | |
| 472 | test_expect_success 'B: fail on invalid committer (2)' ' |
| 473 | cat >input <<-INPUT_END && |
| 474 | commit refs/heads/invalid-committer |
| 475 | committer Name <e<mail> $GIT_COMMITTER_DATE |
| 476 | data <<COMMIT |
| 477 | empty commit |
| 478 | COMMIT |
| 479 | INPUT_END |
| 480 | |
| 481 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
| 482 | test_must_fail git fast-import <input |
| 483 | ' |
| 484 | |
| 485 | test_expect_success 'B: fail on invalid committer (3)' ' |
| 486 | cat >input <<-INPUT_END && |
| 487 | commit refs/heads/invalid-committer |
| 488 | committer Name <email>> $GIT_COMMITTER_DATE |
| 489 | data <<COMMIT |
| 490 | empty commit |
| 491 | COMMIT |
| 492 | INPUT_END |
| 493 | |
| 494 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
| 495 | test_must_fail git fast-import <input |
| 496 | ' |
| 497 | |
| 498 | test_expect_success 'B: fail on invalid committer (4)' ' |
| 499 | cat >input <<-INPUT_END && |
| 500 | commit refs/heads/invalid-committer |
| 501 | committer Name <email $GIT_COMMITTER_DATE |
| 502 | data <<COMMIT |
| 503 | empty commit |
| 504 | COMMIT |
| 505 | INPUT_END |
| 506 | |
| 507 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
| 508 | test_must_fail git fast-import <input |
| 509 | ' |
| 510 | |
| 511 | test_expect_success 'B: fail on invalid committer (5)' ' |
| 512 | cat >input <<-INPUT_END && |
| 513 | commit refs/heads/invalid-committer |
| 514 | committer Name<email> $GIT_COMMITTER_DATE |
| 515 | data <<COMMIT |
| 516 | empty commit |
| 517 | COMMIT |
| 518 | INPUT_END |
| 519 | |
| 520 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
| 521 | test_must_fail git fast-import <input |
| 522 | ' |
| 523 | |
| 524 | test_expect_success 'B: fail on invalid file path of ..' ' |
| 525 | cat >input <<-INPUT_END && |
| 526 | blob |
| 527 | mark :1 |
| 528 | data <<EOF |
| 529 | File contents |
| 530 | EOF |
| 531 | |
| 532 | commit refs/heads/badpath |
| 533 | committer Name <email> $GIT_COMMITTER_DATE |
| 534 | data <<COMMIT |
| 535 | Commit Message |
| 536 | COMMIT |
| 537 | M 100644 :1 ../invalid-path |
| 538 | INPUT_END |
| 539 | |
| 540 | test_when_finished "git update-ref -d refs/heads/badpath" && |
| 541 | test_must_fail git fast-import <input |
| 542 | ' |
| 543 | |
| 544 | test_expect_success 'B: fail on invalid file path of .' ' |
| 545 | cat >input <<-INPUT_END && |
| 546 | blob |
| 547 | mark :1 |
| 548 | data <<EOF |
| 549 | File contents |
| 550 | EOF |
| 551 | |
| 552 | commit refs/heads/badpath |
| 553 | committer Name <email> $GIT_COMMITTER_DATE |
| 554 | data <<COMMIT |
| 555 | Good path |
| 556 | COMMIT |
| 557 | M 100644 :1 ok-path |
| 558 | |
| 559 | commit refs/heads/badpath |
| 560 | committer Name <email> $GIT_COMMITTER_DATE |
| 561 | data <<COMMIT |
| 562 | Bad path |
| 563 | COMMIT |
| 564 | R ok-path ./invalid-path |
| 565 | INPUT_END |
| 566 | |
| 567 | test_when_finished "git update-ref -d refs/heads/badpath" && |
| 568 | test_must_fail git fast-import <input |
| 569 | ' |
| 570 | |
| 571 | test_expect_success WINDOWS 'B: fail on invalid file path of C:' ' |
| 572 | cat >input <<-INPUT_END && |
| 573 | blob |
| 574 | mark :1 |
| 575 | data <<EOF |
| 576 | File contents |
| 577 | EOF |
| 578 | |
| 579 | commit refs/heads/badpath |
| 580 | committer Name <email> $GIT_COMMITTER_DATE |
| 581 | data <<COMMIT |
| 582 | Commit Message |
| 583 | COMMIT |
| 584 | M 100644 :1 C:/invalid-path |
| 585 | INPUT_END |
| 586 | |
| 587 | test_when_finished "git update-ref -d refs/heads/badpath" && |
| 588 | test_must_fail git fast-import <input |
| 589 | ' |
| 590 | |
| 591 | test_expect_success 'B: fail on invalid file path of .git' ' |
| 592 | cat >input <<-INPUT_END && |
| 593 | blob |
| 594 | mark :1 |
| 595 | data <<EOF |
| 596 | File contents |
| 597 | EOF |
| 598 | |
| 599 | commit refs/heads/badpath |
| 600 | committer Name <email> $GIT_COMMITTER_DATE |
| 601 | data <<COMMIT |
| 602 | Commit Message |
| 603 | COMMIT |
| 604 | M 100644 :1 .git/invalid-path |
| 605 | INPUT_END |
| 606 | |
| 607 | test_when_finished "git update-ref -d refs/heads/badpath" && |
| 608 | test_must_fail git fast-import <input |
| 609 | ' |
| 610 | |
| 611 | test_expect_success 'B: fail on invalid file path of .gitmodules' ' |
| 612 | cat >input <<-INPUT_END && |
| 613 | blob |
| 614 | mark :1 |
| 615 | data <<EOF |
| 616 | File contents |
| 617 | EOF |
| 618 | |
| 619 | commit refs/heads/badpath |
| 620 | committer Name <email> $GIT_COMMITTER_DATE |
| 621 | data <<COMMIT |
| 622 | Commit Message |
| 623 | COMMIT |
| 624 | M 120000 :1 .gitmodules |
| 625 | INPUT_END |
| 626 | |
| 627 | test_when_finished "git update-ref -d refs/heads/badpath" && |
| 628 | test_must_fail git fast-import <input |
| 629 | ' |
| 630 | |
| 631 | ### |
| 632 | ### series C |
| 633 | ### |
| 634 | |
| 635 | test_expect_success 'C: incremental import create pack from stdin' ' |
| 636 | newf=$(echo hi newf | git hash-object -w --stdin) && |
| 637 | oldf=$(git rev-parse --verify main:file2) && |
| 638 | thrf=$(git rev-parse --verify main:file3) && |
| 639 | test_tick && |
| 640 | cat >input <<-INPUT_END && |
| 641 | commit refs/heads/branch |
| 642 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 643 | data <<COMMIT |
| 644 | second |
| 645 | COMMIT |
| 646 | |
| 647 | from refs/heads/main |
| 648 | M 644 $oldf file2/oldf |
| 649 | M 755 $newf file2/newf |
| 650 | D file3 |
| 651 | |
| 652 | INPUT_END |
| 653 | |
| 654 | git fast-import <input && |
| 655 | git log --raw branch |
| 656 | ' |
| 657 | |
| 658 | test_expect_success 'C: verify pack' ' |
| 659 | verify_packs |
| 660 | ' |
| 661 | |
| 662 | test_expect_success 'C: validate reuse existing blob' ' |
| 663 | test $newf = $(git rev-parse --verify branch:file2/newf) && |
| 664 | test $oldf = $(git rev-parse --verify branch:file2/oldf) |
| 665 | ' |
| 666 | |
| 667 | test_expect_success 'C: verify commit' ' |
| 668 | cat >expect <<-EOF && |
| 669 | parent $(git rev-parse --verify main^0) |
| 670 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 671 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 672 | |
| 673 | second |
| 674 | EOF |
| 675 | |
| 676 | git cat-file commit branch | sed 1d >actual && |
| 677 | test_cmp expect actual |
| 678 | ' |
| 679 | |
| 680 | test_expect_success 'C: validate rename result' ' |
| 681 | zero=$ZERO_OID && |
| 682 | cat >expect <<-EOF && |
| 683 | :000000 100755 $zero $newf A file2/newf |
| 684 | :100644 100644 $oldf $oldf R100 file2 file2/oldf |
| 685 | :100644 000000 $thrf $zero D file3 |
| 686 | EOF |
| 687 | git diff-tree -M -r main branch >actual && |
| 688 | compare_diff_raw expect actual |
| 689 | ' |
| 690 | |
| 691 | ### |
| 692 | ### series D |
| 693 | ### |
| 694 | |
| 695 | test_expect_success 'D: inline data in commit' ' |
| 696 | test_tick && |
| 697 | cat >input <<-INPUT_END && |
| 698 | commit refs/heads/branch |
| 699 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 700 | data <<COMMIT |
| 701 | third |
| 702 | COMMIT |
| 703 | |
| 704 | from refs/heads/branch^0 |
| 705 | M 644 inline newdir/interesting |
| 706 | data <<EOF |
| 707 | $file5_data |
| 708 | EOF |
| 709 | |
| 710 | M 755 inline newdir/exec.sh |
| 711 | data <<EOF |
| 712 | $file6_data |
| 713 | EOF |
| 714 | |
| 715 | INPUT_END |
| 716 | |
| 717 | git fast-import <input && |
| 718 | git log --raw branch |
| 719 | ' |
| 720 | |
| 721 | test_expect_success 'D: verify pack' ' |
| 722 | verify_packs |
| 723 | ' |
| 724 | |
| 725 | test_expect_success 'D: validate new files added' ' |
| 726 | f5id=$(echo "$file5_data" | git hash-object --stdin) && |
| 727 | f6id=$(echo "$file6_data" | git hash-object --stdin) && |
| 728 | cat >expect <<-EOF && |
| 729 | :000000 100755 $ZERO_OID $f6id A newdir/exec.sh |
| 730 | :000000 100644 $ZERO_OID $f5id A newdir/interesting |
| 731 | EOF |
| 732 | git diff-tree -M -r branch^ branch >actual && |
| 733 | compare_diff_raw expect actual |
| 734 | ' |
| 735 | |
| 736 | test_expect_success 'D: verify file5' ' |
| 737 | echo "$file5_data" >expect && |
| 738 | git cat-file blob branch:newdir/interesting >actual && |
| 739 | test_cmp expect actual |
| 740 | ' |
| 741 | |
| 742 | test_expect_success 'D: verify file6' ' |
| 743 | echo "$file6_data" >expect && |
| 744 | git cat-file blob branch:newdir/exec.sh >actual && |
| 745 | test_cmp expect actual |
| 746 | ' |
| 747 | |
| 748 | ### |
| 749 | ### series E |
| 750 | ### |
| 751 | |
| 752 | test_expect_success 'E: rfc2822 date, --date-format=raw' ' |
| 753 | cat >input <<-INPUT_END && |
| 754 | commit refs/heads/branch |
| 755 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 |
| 756 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 |
| 757 | data <<COMMIT |
| 758 | RFC 2822 type date |
| 759 | COMMIT |
| 760 | |
| 761 | from refs/heads/branch^0 |
| 762 | |
| 763 | INPUT_END |
| 764 | |
| 765 | test_must_fail git fast-import --date-format=raw <input |
| 766 | ' |
| 767 | test_expect_success 'E: rfc2822 date, --date-format=rfc2822' ' |
| 768 | git fast-import --date-format=rfc2822 <input |
| 769 | ' |
| 770 | |
| 771 | test_expect_success 'E: verify pack' ' |
| 772 | verify_packs |
| 773 | ' |
| 774 | |
| 775 | test_expect_success 'E: verify commit' ' |
| 776 | cat >expect <<-EOF && |
| 777 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 |
| 778 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 |
| 779 | |
| 780 | RFC 2822 type date |
| 781 | EOF |
| 782 | git cat-file commit branch | sed 1,2d >actual && |
| 783 | test_cmp expect actual |
| 784 | ' |
| 785 | |
| 786 | ### |
| 787 | ### series F |
| 788 | ### |
| 789 | |
| 790 | test_expect_success 'F: non-fast-forward update skips' ' |
| 791 | old_branch=$(git rev-parse --verify branch^0) && |
| 792 | test_tick && |
| 793 | cat >input <<-INPUT_END && |
| 794 | commit refs/heads/branch |
| 795 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 796 | data <<COMMIT |
| 797 | losing things already? |
| 798 | COMMIT |
| 799 | |
| 800 | from refs/heads/branch~1 |
| 801 | |
| 802 | reset refs/heads/other |
| 803 | from refs/heads/branch |
| 804 | |
| 805 | INPUT_END |
| 806 | |
| 807 | test_must_fail git fast-import <input && |
| 808 | # branch must remain unaffected |
| 809 | test $old_branch = $(git rev-parse --verify branch^0) |
| 810 | ' |
| 811 | |
| 812 | test_expect_success 'F: verify pack' ' |
| 813 | verify_packs |
| 814 | ' |
| 815 | |
| 816 | test_expect_success 'F: verify other commit' ' |
| 817 | cat >expect <<-EOF && |
| 818 | tree $(git rev-parse branch~1^{tree}) |
| 819 | parent $(git rev-parse branch~1) |
| 820 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 821 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 822 | |
| 823 | losing things already? |
| 824 | EOF |
| 825 | git cat-file commit other >actual && |
| 826 | test_cmp expect actual |
| 827 | ' |
| 828 | |
| 829 | ### |
| 830 | ### series G |
| 831 | ### |
| 832 | |
| 833 | test_expect_success 'G: non-fast-forward update forced' ' |
| 834 | old_branch=$(git rev-parse --verify branch^0) && |
| 835 | test_tick && |
| 836 | cat >input <<-INPUT_END && |
| 837 | commit refs/heads/branch |
| 838 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 839 | data <<COMMIT |
| 840 | losing things already? |
| 841 | COMMIT |
| 842 | |
| 843 | from refs/heads/branch~1 |
| 844 | |
| 845 | INPUT_END |
| 846 | git fast-import --force <input |
| 847 | ' |
| 848 | |
| 849 | test_expect_success 'G: verify pack' ' |
| 850 | verify_packs |
| 851 | ' |
| 852 | |
| 853 | test_expect_success 'G: branch changed, but logged' ' |
| 854 | test $old_branch != $(git rev-parse --verify branch^0) && |
| 855 | test $old_branch = $(git rev-parse --verify branch@{1}) |
| 856 | ' |
| 857 | |
| 858 | ### |
| 859 | ### series H |
| 860 | ### |
| 861 | |
| 862 | test_expect_success 'H: deletall, add 1' ' |
| 863 | test_tick && |
| 864 | cat >input <<-INPUT_END && |
| 865 | commit refs/heads/H |
| 866 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 867 | data <<COMMIT |
| 868 | third |
| 869 | COMMIT |
| 870 | |
| 871 | from refs/heads/branch^0 |
| 872 | M 644 inline i-will-die |
| 873 | data <<EOF |
| 874 | this file will never exist. |
| 875 | EOF |
| 876 | |
| 877 | deleteall |
| 878 | M 644 inline h/e/l/lo |
| 879 | data <<EOF |
| 880 | $file5_data |
| 881 | EOF |
| 882 | |
| 883 | INPUT_END |
| 884 | git fast-import <input && |
| 885 | git log --raw H |
| 886 | ' |
| 887 | |
| 888 | test_expect_success 'H: verify pack' ' |
| 889 | verify_packs |
| 890 | ' |
| 891 | |
| 892 | test_expect_success 'H: validate old files removed, new files added' ' |
| 893 | f4id=$(git rev-parse HEAD:file4) && |
| 894 | cat >expect <<-EOF && |
| 895 | :100755 000000 $newf $zero D file2/newf |
| 896 | :100644 000000 $oldf $zero D file2/oldf |
| 897 | :100755 000000 $f4id $zero D file4 |
| 898 | :100644 100644 $f5id $f5id R100 newdir/interesting h/e/l/lo |
| 899 | :100755 000000 $f6id $zero D newdir/exec.sh |
| 900 | EOF |
| 901 | git diff-tree -M -r H^ H >actual && |
| 902 | compare_diff_raw expect actual |
| 903 | ' |
| 904 | |
| 905 | test_expect_success 'H: verify file' ' |
| 906 | echo "$file5_data" >expect && |
| 907 | git cat-file blob H:h/e/l/lo >actual && |
| 908 | test_cmp expect actual |
| 909 | ' |
| 910 | |
| 911 | ### |
| 912 | ### series I |
| 913 | ### |
| 914 | |
| 915 | test_expect_success 'I: export-pack-edges' ' |
| 916 | cat >input <<-INPUT_END && |
| 917 | commit refs/heads/export-boundary |
| 918 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 919 | data <<COMMIT |
| 920 | we have a border. its only 40 characters wide. |
| 921 | COMMIT |
| 922 | |
| 923 | from refs/heads/branch |
| 924 | |
| 925 | INPUT_END |
| 926 | git fast-import --export-pack-edges=edges.list <input |
| 927 | ' |
| 928 | |
| 929 | test_expect_success 'I: verify edge list' ' |
| 930 | cat >expect <<-EOF && |
| 931 | .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary) |
| 932 | EOF |
| 933 | sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && |
| 934 | test_cmp expect actual |
| 935 | ' |
| 936 | |
| 937 | ### |
| 938 | ### series J |
| 939 | ### |
| 940 | |
| 941 | test_expect_success 'J: reset existing branch creates empty commit' ' |
| 942 | cat >input <<-INPUT_END && |
| 943 | commit refs/heads/J |
| 944 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 945 | data <<COMMIT |
| 946 | create J |
| 947 | COMMIT |
| 948 | |
| 949 | from refs/heads/branch |
| 950 | |
| 951 | reset refs/heads/J |
| 952 | |
| 953 | commit refs/heads/J |
| 954 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 955 | data <<COMMIT |
| 956 | initialize J |
| 957 | COMMIT |
| 958 | |
| 959 | INPUT_END |
| 960 | git fast-import <input |
| 961 | ' |
| 962 | test_expect_success 'J: branch has 1 commit, empty tree' ' |
| 963 | test 1 = $(git rev-list J | wc -l) && |
| 964 | test 0 = $(git ls-tree J | wc -l) |
| 965 | ' |
| 966 | |
| 967 | test_expect_success 'J: tag must fail on empty branch' ' |
| 968 | cat >input <<-INPUT_END && |
| 969 | reset refs/heads/J2 |
| 970 | |
| 971 | tag wrong_tag |
| 972 | from refs/heads/J2 |
| 973 | data <<EOF |
| 974 | Tag branch that was reset. |
| 975 | EOF |
| 976 | INPUT_END |
| 977 | test_must_fail git fast-import <input |
| 978 | ' |
| 979 | |
| 980 | ### |
| 981 | ### series K |
| 982 | ### |
| 983 | |
| 984 | test_expect_success 'K: reinit branch with from' ' |
| 985 | cat >input <<-INPUT_END && |
| 986 | commit refs/heads/K |
| 987 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 988 | data <<COMMIT |
| 989 | create K |
| 990 | COMMIT |
| 991 | |
| 992 | from refs/heads/branch |
| 993 | |
| 994 | commit refs/heads/K |
| 995 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 996 | data <<COMMIT |
| 997 | redo K |
| 998 | COMMIT |
| 999 | |
| 1000 | from refs/heads/branch^1 |
| 1001 | |
| 1002 | INPUT_END |
| 1003 | git fast-import <input |
| 1004 | ' |
| 1005 | test_expect_success 'K: verify K^1 = branch^1' ' |
| 1006 | test $(git rev-parse --verify branch^1) \ |
| 1007 | = $(git rev-parse --verify K^1) |
| 1008 | ' |
| 1009 | |
| 1010 | ### |
| 1011 | ### series L |
| 1012 | ### |
| 1013 | |
| 1014 | test_expect_success 'L: verify internal tree sorting' ' |
| 1015 | cat >input <<-INPUT_END && |
| 1016 | blob |
| 1017 | mark :1 |
| 1018 | data <<EOF |
| 1019 | some data |
| 1020 | EOF |
| 1021 | |
| 1022 | blob |
| 1023 | mark :2 |
| 1024 | data <<EOF |
| 1025 | other data |
| 1026 | EOF |
| 1027 | |
| 1028 | commit refs/heads/L |
| 1029 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1030 | data <<COMMIT |
| 1031 | create L |
| 1032 | COMMIT |
| 1033 | |
| 1034 | M 644 :1 b. |
| 1035 | M 644 :1 b/other |
| 1036 | M 644 :1 ba |
| 1037 | |
| 1038 | commit refs/heads/L |
| 1039 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1040 | data <<COMMIT |
| 1041 | update L |
| 1042 | COMMIT |
| 1043 | |
| 1044 | M 644 :2 b. |
| 1045 | M 644 :2 b/other |
| 1046 | M 644 :2 ba |
| 1047 | INPUT_END |
| 1048 | |
| 1049 | cat >expect <<-EXPECT_END && |
| 1050 | :100644 100644 M b. |
| 1051 | :040000 040000 M b |
| 1052 | :100644 100644 M ba |
| 1053 | EXPECT_END |
| 1054 | |
| 1055 | git -c core.protectNTFS=false fast-import <input && |
| 1056 | GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev --raw L^ L >output && |
| 1057 | cut -d" " -f1,2,5 output >actual && |
| 1058 | test_cmp expect actual |
| 1059 | ' |
| 1060 | |
| 1061 | test_expect_success 'L: nested tree copy does not corrupt deltas' ' |
| 1062 | cat >input <<-INPUT_END && |
| 1063 | blob |
| 1064 | mark :1 |
| 1065 | data <<EOF |
| 1066 | the data |
| 1067 | EOF |
| 1068 | |
| 1069 | commit refs/heads/L2 |
| 1070 | committer C O Mitter <committer@example.com> 1112912473 -0700 |
| 1071 | data <<COMMIT |
| 1072 | init L2 |
| 1073 | COMMIT |
| 1074 | M 644 :1 a/b/c |
| 1075 | M 644 :1 a/b/d |
| 1076 | M 644 :1 a/e/f |
| 1077 | |
| 1078 | commit refs/heads/L2 |
| 1079 | committer C O Mitter <committer@example.com> 1112912473 -0700 |
| 1080 | data <<COMMIT |
| 1081 | update L2 |
| 1082 | COMMIT |
| 1083 | C a g |
| 1084 | C a/e g/b |
| 1085 | M 644 :1 g/b/h |
| 1086 | INPUT_END |
| 1087 | |
| 1088 | cat >expect <<-\EOF && |
| 1089 | g/b/f |
| 1090 | g/b/h |
| 1091 | EOF |
| 1092 | |
| 1093 | test_when_finished "git update-ref -d refs/heads/L2" && |
| 1094 | git fast-import <input && |
| 1095 | git ls-tree L2 g/b/ >tmp && |
| 1096 | cut -f 2 <tmp >actual && |
| 1097 | test_cmp expect actual && |
| 1098 | git fsck $(git rev-parse L2) |
| 1099 | ' |
| 1100 | |
| 1101 | ### |
| 1102 | ### series M |
| 1103 | ### |
| 1104 | |
| 1105 | test_expect_success 'M: rename file in same subdirectory' ' |
| 1106 | test_tick && |
| 1107 | cat >input <<-INPUT_END && |
| 1108 | commit refs/heads/M1 |
| 1109 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1110 | data <<COMMIT |
| 1111 | file rename |
| 1112 | COMMIT |
| 1113 | |
| 1114 | from refs/heads/branch^0 |
| 1115 | R file2/newf file2/n.e.w.f |
| 1116 | |
| 1117 | INPUT_END |
| 1118 | |
| 1119 | cat >expect <<-EOF && |
| 1120 | :100755 100755 $newf $newf R100 file2/newf file2/n.e.w.f |
| 1121 | EOF |
| 1122 | git fast-import <input && |
| 1123 | git diff-tree -M -r M1^ M1 >actual && |
| 1124 | compare_diff_raw expect actual |
| 1125 | ' |
| 1126 | |
| 1127 | test_expect_success 'M: rename file to new subdirectory' ' |
| 1128 | cat >input <<-INPUT_END && |
| 1129 | commit refs/heads/M2 |
| 1130 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1131 | data <<COMMIT |
| 1132 | file rename |
| 1133 | COMMIT |
| 1134 | |
| 1135 | from refs/heads/branch^0 |
| 1136 | R file2/newf i/am/new/to/you |
| 1137 | |
| 1138 | INPUT_END |
| 1139 | |
| 1140 | cat >expect <<-EOF && |
| 1141 | :100755 100755 $newf $newf R100 file2/newf i/am/new/to/you |
| 1142 | EOF |
| 1143 | git fast-import <input && |
| 1144 | git diff-tree -M -r M2^ M2 >actual && |
| 1145 | compare_diff_raw expect actual |
| 1146 | ' |
| 1147 | |
| 1148 | test_expect_success 'M: rename subdirectory to new subdirectory' ' |
| 1149 | cat >input <<-INPUT_END && |
| 1150 | commit refs/heads/M3 |
| 1151 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1152 | data <<COMMIT |
| 1153 | file rename |
| 1154 | COMMIT |
| 1155 | |
| 1156 | from refs/heads/M2^0 |
| 1157 | R i other/sub |
| 1158 | |
| 1159 | INPUT_END |
| 1160 | |
| 1161 | cat >expect <<-EOF && |
| 1162 | :100755 100755 $newf $newf R100 i/am/new/to/you other/sub/am/new/to/you |
| 1163 | EOF |
| 1164 | git fast-import <input && |
| 1165 | git diff-tree -M -r M3^ M3 >actual && |
| 1166 | compare_diff_raw expect actual |
| 1167 | ' |
| 1168 | |
| 1169 | for root in '""' '' |
| 1170 | do |
| 1171 | test_expect_success "M: rename root ($root) to subdirectory" ' |
| 1172 | cat >input <<-INPUT_END && |
| 1173 | commit refs/heads/M4 |
| 1174 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1175 | data <<COMMIT |
| 1176 | rename root |
| 1177 | COMMIT |
| 1178 | |
| 1179 | from refs/heads/M2^0 |
| 1180 | R $root sub |
| 1181 | |
| 1182 | INPUT_END |
| 1183 | |
| 1184 | cat >expect <<-EOF && |
| 1185 | :100644 100644 $oldf $oldf R100 file2/oldf sub/file2/oldf |
| 1186 | :100755 100755 $f4id $f4id R100 file4 sub/file4 |
| 1187 | :100755 100755 $newf $newf R100 i/am/new/to/you sub/i/am/new/to/you |
| 1188 | :100755 100755 $f6id $f6id R100 newdir/exec.sh sub/newdir/exec.sh |
| 1189 | :100644 100644 $f5id $f5id R100 newdir/interesting sub/newdir/interesting |
| 1190 | EOF |
| 1191 | git fast-import <input && |
| 1192 | git diff-tree -M -r M4^ M4 >actual && |
| 1193 | compare_diff_raw expect actual |
| 1194 | ' |
| 1195 | done |
| 1196 | |
| 1197 | ### |
| 1198 | ### series N |
| 1199 | ### |
| 1200 | |
| 1201 | test_expect_success 'N: copy file in same subdirectory' ' |
| 1202 | test_tick && |
| 1203 | cat >input <<-INPUT_END && |
| 1204 | commit refs/heads/N1 |
| 1205 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1206 | data <<COMMIT |
| 1207 | file copy |
| 1208 | COMMIT |
| 1209 | |
| 1210 | from refs/heads/branch^0 |
| 1211 | C file2/newf file2/n.e.w.f |
| 1212 | |
| 1213 | INPUT_END |
| 1214 | |
| 1215 | cat >expect <<-EOF && |
| 1216 | :100755 100755 $newf $newf C100 file2/newf file2/n.e.w.f |
| 1217 | EOF |
| 1218 | git fast-import <input && |
| 1219 | git diff-tree -C --find-copies-harder -r N1^ N1 >actual && |
| 1220 | compare_diff_raw expect actual |
| 1221 | ' |
| 1222 | |
| 1223 | test_expect_success 'N: copy then modify subdirectory' ' |
| 1224 | cat >input <<-INPUT_END && |
| 1225 | commit refs/heads/N2 |
| 1226 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1227 | data <<COMMIT |
| 1228 | clean directory copy |
| 1229 | COMMIT |
| 1230 | |
| 1231 | from refs/heads/branch^0 |
| 1232 | C file2 file3 |
| 1233 | |
| 1234 | commit refs/heads/N2 |
| 1235 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1236 | data <<COMMIT |
| 1237 | modify directory copy |
| 1238 | COMMIT |
| 1239 | |
| 1240 | M 644 inline file3/file5 |
| 1241 | data <<EOF |
| 1242 | $file5_data |
| 1243 | EOF |
| 1244 | |
| 1245 | INPUT_END |
| 1246 | |
| 1247 | cat >expect <<-EOF && |
| 1248 | :100644 100644 $f5id $f5id C100 newdir/interesting file3/file5 |
| 1249 | :100755 100755 $newf $newf C100 file2/newf file3/newf |
| 1250 | :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf |
| 1251 | EOF |
| 1252 | git fast-import <input && |
| 1253 | git diff-tree -C --find-copies-harder -r N2^^ N2 >actual && |
| 1254 | compare_diff_raw expect actual |
| 1255 | ' |
| 1256 | |
| 1257 | test_expect_success 'N: copy dirty subdirectory' ' |
| 1258 | cat >input <<-INPUT_END && |
| 1259 | commit refs/heads/N3 |
| 1260 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1261 | data <<COMMIT |
| 1262 | dirty directory copy |
| 1263 | COMMIT |
| 1264 | |
| 1265 | from refs/heads/branch^0 |
| 1266 | M 644 inline file2/file5 |
| 1267 | data <<EOF |
| 1268 | $file5_data |
| 1269 | EOF |
| 1270 | |
| 1271 | C file2 file3 |
| 1272 | D file2/file5 |
| 1273 | |
| 1274 | INPUT_END |
| 1275 | |
| 1276 | git fast-import <input && |
| 1277 | test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree}) |
| 1278 | ' |
| 1279 | |
| 1280 | test_expect_success 'N: copy directory by id' ' |
| 1281 | cat >expect <<-EOF && |
| 1282 | :100755 100755 $newf $newf C100 file2/newf file3/newf |
| 1283 | :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf |
| 1284 | EOF |
| 1285 | subdir=$(git rev-parse refs/heads/branch^0:file2) && |
| 1286 | cat >input <<-INPUT_END && |
| 1287 | commit refs/heads/N4 |
| 1288 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1289 | data <<COMMIT |
| 1290 | copy by tree hash |
| 1291 | COMMIT |
| 1292 | |
| 1293 | from refs/heads/branch^0 |
| 1294 | M 040000 $subdir file3 |
| 1295 | INPUT_END |
| 1296 | git fast-import <input && |
| 1297 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && |
| 1298 | compare_diff_raw expect actual |
| 1299 | ' |
| 1300 | |
| 1301 | test_expect_success PIPE 'N: read and copy directory' ' |
| 1302 | cat >expect <<-EOF && |
| 1303 | :100755 100755 $newf $newf C100 file2/newf file3/newf |
| 1304 | :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf |
| 1305 | EOF |
| 1306 | git update-ref -d refs/heads/N4 && |
| 1307 | rm -f backflow && |
| 1308 | mkfifo backflow && |
| 1309 | ( |
| 1310 | exec <backflow && |
| 1311 | cat <<-EOF && |
| 1312 | commit refs/heads/N4 |
| 1313 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1314 | data <<COMMIT |
| 1315 | copy by tree hash, part 2 |
| 1316 | COMMIT |
| 1317 | |
| 1318 | from refs/heads/branch^0 |
| 1319 | ls "file2" |
| 1320 | EOF |
| 1321 | read mode type tree filename && |
| 1322 | echo "M 040000 $tree file3" |
| 1323 | ) | |
| 1324 | git fast-import --cat-blob-fd=3 3>backflow && |
| 1325 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && |
| 1326 | compare_diff_raw expect actual |
| 1327 | ' |
| 1328 | |
| 1329 | test_expect_success PIPE 'N: empty directory reads as missing' ' |
| 1330 | cat <<-\EOF >expect && |
| 1331 | OBJNAME |
| 1332 | :000000 100644 OBJNAME OBJNAME A unrelated |
| 1333 | EOF |
| 1334 | echo "missing src" >expect.response && |
| 1335 | git update-ref -d refs/heads/read-empty && |
| 1336 | rm -f backflow && |
| 1337 | mkfifo backflow && |
| 1338 | ( |
| 1339 | exec <backflow && |
| 1340 | cat <<-EOF && |
| 1341 | commit refs/heads/read-empty |
| 1342 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1343 | data <<COMMIT |
| 1344 | read "empty" (missing) directory |
| 1345 | COMMIT |
| 1346 | |
| 1347 | M 100644 inline src/greeting |
| 1348 | data <<BLOB |
| 1349 | hello |
| 1350 | BLOB |
| 1351 | C src/greeting dst1/non-greeting |
| 1352 | C src/greeting unrelated |
| 1353 | # leave behind "empty" src directory |
| 1354 | D src/greeting |
| 1355 | ls "src" |
| 1356 | EOF |
| 1357 | read -r line && |
| 1358 | printf "%s\n" "$line" >response && |
| 1359 | cat <<-\EOF |
| 1360 | D dst1 |
| 1361 | D dst2 |
| 1362 | EOF |
| 1363 | ) | |
| 1364 | git fast-import --cat-blob-fd=3 3>backflow && |
| 1365 | test_cmp expect.response response && |
| 1366 | git rev-list read-empty | |
| 1367 | git diff-tree -r --root --stdin | |
| 1368 | sed "s/$OID_REGEX/OBJNAME/g" >actual && |
| 1369 | test_cmp expect actual |
| 1370 | ' |
| 1371 | |
| 1372 | for root in '""' '' |
| 1373 | do |
| 1374 | test_expect_success "N: copy root ($root) by tree hash" ' |
| 1375 | cat >expect <<-EOF && |
| 1376 | :100755 000000 $newf $zero D file3/newf |
| 1377 | :100644 000000 $oldf $zero D file3/oldf |
| 1378 | EOF |
| 1379 | root_tree=$(git rev-parse refs/heads/branch^0^{tree}) && |
| 1380 | cat >input <<-INPUT_END && |
| 1381 | commit refs/heads/N6 |
| 1382 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1383 | data <<COMMIT |
| 1384 | copy root directory by tree hash |
| 1385 | COMMIT |
| 1386 | |
| 1387 | from refs/heads/branch^0 |
| 1388 | M 040000 $root_tree $root |
| 1389 | INPUT_END |
| 1390 | git fast-import <input && |
| 1391 | git diff-tree -C --find-copies-harder -r N4 N6 >actual && |
| 1392 | compare_diff_raw expect actual |
| 1393 | ' |
| 1394 | |
| 1395 | test_expect_success "N: copy root ($root) by path" ' |
| 1396 | cat >expect <<-EOF && |
| 1397 | :100755 100755 $newf $newf C100 file2/newf oldroot/file2/newf |
| 1398 | :100644 100644 $oldf $oldf C100 file2/oldf oldroot/file2/oldf |
| 1399 | :100755 100755 $f4id $f4id C100 file4 oldroot/file4 |
| 1400 | :100755 100755 $f6id $f6id C100 newdir/exec.sh oldroot/newdir/exec.sh |
| 1401 | :100644 100644 $f5id $f5id C100 newdir/interesting oldroot/newdir/interesting |
| 1402 | EOF |
| 1403 | cat >input <<-INPUT_END && |
| 1404 | commit refs/heads/N-copy-root-path |
| 1405 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1406 | data <<COMMIT |
| 1407 | copy root directory by (empty) path |
| 1408 | COMMIT |
| 1409 | |
| 1410 | from refs/heads/branch^0 |
| 1411 | C $root oldroot |
| 1412 | INPUT_END |
| 1413 | git fast-import <input && |
| 1414 | git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual && |
| 1415 | compare_diff_raw expect actual |
| 1416 | ' |
| 1417 | done |
| 1418 | |
| 1419 | test_expect_success 'N: delete directory by copying' ' |
| 1420 | cat >expect <<-\EOF && |
| 1421 | OBJID |
| 1422 | :100644 000000 OBJID OBJID D foo/bar/qux |
| 1423 | OBJID |
| 1424 | :000000 100644 OBJID OBJID A foo/bar/baz |
| 1425 | :000000 100644 OBJID OBJID A foo/bar/qux |
| 1426 | EOF |
| 1427 | empty_tree=$(git mktree </dev/null) && |
| 1428 | cat >input <<-INPUT_END && |
| 1429 | commit refs/heads/N-delete |
| 1430 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1431 | data <<COMMIT |
| 1432 | collect data to be deleted |
| 1433 | COMMIT |
| 1434 | |
| 1435 | deleteall |
| 1436 | M 100644 inline foo/bar/baz |
| 1437 | data <<DATA_END |
| 1438 | hello |
| 1439 | DATA_END |
| 1440 | C "foo/bar/baz" "foo/bar/qux" |
| 1441 | C "foo/bar/baz" "foo/bar/quux/1" |
| 1442 | C "foo/bar/baz" "foo/bar/quuux" |
| 1443 | M 040000 $empty_tree foo/bar/quux |
| 1444 | M 040000 $empty_tree foo/bar/quuux |
| 1445 | |
| 1446 | commit refs/heads/N-delete |
| 1447 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1448 | data <<COMMIT |
| 1449 | delete subdirectory |
| 1450 | COMMIT |
| 1451 | |
| 1452 | M 040000 $empty_tree foo/bar/qux |
| 1453 | INPUT_END |
| 1454 | git fast-import <input && |
| 1455 | git rev-list N-delete | |
| 1456 | git diff-tree -r --stdin --root --always | |
| 1457 | sed -e "s/$OID_REGEX/OBJID/g" >actual && |
| 1458 | test_cmp expect actual |
| 1459 | ' |
| 1460 | |
| 1461 | test_expect_success 'N: modify copied tree' ' |
| 1462 | cat >expect <<-EOF && |
| 1463 | :100644 100644 $f5id $f5id C100 newdir/interesting file3/file5 |
| 1464 | :100755 100755 $newf $newf C100 file2/newf file3/newf |
| 1465 | :100644 100644 $oldf $oldf C100 file2/oldf file3/oldf |
| 1466 | EOF |
| 1467 | subdir=$(git rev-parse refs/heads/branch^0:file2) && |
| 1468 | cat >input <<-INPUT_END && |
| 1469 | commit refs/heads/N5 |
| 1470 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1471 | data <<COMMIT |
| 1472 | copy by tree hash |
| 1473 | COMMIT |
| 1474 | |
| 1475 | from refs/heads/branch^0 |
| 1476 | M 040000 $subdir file3 |
| 1477 | |
| 1478 | commit refs/heads/N5 |
| 1479 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1480 | data <<COMMIT |
| 1481 | modify directory copy |
| 1482 | COMMIT |
| 1483 | |
| 1484 | M 644 inline file3/file5 |
| 1485 | data <<EOF |
| 1486 | $file5_data |
| 1487 | EOF |
| 1488 | INPUT_END |
| 1489 | git fast-import <input && |
| 1490 | git diff-tree -C --find-copies-harder -r N5^^ N5 >actual && |
| 1491 | compare_diff_raw expect actual |
| 1492 | ' |
| 1493 | |
| 1494 | test_expect_success 'N: reject foo/ syntax' ' |
| 1495 | subdir=$(git rev-parse refs/heads/branch^0:file2) && |
| 1496 | test_must_fail git fast-import <<-INPUT_END |
| 1497 | commit refs/heads/N5B |
| 1498 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1499 | data <<COMMIT |
| 1500 | copy with invalid syntax |
| 1501 | COMMIT |
| 1502 | |
| 1503 | from refs/heads/branch^0 |
| 1504 | M 040000 $subdir file3/ |
| 1505 | INPUT_END |
| 1506 | ' |
| 1507 | |
| 1508 | test_expect_success 'N: reject foo/ syntax in copy source' ' |
| 1509 | test_must_fail git fast-import <<-INPUT_END |
| 1510 | commit refs/heads/N5C |
| 1511 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1512 | data <<COMMIT |
| 1513 | copy with invalid syntax |
| 1514 | COMMIT |
| 1515 | |
| 1516 | from refs/heads/branch^0 |
| 1517 | C file2/ file3 |
| 1518 | INPUT_END |
| 1519 | ' |
| 1520 | |
| 1521 | test_expect_success 'N: reject foo/ syntax in rename source' ' |
| 1522 | test_must_fail git fast-import <<-INPUT_END |
| 1523 | commit refs/heads/N5D |
| 1524 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1525 | data <<COMMIT |
| 1526 | rename with invalid syntax |
| 1527 | COMMIT |
| 1528 | |
| 1529 | from refs/heads/branch^0 |
| 1530 | R file2/ file3 |
| 1531 | INPUT_END |
| 1532 | ' |
| 1533 | |
| 1534 | test_expect_success 'N: reject foo/ syntax in ls argument' ' |
| 1535 | test_must_fail git fast-import <<-INPUT_END |
| 1536 | commit refs/heads/N5E |
| 1537 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1538 | data <<COMMIT |
| 1539 | copy with invalid syntax |
| 1540 | COMMIT |
| 1541 | |
| 1542 | from refs/heads/branch^0 |
| 1543 | ls "file2/" |
| 1544 | INPUT_END |
| 1545 | ' |
| 1546 | |
| 1547 | for root in '""' '' |
| 1548 | do |
| 1549 | test_expect_success "N: copy to root ($root) by id and modify" ' |
| 1550 | echo "hello, world" >expect.foo && |
| 1551 | echo hello >expect.bar && |
| 1552 | git fast-import <<-SETUP_END && |
| 1553 | commit refs/heads/N7 |
| 1554 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1555 | data <<COMMIT |
| 1556 | hello, tree |
| 1557 | COMMIT |
| 1558 | |
| 1559 | deleteall |
| 1560 | M 644 inline foo/bar |
| 1561 | data <<EOF |
| 1562 | hello |
| 1563 | EOF |
| 1564 | SETUP_END |
| 1565 | |
| 1566 | tree=$(git rev-parse --verify N7:) && |
| 1567 | git fast-import <<-INPUT_END && |
| 1568 | commit refs/heads/N8 |
| 1569 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1570 | data <<COMMIT |
| 1571 | copy to root by id and modify |
| 1572 | COMMIT |
| 1573 | |
| 1574 | M 040000 $tree $root |
| 1575 | M 644 inline foo/foo |
| 1576 | data <<EOF |
| 1577 | hello, world |
| 1578 | EOF |
| 1579 | INPUT_END |
| 1580 | git show N8:foo/foo >actual.foo && |
| 1581 | git show N8:foo/bar >actual.bar && |
| 1582 | test_cmp expect.foo actual.foo && |
| 1583 | test_cmp expect.bar actual.bar |
| 1584 | ' |
| 1585 | |
| 1586 | test_expect_success "N: extract subtree to the root ($root)" ' |
| 1587 | branch=$(git rev-parse --verify refs/heads/branch^{tree}) && |
| 1588 | cat >input <<-INPUT_END && |
| 1589 | commit refs/heads/N9 |
| 1590 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1591 | data <<COMMIT |
| 1592 | extract subtree branch:newdir |
| 1593 | COMMIT |
| 1594 | |
| 1595 | M 040000 $branch $root |
| 1596 | C "newdir" $root |
| 1597 | INPUT_END |
| 1598 | git fast-import <input && |
| 1599 | git diff --exit-code branch:newdir N9 |
| 1600 | ' |
| 1601 | |
| 1602 | test_expect_success "N: modify subtree, extract it to the root ($root), and modify again" ' |
| 1603 | echo hello >expect.baz && |
| 1604 | echo hello, world >expect.qux && |
| 1605 | git fast-import <<-SETUP_END && |
| 1606 | commit refs/heads/N10 |
| 1607 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1608 | data <<COMMIT |
| 1609 | hello, tree |
| 1610 | COMMIT |
| 1611 | |
| 1612 | deleteall |
| 1613 | M 644 inline foo/bar/baz |
| 1614 | data <<EOF |
| 1615 | hello |
| 1616 | EOF |
| 1617 | SETUP_END |
| 1618 | |
| 1619 | tree=$(git rev-parse --verify N10:) && |
| 1620 | git fast-import <<-INPUT_END && |
| 1621 | commit refs/heads/N11 |
| 1622 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1623 | data <<COMMIT |
| 1624 | copy to root by id and modify |
| 1625 | COMMIT |
| 1626 | |
| 1627 | M 040000 $tree $root |
| 1628 | M 100644 inline foo/bar/qux |
| 1629 | data <<EOF |
| 1630 | hello, world |
| 1631 | EOF |
| 1632 | R "foo" $root |
| 1633 | C "bar/qux" "bar/quux" |
| 1634 | INPUT_END |
| 1635 | git show N11:bar/baz >actual.baz && |
| 1636 | git show N11:bar/qux >actual.qux && |
| 1637 | git show N11:bar/quux >actual.quux && |
| 1638 | test_cmp expect.baz actual.baz && |
| 1639 | test_cmp expect.qux actual.qux && |
| 1640 | test_cmp expect.qux actual.quux |
| 1641 | ' |
| 1642 | done |
| 1643 | |
| 1644 | ### |
| 1645 | ### series O |
| 1646 | ### |
| 1647 | |
| 1648 | test_expect_success 'O: comments are all skipped' ' |
| 1649 | cat >input <<-INPUT_END && |
| 1650 | #we will |
| 1651 | commit refs/heads/O1 |
| 1652 | # -- ignore all of this text |
| 1653 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1654 | data <<COMMIT |
| 1655 | dirty directory copy |
| 1656 | COMMIT |
| 1657 | |
| 1658 | # do not forget the import blank line! |
| 1659 | # |
| 1660 | # yes, we started from our usual base of branch^0. |
| 1661 | # i like branch^0. |
| 1662 | from refs/heads/branch^0 |
| 1663 | # and we need to reuse file2/file5 from N3 above. |
| 1664 | M 644 inline file2/file5 |
| 1665 | # otherwise the tree will be different |
| 1666 | data <<EOF |
| 1667 | $file5_data |
| 1668 | EOF |
| 1669 | |
| 1670 | # do not forget to copy file2 to file3 |
| 1671 | C file2 file3 |
| 1672 | # |
| 1673 | # or to delete file5 from file2. |
| 1674 | D file2/file5 |
| 1675 | # are we done yet? |
| 1676 | |
| 1677 | INPUT_END |
| 1678 | |
| 1679 | git fast-import <input && |
| 1680 | test $(git rev-parse N3) = $(git rev-parse O1) |
| 1681 | ' |
| 1682 | |
| 1683 | test_expect_success 'O: blank lines not necessary after data commands' ' |
| 1684 | cat >input <<-INPUT_END && |
| 1685 | commit refs/heads/O2 |
| 1686 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1687 | data <<COMMIT |
| 1688 | dirty directory copy |
| 1689 | COMMIT |
| 1690 | from refs/heads/branch^0 |
| 1691 | M 644 inline file2/file5 |
| 1692 | data <<EOF |
| 1693 | $file5_data |
| 1694 | EOF |
| 1695 | C file2 file3 |
| 1696 | D file2/file5 |
| 1697 | |
| 1698 | INPUT_END |
| 1699 | |
| 1700 | git fast-import <input && |
| 1701 | test $(git rev-parse N3) = $(git rev-parse O2) |
| 1702 | ' |
| 1703 | |
| 1704 | test_expect_success 'O: repack before next test' ' |
| 1705 | git repack -a -d |
| 1706 | ' |
| 1707 | |
| 1708 | test_expect_success 'O: blank lines not necessary after other commands' ' |
| 1709 | cat >input <<-INPUT_END && |
| 1710 | commit refs/heads/O3 |
| 1711 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1712 | data <<COMMIT |
| 1713 | zstring |
| 1714 | COMMIT |
| 1715 | commit refs/heads/O3 |
| 1716 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1717 | data <<COMMIT |
| 1718 | zof |
| 1719 | COMMIT |
| 1720 | checkpoint |
| 1721 | commit refs/heads/O3 |
| 1722 | mark :5 |
| 1723 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1724 | data <<COMMIT |
| 1725 | zempty |
| 1726 | COMMIT |
| 1727 | checkpoint |
| 1728 | commit refs/heads/O3 |
| 1729 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1730 | data <<COMMIT |
| 1731 | zcommits |
| 1732 | COMMIT |
| 1733 | reset refs/tags/O3-2nd |
| 1734 | from :5 |
| 1735 | reset refs/tags/O3-3rd |
| 1736 | from :5 |
| 1737 | INPUT_END |
| 1738 | |
| 1739 | cat >expect <<-INPUT_END && |
| 1740 | string |
| 1741 | of |
| 1742 | empty |
| 1743 | commits |
| 1744 | INPUT_END |
| 1745 | |
| 1746 | git fast-import <input && |
| 1747 | ls -la .git/objects/pack/pack-*.pack >packlist && |
| 1748 | ls -la .git/objects/pack/pack-*.pack >idxlist && |
| 1749 | test_line_count = 4 idxlist && |
| 1750 | test_line_count = 4 packlist && |
| 1751 | test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) && |
| 1752 | git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && |
| 1753 | test_cmp expect actual |
| 1754 | ' |
| 1755 | |
| 1756 | test_expect_success 'O: progress outputs as requested by input' ' |
| 1757 | cat >input <<-INPUT_END && |
| 1758 | commit refs/heads/O4 |
| 1759 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1760 | data <<COMMIT |
| 1761 | zstring |
| 1762 | COMMIT |
| 1763 | commit refs/heads/O4 |
| 1764 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1765 | data <<COMMIT |
| 1766 | zof |
| 1767 | COMMIT |
| 1768 | progress Two commits down, 2 to go! |
| 1769 | commit refs/heads/O4 |
| 1770 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1771 | data <<COMMIT |
| 1772 | zempty |
| 1773 | COMMIT |
| 1774 | progress Three commits down, 1 to go! |
| 1775 | commit refs/heads/O4 |
| 1776 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1777 | data <<COMMIT |
| 1778 | zcommits |
| 1779 | COMMIT |
| 1780 | progress done! |
| 1781 | INPUT_END |
| 1782 | git fast-import <input >actual && |
| 1783 | grep "progress " <input >expect && |
| 1784 | test_cmp expect actual |
| 1785 | ' |
| 1786 | |
| 1787 | ### |
| 1788 | ### series P (gitlinks) |
| 1789 | ### |
| 1790 | |
| 1791 | test_expect_success 'P: superproject & submodule mix' ' |
| 1792 | cat >input <<-INPUT_END && |
| 1793 | blob |
| 1794 | mark :1 |
| 1795 | data 10 |
| 1796 | test file |
| 1797 | |
| 1798 | reset refs/heads/sub |
| 1799 | commit refs/heads/sub |
| 1800 | mark :2 |
| 1801 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1802 | data 12 |
| 1803 | sub_initial |
| 1804 | M 100644 :1 file |
| 1805 | |
| 1806 | blob |
| 1807 | mark :3 |
| 1808 | data <<DATAEND |
| 1809 | [submodule "sub"] |
| 1810 | path = sub |
| 1811 | url = "$(pwd)/sub" |
| 1812 | DATAEND |
| 1813 | |
| 1814 | commit refs/heads/subuse1 |
| 1815 | mark :4 |
| 1816 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1817 | data 8 |
| 1818 | initial |
| 1819 | from refs/heads/main |
| 1820 | M 100644 :3 .gitmodules |
| 1821 | M 160000 :2 sub |
| 1822 | |
| 1823 | blob |
| 1824 | mark :5 |
| 1825 | data 20 |
| 1826 | test file |
| 1827 | more data |
| 1828 | |
| 1829 | commit refs/heads/sub |
| 1830 | mark :6 |
| 1831 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1832 | data 11 |
| 1833 | sub_second |
| 1834 | from :2 |
| 1835 | M 100644 :5 file |
| 1836 | |
| 1837 | commit refs/heads/subuse1 |
| 1838 | mark :7 |
| 1839 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1840 | data 7 |
| 1841 | second |
| 1842 | from :4 |
| 1843 | M 160000 :6 sub |
| 1844 | |
| 1845 | INPUT_END |
| 1846 | |
| 1847 | git fast-import <input && |
| 1848 | git checkout subuse1 && |
| 1849 | rm -rf sub && |
| 1850 | mkdir sub && |
| 1851 | ( |
| 1852 | cd sub && |
| 1853 | git init && |
| 1854 | git fetch --update-head-ok .. refs/heads/sub:refs/heads/main && |
| 1855 | git checkout main |
| 1856 | ) && |
| 1857 | git submodule init && |
| 1858 | git submodule update |
| 1859 | ' |
| 1860 | |
| 1861 | test_expect_success 'P: verbatim SHA gitlinks' ' |
| 1862 | SUBLAST=$(git rev-parse --verify sub) && |
| 1863 | SUBPREV=$(git rev-parse --verify sub^) && |
| 1864 | |
| 1865 | cat >input <<-INPUT_END && |
| 1866 | blob |
| 1867 | mark :1 |
| 1868 | data <<DATAEND |
| 1869 | [submodule "sub"] |
| 1870 | path = sub |
| 1871 | url = "$(pwd)/sub" |
| 1872 | DATAEND |
| 1873 | |
| 1874 | commit refs/heads/subuse2 |
| 1875 | mark :2 |
| 1876 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1877 | data 8 |
| 1878 | initial |
| 1879 | from refs/heads/main |
| 1880 | M 100644 :1 .gitmodules |
| 1881 | M 160000 $SUBPREV sub |
| 1882 | |
| 1883 | commit refs/heads/subuse2 |
| 1884 | mark :3 |
| 1885 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1886 | data 7 |
| 1887 | second |
| 1888 | from :2 |
| 1889 | M 160000 $SUBLAST sub |
| 1890 | |
| 1891 | INPUT_END |
| 1892 | |
| 1893 | git branch -D sub && |
| 1894 | git gc --prune=now && |
| 1895 | git fast-import <input && |
| 1896 | test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1) |
| 1897 | ' |
| 1898 | |
| 1899 | test_expect_success 'P: fail on inline gitlink' ' |
| 1900 | test_tick && |
| 1901 | cat >input <<-INPUT_END && |
| 1902 | commit refs/heads/subuse3 |
| 1903 | mark :1 |
| 1904 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1905 | data <<COMMIT |
| 1906 | corrupt |
| 1907 | COMMIT |
| 1908 | |
| 1909 | from refs/heads/subuse2 |
| 1910 | M 160000 inline sub |
| 1911 | data <<DATA |
| 1912 | $SUBPREV |
| 1913 | DATA |
| 1914 | |
| 1915 | INPUT_END |
| 1916 | |
| 1917 | test_must_fail git fast-import <input |
| 1918 | ' |
| 1919 | |
| 1920 | test_expect_success 'P: fail on blob mark in gitlink' ' |
| 1921 | test_tick && |
| 1922 | cat >input <<-INPUT_END && |
| 1923 | blob |
| 1924 | mark :1 |
| 1925 | data <<DATA |
| 1926 | $SUBPREV |
| 1927 | DATA |
| 1928 | |
| 1929 | commit refs/heads/subuse3 |
| 1930 | mark :2 |
| 1931 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1932 | data <<COMMIT |
| 1933 | corrupt |
| 1934 | COMMIT |
| 1935 | |
| 1936 | from refs/heads/subuse2 |
| 1937 | M 160000 :1 sub |
| 1938 | |
| 1939 | INPUT_END |
| 1940 | |
| 1941 | test_must_fail git fast-import <input |
| 1942 | ' |
| 1943 | |
| 1944 | ### |
| 1945 | ### series Q (notes) |
| 1946 | ### |
| 1947 | |
| 1948 | test_expect_success 'Q: commit notes' ' |
| 1949 | note1_data="The first note for the first commit" && |
| 1950 | note2_data="The first note for the second commit" && |
| 1951 | note3_data="The first note for the third commit" && |
| 1952 | note1b_data="The second note for the first commit" && |
| 1953 | note1c_data="The third note for the first commit" && |
| 1954 | note2b_data="The second note for the second commit" && |
| 1955 | |
| 1956 | test_tick && |
| 1957 | cat >input <<-INPUT_END && |
| 1958 | blob |
| 1959 | mark :2 |
| 1960 | data <<EOF |
| 1961 | $file2_data |
| 1962 | EOF |
| 1963 | |
| 1964 | commit refs/heads/notes-test |
| 1965 | mark :3 |
| 1966 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1967 | data <<COMMIT |
| 1968 | first (:3) |
| 1969 | COMMIT |
| 1970 | |
| 1971 | M 644 :2 file2 |
| 1972 | |
| 1973 | blob |
| 1974 | mark :4 |
| 1975 | data $file4_len |
| 1976 | $file4_data |
| 1977 | commit refs/heads/notes-test |
| 1978 | mark :5 |
| 1979 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1980 | data <<COMMIT |
| 1981 | second (:5) |
| 1982 | COMMIT |
| 1983 | |
| 1984 | M 644 :4 file4 |
| 1985 | |
| 1986 | commit refs/heads/notes-test |
| 1987 | mark :6 |
| 1988 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1989 | data <<COMMIT |
| 1990 | third (:6) |
| 1991 | COMMIT |
| 1992 | |
| 1993 | M 644 inline file5 |
| 1994 | data <<EOF |
| 1995 | $file5_data |
| 1996 | EOF |
| 1997 | |
| 1998 | M 755 inline file6 |
| 1999 | data <<EOF |
| 2000 | $file6_data |
| 2001 | EOF |
| 2002 | |
| 2003 | blob |
| 2004 | mark :7 |
| 2005 | data <<EOF |
| 2006 | $note1_data |
| 2007 | EOF |
| 2008 | |
| 2009 | blob |
| 2010 | mark :8 |
| 2011 | data <<EOF |
| 2012 | $note2_data |
| 2013 | EOF |
| 2014 | |
| 2015 | commit refs/notes/foobar |
| 2016 | mark :9 |
| 2017 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2018 | data <<COMMIT |
| 2019 | notes (:9) |
| 2020 | COMMIT |
| 2021 | |
| 2022 | N :7 :3 |
| 2023 | N :8 :5 |
| 2024 | N inline :6 |
| 2025 | data <<EOF |
| 2026 | $note3_data |
| 2027 | EOF |
| 2028 | |
| 2029 | commit refs/notes/foobar |
| 2030 | mark :10 |
| 2031 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2032 | data <<COMMIT |
| 2033 | notes (:10) |
| 2034 | COMMIT |
| 2035 | |
| 2036 | N inline :3 |
| 2037 | data <<EOF |
| 2038 | $note1b_data |
| 2039 | EOF |
| 2040 | |
| 2041 | commit refs/notes/foobar2 |
| 2042 | mark :11 |
| 2043 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2044 | data <<COMMIT |
| 2045 | notes (:11) |
| 2046 | COMMIT |
| 2047 | |
| 2048 | N inline :3 |
| 2049 | data <<EOF |
| 2050 | $note1c_data |
| 2051 | EOF |
| 2052 | |
| 2053 | commit refs/notes/foobar |
| 2054 | mark :12 |
| 2055 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2056 | data <<COMMIT |
| 2057 | notes (:12) |
| 2058 | COMMIT |
| 2059 | |
| 2060 | deleteall |
| 2061 | N inline :5 |
| 2062 | data <<EOF |
| 2063 | $note2b_data |
| 2064 | EOF |
| 2065 | |
| 2066 | INPUT_END |
| 2067 | |
| 2068 | git fast-import <input && |
| 2069 | git log --raw notes-test |
| 2070 | ' |
| 2071 | |
| 2072 | test_expect_success 'Q: verify pack' ' |
| 2073 | verify_packs |
| 2074 | ' |
| 2075 | |
| 2076 | test_expect_success 'Q: verify first commit' ' |
| 2077 | commit1=$(git rev-parse notes-test~2) && |
| 2078 | commit2=$(git rev-parse notes-test^) && |
| 2079 | commit3=$(git rev-parse notes-test) && |
| 2080 | |
| 2081 | cat >expect <<-EOF && |
| 2082 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2083 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2084 | |
| 2085 | first (:3) |
| 2086 | EOF |
| 2087 | git cat-file commit notes-test~2 | sed 1d >actual && |
| 2088 | test_cmp expect actual |
| 2089 | ' |
| 2090 | |
| 2091 | test_expect_success 'Q: verify second commit' ' |
| 2092 | cat >expect <<-EOF && |
| 2093 | parent $commit1 |
| 2094 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2095 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2096 | |
| 2097 | second (:5) |
| 2098 | EOF |
| 2099 | git cat-file commit notes-test^ | sed 1d >actual && |
| 2100 | test_cmp expect actual |
| 2101 | ' |
| 2102 | |
| 2103 | test_expect_success 'Q: verify third commit' ' |
| 2104 | cat >expect <<-EOF && |
| 2105 | parent $commit2 |
| 2106 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2107 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2108 | |
| 2109 | third (:6) |
| 2110 | EOF |
| 2111 | git cat-file commit notes-test | sed 1d >actual && |
| 2112 | test_cmp expect actual |
| 2113 | ' |
| 2114 | |
| 2115 | test_expect_success 'Q: verify first notes commit' ' |
| 2116 | cat >expect <<-EOF && |
| 2117 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2118 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2119 | |
| 2120 | notes (:9) |
| 2121 | EOF |
| 2122 | git cat-file commit refs/notes/foobar~2 | sed 1d >actual && |
| 2123 | test_cmp expect actual |
| 2124 | ' |
| 2125 | |
| 2126 | test_expect_success 'Q: verify first notes tree' ' |
| 2127 | sort >expect <<-EOF && |
| 2128 | 100644 blob $commit1 |
| 2129 | 100644 blob $commit2 |
| 2130 | 100644 blob $commit3 |
| 2131 | EOF |
| 2132 | git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 2133 | test_cmp expect actual |
| 2134 | ' |
| 2135 | |
| 2136 | test_expect_success 'Q: verify first note for first commit' ' |
| 2137 | echo "$note1_data" >expect && |
| 2138 | git cat-file blob refs/notes/foobar~2:$commit1 >actual && |
| 2139 | test_cmp expect actual |
| 2140 | ' |
| 2141 | |
| 2142 | test_expect_success 'Q: verify first note for second commit' ' |
| 2143 | echo "$note2_data" >expect && |
| 2144 | git cat-file blob refs/notes/foobar~2:$commit2 >actual && |
| 2145 | test_cmp expect actual |
| 2146 | ' |
| 2147 | |
| 2148 | test_expect_success 'Q: verify first note for third commit' ' |
| 2149 | echo "$note3_data" >expect && |
| 2150 | git cat-file blob refs/notes/foobar~2:$commit3 >actual && |
| 2151 | test_cmp expect actual |
| 2152 | ' |
| 2153 | |
| 2154 | test_expect_success 'Q: verify second notes commit' ' |
| 2155 | cat >expect <<-EOF && |
| 2156 | parent $(git rev-parse --verify refs/notes/foobar~2) |
| 2157 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2158 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2159 | |
| 2160 | notes (:10) |
| 2161 | EOF |
| 2162 | git cat-file commit refs/notes/foobar^ | sed 1d >actual && |
| 2163 | test_cmp expect actual |
| 2164 | ' |
| 2165 | |
| 2166 | test_expect_success 'Q: verify second notes tree' ' |
| 2167 | sort >expect <<-EOF && |
| 2168 | 100644 blob $commit1 |
| 2169 | 100644 blob $commit2 |
| 2170 | 100644 blob $commit3 |
| 2171 | EOF |
| 2172 | git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 2173 | test_cmp expect actual |
| 2174 | ' |
| 2175 | |
| 2176 | test_expect_success 'Q: verify second note for first commit' ' |
| 2177 | echo "$note1b_data" >expect && |
| 2178 | git cat-file blob refs/notes/foobar^:$commit1 >actual && |
| 2179 | test_cmp expect actual |
| 2180 | ' |
| 2181 | |
| 2182 | test_expect_success 'Q: verify first note for second commit' ' |
| 2183 | echo "$note2_data" >expect && |
| 2184 | git cat-file blob refs/notes/foobar^:$commit2 >actual && |
| 2185 | test_cmp expect actual |
| 2186 | ' |
| 2187 | |
| 2188 | test_expect_success 'Q: verify first note for third commit' ' |
| 2189 | echo "$note3_data" >expect && |
| 2190 | git cat-file blob refs/notes/foobar^:$commit3 >actual && |
| 2191 | test_cmp expect actual |
| 2192 | ' |
| 2193 | |
| 2194 | test_expect_success 'Q: verify third notes commit' ' |
| 2195 | cat >expect <<-EOF && |
| 2196 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2197 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2198 | |
| 2199 | notes (:11) |
| 2200 | EOF |
| 2201 | git cat-file commit refs/notes/foobar2 | sed 1d >actual && |
| 2202 | test_cmp expect actual |
| 2203 | ' |
| 2204 | |
| 2205 | test_expect_success 'Q: verify third notes tree' ' |
| 2206 | sort >expect <<-EOF && |
| 2207 | 100644 blob $commit1 |
| 2208 | EOF |
| 2209 | git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 2210 | test_cmp expect actual |
| 2211 | ' |
| 2212 | |
| 2213 | test_expect_success 'Q: verify third note for first commit' ' |
| 2214 | echo "$note1c_data" >expect && |
| 2215 | git cat-file blob refs/notes/foobar2:$commit1 >actual && |
| 2216 | test_cmp expect actual |
| 2217 | ' |
| 2218 | |
| 2219 | test_expect_success 'Q: verify fourth notes commit' ' |
| 2220 | cat >expect <<-EOF && |
| 2221 | parent $(git rev-parse --verify refs/notes/foobar^) |
| 2222 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2223 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2224 | |
| 2225 | notes (:12) |
| 2226 | EOF |
| 2227 | git cat-file commit refs/notes/foobar | sed 1d >actual && |
| 2228 | test_cmp expect actual |
| 2229 | ' |
| 2230 | |
| 2231 | test_expect_success 'Q: verify fourth notes tree' ' |
| 2232 | sort >expect <<-EOF && |
| 2233 | 100644 blob $commit2 |
| 2234 | EOF |
| 2235 | git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 2236 | test_cmp expect actual |
| 2237 | ' |
| 2238 | |
| 2239 | test_expect_success 'Q: verify second note for second commit' ' |
| 2240 | echo "$note2b_data" >expect && |
| 2241 | git cat-file blob refs/notes/foobar:$commit2 >actual && |
| 2242 | test_cmp expect actual |
| 2243 | ' |
| 2244 | |
| 2245 | test_expect_success 'Q: deny note on empty branch' ' |
| 2246 | cat >input <<-EOF && |
| 2247 | reset refs/heads/Q0 |
| 2248 | |
| 2249 | commit refs/heads/note-Q0 |
| 2250 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2251 | data <<COMMIT |
| 2252 | Note for an empty branch. |
| 2253 | COMMIT |
| 2254 | |
| 2255 | N inline refs/heads/Q0 |
| 2256 | data <<NOTE |
| 2257 | some note |
| 2258 | NOTE |
| 2259 | EOF |
| 2260 | test_must_fail git fast-import <input |
| 2261 | ' |
| 2262 | |
| 2263 | ### |
| 2264 | ### series R (feature and option) |
| 2265 | ### |
| 2266 | |
| 2267 | test_expect_success 'R: abort on unsupported feature' ' |
| 2268 | cat >input <<-EOF && |
| 2269 | feature no-such-feature-exists |
| 2270 | EOF |
| 2271 | |
| 2272 | test_must_fail git fast-import <input |
| 2273 | ' |
| 2274 | |
| 2275 | test_expect_success 'R: supported feature is accepted' ' |
| 2276 | cat >input <<-EOF && |
| 2277 | feature date-format=now |
| 2278 | EOF |
| 2279 | |
| 2280 | git fast-import <input |
| 2281 | ' |
| 2282 | |
| 2283 | test_expect_success 'R: abort on receiving feature after data command' ' |
| 2284 | cat >input <<-EOF && |
| 2285 | blob |
| 2286 | data 3 |
| 2287 | hi |
| 2288 | feature date-format=now |
| 2289 | EOF |
| 2290 | |
| 2291 | test_must_fail git fast-import <input |
| 2292 | ' |
| 2293 | |
| 2294 | test_expect_success 'R: import-marks features forbidden by default' ' |
| 2295 | >git.marks && |
| 2296 | echo "feature import-marks=git.marks" >input && |
| 2297 | test_must_fail git fast-import <input && |
| 2298 | echo "feature import-marks-if-exists=git.marks" >input && |
| 2299 | test_must_fail git fast-import <input |
| 2300 | ' |
| 2301 | |
| 2302 | test_expect_success 'R: only one import-marks feature allowed per stream' ' |
| 2303 | >git.marks && |
| 2304 | >git2.marks && |
| 2305 | cat >input <<-EOF && |
| 2306 | feature import-marks=git.marks |
| 2307 | feature import-marks=git2.marks |
| 2308 | EOF |
| 2309 | |
| 2310 | test_must_fail git fast-import --allow-unsafe-features <input |
| 2311 | ' |
| 2312 | |
| 2313 | test_expect_success 'R: export-marks feature forbidden by default' ' |
| 2314 | echo "feature export-marks=git.marks" >input && |
| 2315 | test_must_fail git fast-import <input |
| 2316 | ' |
| 2317 | |
| 2318 | test_expect_success 'R: export-marks feature results in a marks file being created' ' |
| 2319 | cat >input <<-EOF && |
| 2320 | feature export-marks=git.marks |
| 2321 | blob |
| 2322 | mark :1 |
| 2323 | data 3 |
| 2324 | hi |
| 2325 | |
| 2326 | EOF |
| 2327 | |
| 2328 | git fast-import --allow-unsafe-features <input && |
| 2329 | grep :1 git.marks |
| 2330 | ' |
| 2331 | |
| 2332 | test_expect_success 'R: export-marks options can be overridden by commandline options' ' |
| 2333 | cat >input <<-\EOF && |
| 2334 | feature export-marks=feature-sub/git.marks |
| 2335 | blob |
| 2336 | mark :1 |
| 2337 | data 3 |
| 2338 | hi |
| 2339 | |
| 2340 | EOF |
| 2341 | git fast-import --allow-unsafe-features \ |
| 2342 | --export-marks=cmdline-sub/other.marks <input && |
| 2343 | grep :1 cmdline-sub/other.marks && |
| 2344 | test_path_is_missing feature-sub |
| 2345 | ' |
| 2346 | |
| 2347 | test_expect_success 'R: catch typo in marks file name' ' |
| 2348 | test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null && |
| 2349 | echo "feature import-marks=nonexistent.marks" | |
| 2350 | test_must_fail git fast-import --allow-unsafe-features |
| 2351 | ' |
| 2352 | |
| 2353 | test_expect_success 'R: import and output marks can be the same file' ' |
| 2354 | rm -f io.marks && |
| 2355 | blob=$(echo hi | git hash-object --stdin) && |
| 2356 | cat >expect <<-EOF && |
| 2357 | :1 $blob |
| 2358 | :2 $blob |
| 2359 | EOF |
| 2360 | git fast-import --export-marks=io.marks <<-\EOF && |
| 2361 | blob |
| 2362 | mark :1 |
| 2363 | data 3 |
| 2364 | hi |
| 2365 | |
| 2366 | EOF |
| 2367 | git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && |
| 2368 | blob |
| 2369 | mark :2 |
| 2370 | data 3 |
| 2371 | hi |
| 2372 | |
| 2373 | EOF |
| 2374 | test_cmp expect io.marks |
| 2375 | ' |
| 2376 | |
| 2377 | test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' ' |
| 2378 | rm -f io.marks && |
| 2379 | test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF |
| 2380 | blob |
| 2381 | mark :1 |
| 2382 | data 3 |
| 2383 | hi |
| 2384 | |
| 2385 | EOF |
| 2386 | ' |
| 2387 | |
| 2388 | test_expect_success 'R: --import-marks-if-exists' ' |
| 2389 | rm -f io.marks && |
| 2390 | blob=$(echo hi | git hash-object --stdin) && |
| 2391 | echo ":1 $blob" >expect && |
| 2392 | git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF && |
| 2393 | blob |
| 2394 | mark :1 |
| 2395 | data 3 |
| 2396 | hi |
| 2397 | |
| 2398 | EOF |
| 2399 | test_cmp expect io.marks |
| 2400 | ' |
| 2401 | |
| 2402 | test_expect_success 'R: feature import-marks-if-exists' ' |
| 2403 | rm -f io.marks && |
| 2404 | |
| 2405 | git fast-import --export-marks=io.marks \ |
| 2406 | --allow-unsafe-features <<-\EOF && |
| 2407 | feature import-marks-if-exists=not_io.marks |
| 2408 | EOF |
| 2409 | test_must_be_empty io.marks && |
| 2410 | |
| 2411 | blob=$(echo hi | git hash-object --stdin) && |
| 2412 | |
| 2413 | echo ":1 $blob" >io.marks && |
| 2414 | echo ":1 $blob" >expect && |
| 2415 | echo ":2 $blob" >>expect && |
| 2416 | |
| 2417 | git fast-import --export-marks=io.marks \ |
| 2418 | --allow-unsafe-features <<-\EOF && |
| 2419 | feature import-marks-if-exists=io.marks |
| 2420 | blob |
| 2421 | mark :2 |
| 2422 | data 3 |
| 2423 | hi |
| 2424 | |
| 2425 | EOF |
| 2426 | test_cmp expect io.marks && |
| 2427 | |
| 2428 | echo ":3 $blob" >>expect && |
| 2429 | |
| 2430 | git fast-import --import-marks=io.marks \ |
| 2431 | --export-marks=io.marks \ |
| 2432 | --allow-unsafe-features <<-\EOF && |
| 2433 | feature import-marks-if-exists=not_io.marks |
| 2434 | blob |
| 2435 | mark :3 |
| 2436 | data 3 |
| 2437 | hi |
| 2438 | |
| 2439 | EOF |
| 2440 | test_cmp expect io.marks && |
| 2441 | |
| 2442 | git fast-import --import-marks-if-exists=not_io.marks \ |
| 2443 | --export-marks=io.marks \ |
| 2444 | --allow-unsafe-features <<-\EOF && |
| 2445 | feature import-marks-if-exists=io.marks |
| 2446 | EOF |
| 2447 | test_must_be_empty io.marks |
| 2448 | ' |
| 2449 | |
| 2450 | test_expect_success 'R: import to output marks works without any content' ' |
| 2451 | cat >input <<-EOF && |
| 2452 | feature import-marks=marks.out |
| 2453 | feature export-marks=marks.new |
| 2454 | EOF |
| 2455 | |
| 2456 | git fast-import --allow-unsafe-features <input && |
| 2457 | test_cmp marks.out marks.new |
| 2458 | ' |
| 2459 | |
| 2460 | test_expect_success 'R: import marks prefers commandline marks file over the stream' ' |
| 2461 | cat >input <<-EOF && |
| 2462 | feature import-marks=nonexistent.marks |
| 2463 | feature export-marks=marks.new |
| 2464 | EOF |
| 2465 | |
| 2466 | git fast-import --import-marks=marks.out --allow-unsafe-features <input && |
| 2467 | test_cmp marks.out marks.new |
| 2468 | ' |
| 2469 | |
| 2470 | |
| 2471 | test_expect_success 'R: multiple --import-marks= should be honoured' ' |
| 2472 | cat >input <<-EOF && |
| 2473 | feature import-marks=nonexistent.marks |
| 2474 | feature export-marks=combined.marks |
| 2475 | EOF |
| 2476 | |
| 2477 | head -n2 marks.out > one.marks && |
| 2478 | tail -n +3 marks.out > two.marks && |
| 2479 | git fast-import --import-marks=one.marks --import-marks=two.marks \ |
| 2480 | --allow-unsafe-features <input && |
| 2481 | test_cmp marks.out combined.marks |
| 2482 | ' |
| 2483 | |
| 2484 | test_expect_success 'R: feature relative-marks should be honoured' ' |
| 2485 | cat >input <<-EOF && |
| 2486 | feature relative-marks |
| 2487 | feature import-marks=relative.in |
| 2488 | feature export-marks=relative.out |
| 2489 | EOF |
| 2490 | |
| 2491 | mkdir -p .git/info/fast-import/ && |
| 2492 | cp marks.new .git/info/fast-import/relative.in && |
| 2493 | git fast-import --allow-unsafe-features <input && |
| 2494 | test_cmp marks.new .git/info/fast-import/relative.out |
| 2495 | ' |
| 2496 | |
| 2497 | test_expect_success 'R: feature no-relative-marks should be honoured' ' |
| 2498 | cat >input <<-EOF && |
| 2499 | feature relative-marks |
| 2500 | feature import-marks=relative.in |
| 2501 | feature no-relative-marks |
| 2502 | feature export-marks=non-relative.out |
| 2503 | EOF |
| 2504 | |
| 2505 | git fast-import --allow-unsafe-features <input && |
| 2506 | test_cmp marks.new non-relative.out |
| 2507 | ' |
| 2508 | |
| 2509 | test_expect_success 'R: feature ls supported' ' |
| 2510 | echo "feature ls" | |
| 2511 | git fast-import |
| 2512 | ' |
| 2513 | |
| 2514 | test_expect_success 'R: feature cat-blob supported' ' |
| 2515 | echo "feature cat-blob" | |
| 2516 | git fast-import |
| 2517 | ' |
| 2518 | |
| 2519 | test_expect_success 'R: cat-blob-fd must be a nonnegative integer' ' |
| 2520 | test_must_fail git fast-import --cat-blob-fd=-1 </dev/null |
| 2521 | ' |
| 2522 | |
| 2523 | test_expect_success !MINGW 'R: print old blob' ' |
| 2524 | blob=$(echo "yes it can" | git hash-object -w --stdin) && |
| 2525 | cat >expect <<-EOF && |
| 2526 | ${blob} blob 11 |
| 2527 | yes it can |
| 2528 | |
| 2529 | EOF |
| 2530 | echo "cat-blob $blob" | |
| 2531 | git fast-import --cat-blob-fd=6 6>actual && |
| 2532 | test_cmp expect actual |
| 2533 | ' |
| 2534 | |
| 2535 | test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' ' |
| 2536 | echo hello >greeting && |
| 2537 | blob=$(git hash-object -w greeting) && |
| 2538 | cat >expect <<-EOF && |
| 2539 | ${blob} blob 6 |
| 2540 | hello |
| 2541 | |
| 2542 | EOF |
| 2543 | git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF && |
| 2544 | cat-blob $blob |
| 2545 | EOF |
| 2546 | test_cmp expect actual.3 && |
| 2547 | test_must_be_empty actual.1 && |
| 2548 | git fast-import 3>actual.3 >actual.1 <<-EOF && |
| 2549 | option cat-blob-fd=3 |
| 2550 | cat-blob $blob |
| 2551 | EOF |
| 2552 | test_must_be_empty actual.3 && |
| 2553 | test_cmp expect actual.1 |
| 2554 | ' |
| 2555 | |
| 2556 | test_expect_success !MINGW 'R: print mark for new blob' ' |
| 2557 | echo "effluentish" | git hash-object --stdin >expect && |
| 2558 | git fast-import --cat-blob-fd=6 6>actual <<-\EOF && |
| 2559 | blob |
| 2560 | mark :1 |
| 2561 | data <<BLOB_END |
| 2562 | effluentish |
| 2563 | BLOB_END |
| 2564 | get-mark :1 |
| 2565 | EOF |
| 2566 | test_cmp expect actual |
| 2567 | ' |
| 2568 | |
| 2569 | test_expect_success !MINGW 'R: print new blob' ' |
| 2570 | blob=$(echo "yep yep yep" | git hash-object --stdin) && |
| 2571 | cat >expect <<-EOF && |
| 2572 | ${blob} blob 12 |
| 2573 | yep yep yep |
| 2574 | |
| 2575 | EOF |
| 2576 | git fast-import --cat-blob-fd=6 6>actual <<-\EOF && |
| 2577 | blob |
| 2578 | mark :1 |
| 2579 | data <<BLOB_END |
| 2580 | yep yep yep |
| 2581 | BLOB_END |
| 2582 | cat-blob :1 |
| 2583 | EOF |
| 2584 | test_cmp expect actual |
| 2585 | ' |
| 2586 | |
| 2587 | test_expect_success !MINGW 'R: print new blob by sha1' ' |
| 2588 | blob=$(echo "a new blob named by sha1" | git hash-object --stdin) && |
| 2589 | cat >expect <<-EOF && |
| 2590 | ${blob} blob 25 |
| 2591 | a new blob named by sha1 |
| 2592 | |
| 2593 | EOF |
| 2594 | git fast-import --cat-blob-fd=6 6>actual <<-EOF && |
| 2595 | blob |
| 2596 | data <<BLOB_END |
| 2597 | a new blob named by sha1 |
| 2598 | BLOB_END |
| 2599 | cat-blob $blob |
| 2600 | EOF |
| 2601 | test_cmp expect actual |
| 2602 | ' |
| 2603 | |
| 2604 | test_expect_success 'setup: big file' ' |
| 2605 | ( |
| 2606 | echo "the quick brown fox jumps over the lazy dog" >big && |
| 2607 | for i in 1 2 3 |
| 2608 | do |
| 2609 | cat big big big big >bigger && |
| 2610 | cat bigger bigger bigger bigger >big || |
| 2611 | exit |
| 2612 | done |
| 2613 | ) |
| 2614 | ' |
| 2615 | |
| 2616 | test_expect_success 'R: print two blobs to stdout' ' |
| 2617 | blob1=$(git hash-object big) && |
| 2618 | blob1_len=$(wc -c <big) && |
| 2619 | blob2=$(echo hello | git hash-object --stdin) && |
| 2620 | { |
| 2621 | echo ${blob1} blob $blob1_len && |
| 2622 | cat big && |
| 2623 | cat <<-EOF |
| 2624 | |
| 2625 | ${blob2} blob 6 |
| 2626 | hello |
| 2627 | |
| 2628 | EOF |
| 2629 | } >expect && |
| 2630 | { |
| 2631 | cat <<-\END_PART1 && |
| 2632 | blob |
| 2633 | mark :1 |
| 2634 | data <<data_end |
| 2635 | END_PART1 |
| 2636 | cat big && |
| 2637 | cat <<-\EOF |
| 2638 | data_end |
| 2639 | blob |
| 2640 | mark :2 |
| 2641 | data <<data_end |
| 2642 | hello |
| 2643 | data_end |
| 2644 | cat-blob :1 |
| 2645 | cat-blob :2 |
| 2646 | EOF |
| 2647 | } | |
| 2648 | git fast-import >actual && |
| 2649 | test_cmp expect actual |
| 2650 | ' |
| 2651 | |
| 2652 | test_expect_success PIPE 'R: copy using cat-file' ' |
| 2653 | expect_id=$(git hash-object big) && |
| 2654 | expect_len=$(wc -c <big) && |
| 2655 | echo $expect_id blob $expect_len >expect.response && |
| 2656 | |
| 2657 | rm -f blobs && |
| 2658 | |
| 2659 | mkfifo blobs && |
| 2660 | ( |
| 2661 | export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE && |
| 2662 | cat <<-\EOF && |
| 2663 | feature cat-blob |
| 2664 | blob |
| 2665 | mark :1 |
| 2666 | data <<BLOB |
| 2667 | EOF |
| 2668 | cat big && |
| 2669 | cat <<-\EOF && |
| 2670 | BLOB |
| 2671 | cat-blob :1 |
| 2672 | EOF |
| 2673 | |
| 2674 | read blob_id type size <&3 && |
| 2675 | echo "$blob_id $type $size" >response && |
| 2676 | test_copy_bytes $size >blob <&3 && |
| 2677 | read newline <&3 && |
| 2678 | |
| 2679 | cat <<-EOF && |
| 2680 | commit refs/heads/copied |
| 2681 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2682 | data <<COMMIT |
| 2683 | copy big file as file3 |
| 2684 | COMMIT |
| 2685 | M 644 inline file3 |
| 2686 | data <<BLOB |
| 2687 | EOF |
| 2688 | cat blob && |
| 2689 | echo BLOB |
| 2690 | ) 3<blobs | |
| 2691 | git fast-import --cat-blob-fd=3 3>blobs && |
| 2692 | git show copied:file3 >actual && |
| 2693 | test_cmp expect.response response && |
| 2694 | test_cmp big actual |
| 2695 | ' |
| 2696 | |
| 2697 | test_expect_success PIPE 'R: print blob mid-commit' ' |
| 2698 | rm -f blobs && |
| 2699 | echo "A blob from _before_ the commit." >expect && |
| 2700 | mkfifo blobs && |
| 2701 | ( |
| 2702 | exec 3<blobs && |
| 2703 | cat <<-EOF && |
| 2704 | feature cat-blob |
| 2705 | blob |
| 2706 | mark :1 |
| 2707 | data <<BLOB |
| 2708 | A blob from _before_ the commit. |
| 2709 | BLOB |
| 2710 | commit refs/heads/temporary |
| 2711 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2712 | data <<COMMIT |
| 2713 | Empty commit |
| 2714 | COMMIT |
| 2715 | cat-blob :1 |
| 2716 | EOF |
| 2717 | |
| 2718 | read blob_id type size <&3 && |
| 2719 | test_copy_bytes $size >actual <&3 && |
| 2720 | read newline <&3 && |
| 2721 | |
| 2722 | echo |
| 2723 | ) | |
| 2724 | git fast-import --cat-blob-fd=3 3>blobs && |
| 2725 | test_cmp expect actual |
| 2726 | ' |
| 2727 | |
| 2728 | test_expect_success PIPE 'R: print staged blob within commit' ' |
| 2729 | rm -f blobs && |
| 2730 | echo "A blob from _within_ the commit." >expect && |
| 2731 | mkfifo blobs && |
| 2732 | ( |
| 2733 | exec 3<blobs && |
| 2734 | cat <<-EOF && |
| 2735 | feature cat-blob |
| 2736 | commit refs/heads/within |
| 2737 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2738 | data <<COMMIT |
| 2739 | Empty commit |
| 2740 | COMMIT |
| 2741 | M 644 inline within |
| 2742 | data <<BLOB |
| 2743 | A blob from _within_ the commit. |
| 2744 | BLOB |
| 2745 | EOF |
| 2746 | |
| 2747 | to_get=$( |
| 2748 | echo "A blob from _within_ the commit." | |
| 2749 | git hash-object --stdin |
| 2750 | ) && |
| 2751 | echo "cat-blob $to_get" && |
| 2752 | |
| 2753 | read blob_id type size <&3 && |
| 2754 | test_copy_bytes $size >actual <&3 && |
| 2755 | read newline <&3 && |
| 2756 | |
| 2757 | echo deleteall |
| 2758 | ) | |
| 2759 | git fast-import --cat-blob-fd=3 3>blobs && |
| 2760 | test_cmp expect actual |
| 2761 | ' |
| 2762 | |
| 2763 | test_expect_success 'R: quiet option results in no stats being output' ' |
| 2764 | cat >input <<-EOF && |
| 2765 | option git quiet |
| 2766 | blob |
| 2767 | data 3 |
| 2768 | hi |
| 2769 | |
| 2770 | EOF |
| 2771 | |
| 2772 | git fast-import 2>output <input && |
| 2773 | test_must_be_empty output |
| 2774 | ' |
| 2775 | |
| 2776 | test_expect_success 'R: feature done means terminating "done" is mandatory' ' |
| 2777 | echo feature done | test_must_fail git fast-import && |
| 2778 | test_must_fail git fast-import --done </dev/null |
| 2779 | ' |
| 2780 | |
| 2781 | test_expect_success 'R: terminating "done" with trailing gibberish is ok' ' |
| 2782 | git fast-import <<-\EOF && |
| 2783 | feature done |
| 2784 | done |
| 2785 | trailing gibberish |
| 2786 | EOF |
| 2787 | git fast-import <<-\EOF |
| 2788 | done |
| 2789 | more trailing gibberish |
| 2790 | EOF |
| 2791 | ' |
| 2792 | |
| 2793 | test_expect_success 'R: terminating "done" within commit' ' |
| 2794 | cat >expect <<-\EOF && |
| 2795 | OBJID |
| 2796 | :000000 100644 OBJID OBJID A hello.c |
| 2797 | :000000 100644 OBJID OBJID A hello2.c |
| 2798 | EOF |
| 2799 | git fast-import <<-EOF && |
| 2800 | commit refs/heads/done-ends |
| 2801 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2802 | data <<EOT |
| 2803 | Commit terminated by "done" command |
| 2804 | EOT |
| 2805 | M 100644 inline hello.c |
| 2806 | data <<EOT |
| 2807 | Hello, world. |
| 2808 | EOT |
| 2809 | C hello.c hello2.c |
| 2810 | done |
| 2811 | EOF |
| 2812 | git rev-list done-ends | |
| 2813 | git diff-tree -r --stdin --root --always | |
| 2814 | sed -e "s/$OID_REGEX/OBJID/g" >actual && |
| 2815 | test_cmp expect actual |
| 2816 | ' |
| 2817 | |
| 2818 | test_expect_success 'R: die on unknown option' ' |
| 2819 | cat >input <<-EOF && |
| 2820 | option git non-existing-option |
| 2821 | EOF |
| 2822 | |
| 2823 | test_must_fail git fast-import <input |
| 2824 | ' |
| 2825 | |
| 2826 | test_expect_success 'R: unknown commandline options are rejected' '\ |
| 2827 | test_must_fail git fast-import --non-existing-option < /dev/null |
| 2828 | ' |
| 2829 | |
| 2830 | test_expect_success 'R: die on invalid option argument' ' |
| 2831 | echo "option git active-branches=-5" | |
| 2832 | test_must_fail git fast-import && |
| 2833 | echo "option git depth=" | |
| 2834 | test_must_fail git fast-import && |
| 2835 | test_must_fail git fast-import --depth="5 elephants" </dev/null |
| 2836 | ' |
| 2837 | |
| 2838 | test_expect_success 'R: ignore non-git options' ' |
| 2839 | cat >input <<-EOF && |
| 2840 | option non-existing-vcs non-existing-option |
| 2841 | EOF |
| 2842 | |
| 2843 | git fast-import <input |
| 2844 | ' |
| 2845 | |
| 2846 | test_expect_success 'R: corrupt lines do not mess marks file' ' |
| 2847 | rm -f io.marks && |
| 2848 | blob=$(echo hi | git hash-object --stdin) && |
| 2849 | cat >expect <<-EOF && |
| 2850 | :3 $ZERO_OID |
| 2851 | :1 $blob |
| 2852 | :2 $blob |
| 2853 | EOF |
| 2854 | cp expect io.marks && |
| 2855 | test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && |
| 2856 | |
| 2857 | EOF |
| 2858 | test_cmp expect io.marks |
| 2859 | ' |
| 2860 | |
| 2861 | ## |
| 2862 | ## R: very large blobs |
| 2863 | ## |
| 2864 | test_expect_success 'R: blob bigger than threshold' ' |
| 2865 | blobsize=$((2*1024*1024 + 53)) && |
| 2866 | test-tool genrandom bar $blobsize >expect && |
| 2867 | cat >input <<-INPUT_END && |
| 2868 | commit refs/heads/big-file |
| 2869 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2870 | data <<COMMIT |
| 2871 | R - big file |
| 2872 | COMMIT |
| 2873 | |
| 2874 | M 644 inline big1 |
| 2875 | data $blobsize |
| 2876 | INPUT_END |
| 2877 | cat expect >>input && |
| 2878 | cat >>input <<-INPUT_END && |
| 2879 | M 644 inline big2 |
| 2880 | data $blobsize |
| 2881 | INPUT_END |
| 2882 | cat expect >>input && |
| 2883 | echo >>input && |
| 2884 | |
| 2885 | test_create_repo R && |
| 2886 | git --git-dir=R/.git config fastimport.unpackLimit 0 && |
| 2887 | git --git-dir=R/.git fast-import --big-file-threshold=1 <input |
| 2888 | ' |
| 2889 | |
| 2890 | test_expect_success 'R: verify created pack' ' |
| 2891 | ( |
| 2892 | cd R && |
| 2893 | verify_packs -v > ../verify |
| 2894 | ) |
| 2895 | ' |
| 2896 | |
| 2897 | test_expect_success 'R: verify written objects' ' |
| 2898 | git --git-dir=R/.git cat-file blob big-file:big1 >actual && |
| 2899 | test_cmp_bin expect actual && |
| 2900 | a=$(git --git-dir=R/.git rev-parse big-file:big1) && |
| 2901 | b=$(git --git-dir=R/.git rev-parse big-file:big2) && |
| 2902 | test $a = $b |
| 2903 | ' |
| 2904 | |
| 2905 | test_expect_success 'R: blob appears only once' ' |
| 2906 | n=$(grep $a verify | wc -l) && |
| 2907 | test 1 = $n |
| 2908 | ' |
| 2909 | |
| 2910 | ### |
| 2911 | ### series S (mark and path parsing) |
| 2912 | ### |
| 2913 | # |
| 2914 | # Make sure missing spaces and EOLs after mark references |
| 2915 | # cause errors. |
| 2916 | # |
| 2917 | # Setup: |
| 2918 | # |
| 2919 | # 1--2--4 |
| 2920 | # \ / |
| 2921 | # -3- |
| 2922 | # |
| 2923 | # commit marks: 301, 302, 303, 304 |
| 2924 | # blob marks: 403, 404, resp. |
| 2925 | # note mark: 202 |
| 2926 | # |
| 2927 | # The error message when a space is missing not at the |
| 2928 | # end of the line is: |
| 2929 | # |
| 2930 | # missing space after .. |
| 2931 | # |
| 2932 | # or when extra characters come after the mark at the end |
| 2933 | # of the line: |
| 2934 | # |
| 2935 | # garbage after .. |
| 2936 | # |
| 2937 | # or when the dataref is neither "inline " or a known SHA1, |
| 2938 | # |
| 2939 | # invalid dataref .. |
| 2940 | # |
| 2941 | test_expect_success 'S: initialize for S tests' ' |
| 2942 | test_tick && |
| 2943 | |
| 2944 | cat >input <<-INPUT_END && |
| 2945 | commit refs/heads/S |
| 2946 | mark :301 |
| 2947 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2948 | data <<COMMIT |
| 2949 | commit 1 |
| 2950 | COMMIT |
| 2951 | M 100644 inline hello.c |
| 2952 | data <<BLOB |
| 2953 | blob 1 |
| 2954 | BLOB |
| 2955 | |
| 2956 | commit refs/heads/S |
| 2957 | mark :302 |
| 2958 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2959 | data <<COMMIT |
| 2960 | commit 2 |
| 2961 | COMMIT |
| 2962 | from :301 |
| 2963 | M 100644 inline hello.c |
| 2964 | data <<BLOB |
| 2965 | blob 2 |
| 2966 | BLOB |
| 2967 | |
| 2968 | blob |
| 2969 | mark :403 |
| 2970 | data <<BLOB |
| 2971 | blob 3 |
| 2972 | BLOB |
| 2973 | |
| 2974 | blob |
| 2975 | mark :202 |
| 2976 | data <<BLOB |
| 2977 | note 2 |
| 2978 | BLOB |
| 2979 | INPUT_END |
| 2980 | |
| 2981 | git fast-import --export-marks=marks <input |
| 2982 | ' |
| 2983 | |
| 2984 | # |
| 2985 | # filemodify, three datarefs |
| 2986 | # |
| 2987 | test_expect_success 'S: filemodify with garbage after mark must fail' ' |
| 2988 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2989 | commit refs/heads/S |
| 2990 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2991 | data <<COMMIT |
| 2992 | commit N |
| 2993 | COMMIT |
| 2994 | M 100644 :403x hello.c |
| 2995 | EOF |
| 2996 | test_grep "space after mark" err |
| 2997 | ' |
| 2998 | |
| 2999 | # inline is misspelled; fast-import thinks it is some unknown dataref |
| 3000 | test_expect_success 'S: filemodify with garbage after inline must fail' ' |
| 3001 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3002 | commit refs/heads/S |
| 3003 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3004 | data <<COMMIT |
| 3005 | commit N |
| 3006 | COMMIT |
| 3007 | M 100644 inlineX hello.c |
| 3008 | data <<BLOB |
| 3009 | inline |
| 3010 | BLOB |
| 3011 | EOF |
| 3012 | test_grep "nvalid dataref" err |
| 3013 | ' |
| 3014 | |
| 3015 | test_expect_success 'S: filemodify with garbage after sha1 must fail' ' |
| 3016 | sha1=$(grep :403 marks | cut -d\ -f2) && |
| 3017 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3018 | commit refs/heads/S |
| 3019 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3020 | data <<COMMIT |
| 3021 | commit N |
| 3022 | COMMIT |
| 3023 | M 100644 ${sha1}x hello.c |
| 3024 | EOF |
| 3025 | test_grep "space after SHA1" err |
| 3026 | ' |
| 3027 | |
| 3028 | # |
| 3029 | # notemodify, three ways to say dataref |
| 3030 | # |
| 3031 | test_expect_success 'S: notemodify with garbage after mark dataref must fail' ' |
| 3032 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3033 | commit refs/heads/S |
| 3034 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3035 | data <<COMMIT |
| 3036 | commit S note dataref markref |
| 3037 | COMMIT |
| 3038 | N :202x :302 |
| 3039 | EOF |
| 3040 | test_grep "space after mark" err |
| 3041 | ' |
| 3042 | |
| 3043 | test_expect_success 'S: notemodify with garbage after inline dataref must fail' ' |
| 3044 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3045 | commit refs/heads/S |
| 3046 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3047 | data <<COMMIT |
| 3048 | commit S note dataref inline |
| 3049 | COMMIT |
| 3050 | N inlineX :302 |
| 3051 | data <<BLOB |
| 3052 | note blob |
| 3053 | BLOB |
| 3054 | EOF |
| 3055 | test_grep "nvalid dataref" err |
| 3056 | ' |
| 3057 | |
| 3058 | test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' ' |
| 3059 | sha1=$(grep :202 marks | cut -d\ -f2) && |
| 3060 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3061 | commit refs/heads/S |
| 3062 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3063 | data <<COMMIT |
| 3064 | commit S note dataref sha1 |
| 3065 | COMMIT |
| 3066 | N ${sha1}x :302 |
| 3067 | EOF |
| 3068 | test_grep "space after SHA1" err |
| 3069 | ' |
| 3070 | |
| 3071 | # |
| 3072 | # notemodify, mark in commit-ish |
| 3073 | # |
| 3074 | test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' ' |
| 3075 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3076 | commit refs/heads/Snotes |
| 3077 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3078 | data <<COMMIT |
| 3079 | commit S note commit-ish |
| 3080 | COMMIT |
| 3081 | N :202 :302x |
| 3082 | EOF |
| 3083 | test_grep "after mark" err |
| 3084 | ' |
| 3085 | |
| 3086 | # |
| 3087 | # from |
| 3088 | # |
| 3089 | test_expect_success 'S: from with garbage after mark must fail' ' |
| 3090 | test_must_fail \ |
| 3091 | git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err && |
| 3092 | commit refs/heads/S2 |
| 3093 | mark :303 |
| 3094 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3095 | data <<COMMIT |
| 3096 | commit 3 |
| 3097 | COMMIT |
| 3098 | from :301x |
| 3099 | M 100644 :403 hello.c |
| 3100 | EOF |
| 3101 | |
| 3102 | |
| 3103 | # go create the commit, need it for merge test |
| 3104 | git fast-import --import-marks=marks --export-marks=marks <<-EOF && |
| 3105 | commit refs/heads/S2 |
| 3106 | mark :303 |
| 3107 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3108 | data <<COMMIT |
| 3109 | commit 3 |
| 3110 | COMMIT |
| 3111 | from :301 |
| 3112 | M 100644 :403 hello.c |
| 3113 | EOF |
| 3114 | |
| 3115 | # now evaluate the error |
| 3116 | test_grep "after mark" err |
| 3117 | ' |
| 3118 | |
| 3119 | |
| 3120 | # |
| 3121 | # merge |
| 3122 | # |
| 3123 | test_expect_success 'S: merge with garbage after mark must fail' ' |
| 3124 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3125 | commit refs/heads/S |
| 3126 | mark :304 |
| 3127 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3128 | data <<COMMIT |
| 3129 | merge 4 |
| 3130 | COMMIT |
| 3131 | from :302 |
| 3132 | merge :303x |
| 3133 | M 100644 :403 hello.c |
| 3134 | EOF |
| 3135 | test_grep "after mark" err |
| 3136 | ' |
| 3137 | |
| 3138 | # |
| 3139 | # tag, from markref |
| 3140 | # |
| 3141 | test_expect_success 'S: tag with garbage after mark must fail' ' |
| 3142 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3143 | tag refs/tags/Stag |
| 3144 | from :302x |
| 3145 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3146 | data <<TAG |
| 3147 | tag S |
| 3148 | TAG |
| 3149 | EOF |
| 3150 | test_grep "after mark" err |
| 3151 | ' |
| 3152 | |
| 3153 | # |
| 3154 | # cat-blob markref |
| 3155 | # |
| 3156 | test_expect_success 'S: cat-blob with garbage after mark must fail' ' |
| 3157 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3158 | cat-blob :403x |
| 3159 | EOF |
| 3160 | test_grep "after mark" err |
| 3161 | ' |
| 3162 | |
| 3163 | # |
| 3164 | # ls markref |
| 3165 | # |
| 3166 | test_expect_success 'S: ls with garbage after mark must fail' ' |
| 3167 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3168 | ls :302x hello.c |
| 3169 | EOF |
| 3170 | test_grep "space after mark" err |
| 3171 | ' |
| 3172 | |
| 3173 | test_expect_success 'S: ls with garbage after sha1 must fail' ' |
| 3174 | sha1=$(grep :302 marks | cut -d\ -f2) && |
| 3175 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 3176 | ls ${sha1}x hello.c |
| 3177 | EOF |
| 3178 | test_grep "space after tree-ish" err |
| 3179 | ' |
| 3180 | |
| 3181 | # |
| 3182 | # Path parsing |
| 3183 | # |
| 3184 | # There are two sorts of ways a path can be parsed, depending on whether it is |
| 3185 | # the last field on the line. Additionally, ls without a <dataref> has a special |
| 3186 | # case. Test every occurrence of <path> in the grammar against every error case. |
| 3187 | # Paths for the root (empty strings) are tested elsewhere. |
| 3188 | # |
| 3189 | |
| 3190 | # |
| 3191 | # Valid paths at the end of a line: filemodify, filedelete, filecopy (dest), |
| 3192 | # filerename (dest), and ls. |
| 3193 | # |
| 3194 | # commit :301 from root -- modify hello.c (for setup) |
| 3195 | # commit :302 from :301 -- modify $path |
| 3196 | # commit :303 from :302 -- delete $path |
| 3197 | # commit :304 from :301 -- copy hello.c $path |
| 3198 | # commit :305 from :301 -- rename hello.c $path |
| 3199 | # ls :305 $path |
| 3200 | # |
| 3201 | test_path_eol_success () { |
| 3202 | local test="$1" path="$2" unquoted_path="$3" |
| 3203 | test_expect_success "S: paths at EOL with $test must work" ' |
| 3204 | test_when_finished "git branch -D S-path-eol" && |
| 3205 | |
| 3206 | git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err && |
| 3207 | blob |
| 3208 | mark :401 |
| 3209 | data <<BLOB |
| 3210 | hello world |
| 3211 | BLOB |
| 3212 | |
| 3213 | blob |
| 3214 | mark :402 |
| 3215 | data <<BLOB |
| 3216 | hallo welt |
| 3217 | BLOB |
| 3218 | |
| 3219 | commit refs/heads/S-path-eol |
| 3220 | mark :301 |
| 3221 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3222 | data <<COMMIT |
| 3223 | initial commit |
| 3224 | COMMIT |
| 3225 | M 100644 :401 hello.c |
| 3226 | |
| 3227 | commit refs/heads/S-path-eol |
| 3228 | mark :302 |
| 3229 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3230 | data <<COMMIT |
| 3231 | commit filemodify |
| 3232 | COMMIT |
| 3233 | from :301 |
| 3234 | M 100644 :402 $path |
| 3235 | |
| 3236 | commit refs/heads/S-path-eol |
| 3237 | mark :303 |
| 3238 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3239 | data <<COMMIT |
| 3240 | commit filedelete |
| 3241 | COMMIT |
| 3242 | from :302 |
| 3243 | D $path |
| 3244 | |
| 3245 | commit refs/heads/S-path-eol |
| 3246 | mark :304 |
| 3247 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3248 | data <<COMMIT |
| 3249 | commit filecopy dest |
| 3250 | COMMIT |
| 3251 | from :301 |
| 3252 | C hello.c $path |
| 3253 | |
| 3254 | commit refs/heads/S-path-eol |
| 3255 | mark :305 |
| 3256 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3257 | data <<COMMIT |
| 3258 | commit filerename dest |
| 3259 | COMMIT |
| 3260 | from :301 |
| 3261 | R hello.c $path |
| 3262 | |
| 3263 | ls :305 $path |
| 3264 | EOF |
| 3265 | |
| 3266 | commit_m=$(grep :302 marks.out | cut -d\ -f2) && |
| 3267 | commit_d=$(grep :303 marks.out | cut -d\ -f2) && |
| 3268 | commit_c=$(grep :304 marks.out | cut -d\ -f2) && |
| 3269 | commit_r=$(grep :305 marks.out | cut -d\ -f2) && |
| 3270 | blob1=$(grep :401 marks.out | cut -d\ -f2) && |
| 3271 | blob2=$(grep :402 marks.out | cut -d\ -f2) && |
| 3272 | |
| 3273 | ( |
| 3274 | printf "100644 blob $blob2\t$unquoted_path\n" && |
| 3275 | printf "100644 blob $blob1\thello.c\n" |
| 3276 | ) | sort >tree_m.exp && |
| 3277 | git ls-tree $commit_m | sort >tree_m.out && |
| 3278 | test_cmp tree_m.exp tree_m.out && |
| 3279 | |
| 3280 | printf "100644 blob $blob1\thello.c\n" >tree_d.exp && |
| 3281 | git ls-tree $commit_d >tree_d.out && |
| 3282 | test_cmp tree_d.exp tree_d.out && |
| 3283 | |
| 3284 | ( |
| 3285 | printf "100644 blob $blob1\t$unquoted_path\n" && |
| 3286 | printf "100644 blob $blob1\thello.c\n" |
| 3287 | ) | sort >tree_c.exp && |
| 3288 | git ls-tree $commit_c | sort >tree_c.out && |
| 3289 | test_cmp tree_c.exp tree_c.out && |
| 3290 | |
| 3291 | printf "100644 blob $blob1\t$unquoted_path\n" >tree_r.exp && |
| 3292 | git ls-tree $commit_r >tree_r.out && |
| 3293 | test_cmp tree_r.exp tree_r.out && |
| 3294 | |
| 3295 | test_cmp out tree_r.exp |
| 3296 | ' |
| 3297 | } |
| 3298 | |
| 3299 | test_path_eol_success 'quoted spaces' '" hello world.c "' ' hello world.c ' |
| 3300 | test_path_eol_success 'unquoted spaces' ' hello world.c ' ' hello world.c ' |
| 3301 | test_path_eol_success 'octal escapes' '"\150\151\056\143"' 'hi.c' |
| 3302 | |
| 3303 | # |
| 3304 | # Valid paths before a space: filecopy (source) and filerename (source). |
| 3305 | # |
| 3306 | # commit :301 from root -- modify $path (for setup) |
| 3307 | # commit :302 from :301 -- copy $path hello2.c |
| 3308 | # commit :303 from :301 -- rename $path hello2.c |
| 3309 | # |
| 3310 | test_path_space_success () { |
| 3311 | local test="$1" path="$2" unquoted_path="$3" |
| 3312 | test_expect_success "S: paths before space with $test must work" ' |
| 3313 | test_when_finished "git branch -D S-path-space" && |
| 3314 | |
| 3315 | git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err && |
| 3316 | blob |
| 3317 | mark :401 |
| 3318 | data <<BLOB |
| 3319 | hello world |
| 3320 | BLOB |
| 3321 | |
| 3322 | commit refs/heads/S-path-space |
| 3323 | mark :301 |
| 3324 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3325 | data <<COMMIT |
| 3326 | initial commit |
| 3327 | COMMIT |
| 3328 | M 100644 :401 $path |
| 3329 | |
| 3330 | commit refs/heads/S-path-space |
| 3331 | mark :302 |
| 3332 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3333 | data <<COMMIT |
| 3334 | commit filecopy source |
| 3335 | COMMIT |
| 3336 | from :301 |
| 3337 | C $path hello2.c |
| 3338 | |
| 3339 | commit refs/heads/S-path-space |
| 3340 | mark :303 |
| 3341 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3342 | data <<COMMIT |
| 3343 | commit filerename source |
| 3344 | COMMIT |
| 3345 | from :301 |
| 3346 | R $path hello2.c |
| 3347 | |
| 3348 | EOF |
| 3349 | |
| 3350 | commit_c=$(grep :302 marks.out | cut -d\ -f2) && |
| 3351 | commit_r=$(grep :303 marks.out | cut -d\ -f2) && |
| 3352 | blob=$(grep :401 marks.out | cut -d\ -f2) && |
| 3353 | |
| 3354 | ( |
| 3355 | printf "100644 blob $blob\t$unquoted_path\n" && |
| 3356 | printf "100644 blob $blob\thello2.c\n" |
| 3357 | ) | sort >tree_c.exp && |
| 3358 | git ls-tree $commit_c | sort >tree_c.out && |
| 3359 | test_cmp tree_c.exp tree_c.out && |
| 3360 | |
| 3361 | printf "100644 blob $blob\thello2.c\n" >tree_r.exp && |
| 3362 | git ls-tree $commit_r >tree_r.out && |
| 3363 | test_cmp tree_r.exp tree_r.out |
| 3364 | ' |
| 3365 | } |
| 3366 | |
| 3367 | test_path_space_success 'quoted spaces' '" hello world.c "' ' hello world.c ' |
| 3368 | test_path_space_success 'no unquoted spaces' 'hello_world.c' 'hello_world.c' |
| 3369 | test_path_space_success 'octal escapes' '"\150\151\056\143"' 'hi.c' |
| 3370 | |
| 3371 | # |
| 3372 | # Test a single commit change with an invalid path. Run it with all occurrences |
| 3373 | # of <path> in the grammar against all error kinds. |
| 3374 | # |
| 3375 | test_path_fail () { |
| 3376 | local change="$1" what="$2" prefix="$3" path="$4" suffix="$5" err_grep="$6" |
| 3377 | test_expect_success "S: $change with $what must fail" ' |
| 3378 | test_must_fail git fast-import <<-EOF 2>err && |
| 3379 | blob |
| 3380 | mark :1 |
| 3381 | data <<BLOB |
| 3382 | hello world |
| 3383 | BLOB |
| 3384 | |
| 3385 | commit refs/heads/S-path-fail |
| 3386 | mark :2 |
| 3387 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3388 | data <<COMMIT |
| 3389 | commit setup |
| 3390 | COMMIT |
| 3391 | M 100644 :1 hello.c |
| 3392 | |
| 3393 | commit refs/heads/S-path-fail |
| 3394 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3395 | data <<COMMIT |
| 3396 | commit with bad path |
| 3397 | COMMIT |
| 3398 | from :2 |
| 3399 | $prefix$path$suffix |
| 3400 | EOF |
| 3401 | |
| 3402 | test_grep "$err_grep" err |
| 3403 | ' |
| 3404 | } |
| 3405 | |
| 3406 | test_path_base_fail () { |
| 3407 | local change="$1" prefix="$2" field="$3" suffix="$4" |
| 3408 | test_path_fail "$change" 'unclosed " in '"$field" "$prefix" '"hello.c' "$suffix" "invalid $field" |
| 3409 | test_path_fail "$change" "invalid escape in quoted $field" "$prefix" '"hello\xff"' "$suffix" "invalid $field" |
| 3410 | test_path_fail "$change" "escaped NUL in quoted $field" "$prefix" '"hello\000"' "$suffix" "NUL in $field" |
| 3411 | } |
| 3412 | test_path_eol_quoted_fail () { |
| 3413 | local change="$1" prefix="$2" field="$3" |
| 3414 | test_path_base_fail "$change" "$prefix" "$field" '' |
| 3415 | test_path_fail "$change" "garbage after quoted $field" "$prefix" '"hello.c"' 'x' "garbage after $field" |
| 3416 | test_path_fail "$change" "space after quoted $field" "$prefix" '"hello.c"' ' ' "garbage after $field" |
| 3417 | } |
| 3418 | test_path_eol_fail () { |
| 3419 | local change="$1" prefix="$2" field="$3" |
| 3420 | test_path_eol_quoted_fail "$change" "$prefix" "$field" |
| 3421 | } |
| 3422 | test_path_space_fail () { |
| 3423 | local change="$1" prefix="$2" field="$3" |
| 3424 | test_path_base_fail "$change" "$prefix" "$field" ' world.c' |
| 3425 | test_path_fail "$change" "missing space after quoted $field" "$prefix" '"hello.c"' 'x world.c' "missing space after $field" |
| 3426 | test_path_fail "$change" "missing space after unquoted $field" "$prefix" 'hello.c' '' "missing space after $field" |
| 3427 | } |
| 3428 | |
| 3429 | test_path_eol_fail filemodify 'M 100644 :1 ' path |
| 3430 | test_path_eol_fail filedelete 'D ' path |
| 3431 | test_path_space_fail filecopy 'C ' source |
| 3432 | test_path_eol_fail filecopy 'C hello.c ' dest |
| 3433 | test_path_space_fail filerename 'R ' source |
| 3434 | test_path_eol_fail filerename 'R hello.c ' dest |
| 3435 | test_path_eol_fail 'ls (in commit)' 'ls :2 ' path |
| 3436 | |
| 3437 | # When 'ls' has no <dataref>, the <path> must be quoted. |
| 3438 | test_path_eol_quoted_fail 'ls (without dataref in commit)' 'ls ' path |
| 3439 | |
| 3440 | ### |
| 3441 | ### series T (ls) |
| 3442 | ### |
| 3443 | # Setup is carried over from series S. |
| 3444 | |
| 3445 | for root in '""' '' |
| 3446 | do |
| 3447 | test_expect_success "T: ls root ($root) tree" ' |
| 3448 | sed -e "s/Z\$//" >expect <<-EOF && |
| 3449 | 040000 tree $(git rev-parse S^{tree}) Z |
| 3450 | EOF |
| 3451 | sha1=$(git rev-parse --verify S) && |
| 3452 | git fast-import --import-marks=marks <<-EOF >actual && |
| 3453 | ls $sha1 $root |
| 3454 | EOF |
| 3455 | test_cmp expect actual |
| 3456 | ' |
| 3457 | done |
| 3458 | |
| 3459 | test_expect_success 'T: delete branch' ' |
| 3460 | git branch to-delete && |
| 3461 | git fast-import <<-EOF && |
| 3462 | reset refs/heads/to-delete |
| 3463 | from $ZERO_OID |
| 3464 | EOF |
| 3465 | test_must_fail git rev-parse --verify refs/heads/to-delete |
| 3466 | ' |
| 3467 | |
| 3468 | test_expect_success 'T: empty reset doesnt delete branch' ' |
| 3469 | git branch not-to-delete && |
| 3470 | git fast-import <<-EOF && |
| 3471 | reset refs/heads/not-to-delete |
| 3472 | EOF |
| 3473 | git show-ref && |
| 3474 | git rev-parse --verify refs/heads/not-to-delete |
| 3475 | ' |
| 3476 | |
| 3477 | ### |
| 3478 | ### series U (filedelete) |
| 3479 | ### |
| 3480 | |
| 3481 | test_expect_success 'U: initialize for U tests' ' |
| 3482 | cat >input <<-INPUT_END && |
| 3483 | commit refs/heads/U |
| 3484 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3485 | data <<COMMIT |
| 3486 | test setup |
| 3487 | COMMIT |
| 3488 | M 100644 inline hello.c |
| 3489 | data <<BLOB |
| 3490 | blob 1 |
| 3491 | BLOB |
| 3492 | M 100644 inline good/night.txt |
| 3493 | data <<BLOB |
| 3494 | sleep well |
| 3495 | BLOB |
| 3496 | M 100644 inline good/bye.txt |
| 3497 | data <<BLOB |
| 3498 | au revoir |
| 3499 | BLOB |
| 3500 | |
| 3501 | INPUT_END |
| 3502 | |
| 3503 | f7id=$(echo "blob 1" | git hash-object --stdin) && |
| 3504 | f8id=$(echo "sleep well" | git hash-object --stdin) && |
| 3505 | f9id=$(echo "au revoir" | git hash-object --stdin) && |
| 3506 | git fast-import <input |
| 3507 | ' |
| 3508 | |
| 3509 | test_expect_success 'U: filedelete file succeeds' ' |
| 3510 | cat >input <<-INPUT_END && |
| 3511 | commit refs/heads/U |
| 3512 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3513 | data <<COMMIT |
| 3514 | delete good/night.txt |
| 3515 | COMMIT |
| 3516 | from refs/heads/U^0 |
| 3517 | D good/night.txt |
| 3518 | |
| 3519 | INPUT_END |
| 3520 | |
| 3521 | git fast-import <input |
| 3522 | ' |
| 3523 | |
| 3524 | test_expect_success 'U: validate file delete result' ' |
| 3525 | cat >expect <<-EOF && |
| 3526 | :100644 000000 $f8id $ZERO_OID D good/night.txt |
| 3527 | EOF |
| 3528 | |
| 3529 | git diff-tree -M -r U^1 U >actual && |
| 3530 | |
| 3531 | compare_diff_raw expect actual |
| 3532 | ' |
| 3533 | |
| 3534 | test_expect_success 'U: filedelete directory succeeds' ' |
| 3535 | cat >input <<-INPUT_END && |
| 3536 | commit refs/heads/U |
| 3537 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3538 | data <<COMMIT |
| 3539 | delete good dir |
| 3540 | COMMIT |
| 3541 | from refs/heads/U^0 |
| 3542 | D good |
| 3543 | |
| 3544 | INPUT_END |
| 3545 | |
| 3546 | git fast-import <input |
| 3547 | ' |
| 3548 | |
| 3549 | test_expect_success 'U: validate directory delete result' ' |
| 3550 | cat >expect <<-EOF && |
| 3551 | :100644 000000 $f9id $ZERO_OID D good/bye.txt |
| 3552 | EOF |
| 3553 | |
| 3554 | git diff-tree -M -r U^1 U >actual && |
| 3555 | |
| 3556 | compare_diff_raw expect actual |
| 3557 | ' |
| 3558 | |
| 3559 | for root in '""' '' |
| 3560 | do |
| 3561 | test_expect_success "U: filedelete root ($root) succeeds" ' |
| 3562 | cat >input <<-INPUT_END && |
| 3563 | commit refs/heads/U-delete-root |
| 3564 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3565 | data <<COMMIT |
| 3566 | must succeed |
| 3567 | COMMIT |
| 3568 | from refs/heads/U^0 |
| 3569 | D $root |
| 3570 | |
| 3571 | INPUT_END |
| 3572 | |
| 3573 | git fast-import <input |
| 3574 | ' |
| 3575 | |
| 3576 | test_expect_success "U: validate root ($root) delete result" ' |
| 3577 | cat >expect <<-EOF && |
| 3578 | :100644 000000 $f7id $ZERO_OID D hello.c |
| 3579 | EOF |
| 3580 | |
| 3581 | git diff-tree -M -r U U-delete-root >actual && |
| 3582 | |
| 3583 | compare_diff_raw expect actual |
| 3584 | ' |
| 3585 | done |
| 3586 | |
| 3587 | ### |
| 3588 | ### series V (checkpoint) |
| 3589 | ### |
| 3590 | |
| 3591 | # The commands in input_file should not produce any output on the file |
| 3592 | # descriptor set with --cat-blob-fd (or stdout if unspecified). |
| 3593 | # |
| 3594 | # To make sure you're observing the side effects of checkpoint *before* |
| 3595 | # fast-import terminates (and thus writes out its state), check that the |
| 3596 | # fast-import process is still running using background_import_still_running |
| 3597 | # *after* evaluating the test conditions. |
| 3598 | background_import_then_checkpoint () { |
| 3599 | options=$1 |
| 3600 | input_file=$2 |
| 3601 | |
| 3602 | mkfifo V.input |
| 3603 | exec 8<>V.input |
| 3604 | rm V.input |
| 3605 | |
| 3606 | mkfifo V.output |
| 3607 | exec 9<>V.output |
| 3608 | rm V.output |
| 3609 | |
| 3610 | ( |
| 3611 | git fast-import $options <&8 >&9 & |
| 3612 | echo $! >&9 |
| 3613 | wait $! |
| 3614 | echo >&2 "background fast-import terminated too early with exit code $?" |
| 3615 | # Un-block the read loop in the main shell process. |
| 3616 | echo >&9 UNEXPECTED |
| 3617 | ) & |
| 3618 | sh_pid=$! |
| 3619 | read fi_pid <&9 |
| 3620 | # We don't mind if fast-import has already died by the time the test |
| 3621 | # ends. |
| 3622 | test_when_finished " |
| 3623 | exec 8>&-; exec 9>&-; |
| 3624 | kill $sh_pid && wait $sh_pid |
| 3625 | kill $fi_pid && wait $fi_pid |
| 3626 | true" |
| 3627 | |
| 3628 | # Start in the background to ensure we adhere strictly to (blocking) |
| 3629 | # pipes writing sequence. We want to assume that the write below could |
| 3630 | # block, e.g. if fast-import blocks writing its own output to &9 |
| 3631 | # because there is no reader on &9 yet. |
| 3632 | ( |
| 3633 | cat "$input_file" |
| 3634 | echo "checkpoint" |
| 3635 | echo "progress checkpoint" |
| 3636 | ) >&8 & |
| 3637 | |
| 3638 | last=$( |
| 3639 | while read output <&9 |
| 3640 | do |
| 3641 | if test "$output" = "progress checkpoint" || test "$output" = "UNEXPECTED" |
| 3642 | then |
| 3643 | echo "$output" |
| 3644 | break |
| 3645 | else |
| 3646 | # otherwise ignore cruft |
| 3647 | echo >&2 "cruft: $output" |
| 3648 | fi |
| 3649 | done |
| 3650 | ) |
| 3651 | |
| 3652 | test "$last" = "progress checkpoint" |
| 3653 | } |
| 3654 | |
| 3655 | background_import_still_running () { |
| 3656 | if ! kill -0 "$fi_pid" |
| 3657 | then |
| 3658 | echo >&2 "background fast-import terminated too early" |
| 3659 | false |
| 3660 | fi |
| 3661 | } |
| 3662 | |
| 3663 | test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' ' |
| 3664 | cat >input <<-INPUT_END && |
| 3665 | progress foo |
| 3666 | progress bar |
| 3667 | |
| 3668 | INPUT_END |
| 3669 | |
| 3670 | background_import_then_checkpoint "" input && |
| 3671 | background_import_still_running |
| 3672 | ' |
| 3673 | |
| 3674 | test_expect_success PIPE 'V: checkpoint updates refs after reset' ' |
| 3675 | cat >input <<-\INPUT_END && |
| 3676 | reset refs/heads/V |
| 3677 | from refs/heads/U |
| 3678 | |
| 3679 | INPUT_END |
| 3680 | |
| 3681 | background_import_then_checkpoint "" input && |
| 3682 | test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" && |
| 3683 | background_import_still_running |
| 3684 | ' |
| 3685 | |
| 3686 | test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' ' |
| 3687 | cat >input <<-INPUT_END && |
| 3688 | commit refs/heads/V |
| 3689 | mark :1 |
| 3690 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3691 | data 0 |
| 3692 | from refs/heads/U |
| 3693 | |
| 3694 | INPUT_END |
| 3695 | |
| 3696 | background_import_then_checkpoint "--export-marks=marks.actual" input && |
| 3697 | |
| 3698 | echo ":1 $(git rev-parse --verify V)" >marks.expected && |
| 3699 | |
| 3700 | test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" && |
| 3701 | test_cmp marks.expected marks.actual && |
| 3702 | background_import_still_running |
| 3703 | ' |
| 3704 | |
| 3705 | # Re-create the exact same commit, but on a different branch: no new object is |
| 3706 | # created in the database, but the refs and marks still need to be updated. |
| 3707 | test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' ' |
| 3708 | cat >input <<-INPUT_END && |
| 3709 | commit refs/heads/V2 |
| 3710 | mark :2 |
| 3711 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3712 | data 0 |
| 3713 | from refs/heads/U |
| 3714 | |
| 3715 | INPUT_END |
| 3716 | |
| 3717 | background_import_then_checkpoint "--export-marks=marks.actual" input && |
| 3718 | |
| 3719 | echo ":2 $(git rev-parse --verify V2)" >marks.expected && |
| 3720 | |
| 3721 | test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" && |
| 3722 | test_cmp marks.expected marks.actual && |
| 3723 | background_import_still_running |
| 3724 | ' |
| 3725 | |
| 3726 | test_expect_success PIPE 'V: checkpoint updates tags after tag' ' |
| 3727 | cat >input <<-INPUT_END && |
| 3728 | tag Vtag |
| 3729 | from refs/heads/V |
| 3730 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3731 | data 0 |
| 3732 | |
| 3733 | INPUT_END |
| 3734 | |
| 3735 | background_import_then_checkpoint "" input && |
| 3736 | git show-ref -d Vtag && |
| 3737 | background_import_still_running |
| 3738 | ' |
| 3739 | |
| 3740 | ### |
| 3741 | ### series W (get-mark and empty orphan commits) |
| 3742 | ### |
| 3743 | |
| 3744 | cat >>W-input <<-W_INPUT_END |
| 3745 | commit refs/heads/W-branch |
| 3746 | mark :1 |
| 3747 | author Full Name <user@company.tld> 1000000000 +0100 |
| 3748 | committer Full Name <user@company.tld> 1000000000 +0100 |
| 3749 | data 27 |
| 3750 | Intentionally empty commit |
| 3751 | LFsget-mark :1 |
| 3752 | W_INPUT_END |
| 3753 | |
| 3754 | test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' ' |
| 3755 | sed -e s/LFs// W-input | tr L "\n" | git fast-import |
| 3756 | ' |
| 3757 | |
| 3758 | test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' ' |
| 3759 | sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import |
| 3760 | ' |
| 3761 | |
| 3762 | test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' ' |
| 3763 | # Technically, this should fail as it has too many linefeeds |
| 3764 | # according to the grammar in fast-import.txt. But, for whatever |
| 3765 | # reason, it works. Since using the correct number of newlines |
| 3766 | # does not work with older (pre-2.22) versions of git, allow apps |
| 3767 | # that used this second-newline workaround to keep working by |
| 3768 | # checking it with this test... |
| 3769 | sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import |
| 3770 | ' |
| 3771 | |
| 3772 | test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' ' |
| 3773 | # ...but do NOT allow more empty lines than that (see previous test). |
| 3774 | sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import |
| 3775 | ' |
| 3776 | |
| 3777 | ### |
| 3778 | ### series X (other new features) |
| 3779 | ### |
| 3780 | |
| 3781 | test_expect_success ICONV 'X: handling encoding' ' |
| 3782 | test_tick && |
| 3783 | cat >input <<-INPUT_END && |
| 3784 | commit refs/heads/encoding |
| 3785 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3786 | encoding iso-8859-7 |
| 3787 | data <<COMMIT |
| 3788 | INPUT_END |
| 3789 | |
| 3790 | printf "Pi: \360\nCOMMIT\n" >>input && |
| 3791 | |
| 3792 | git fast-import <input && |
| 3793 | git cat-file -p encoding | grep $(printf "\360") && |
| 3794 | git log -1 --format=%B encoding | grep $(printf "\317\200") |
| 3795 | ' |
| 3796 | |
| 3797 | test_expect_success 'X: replace ref that becomes useless is removed' ' |
| 3798 | git init -qb main testrepo && |
| 3799 | cd testrepo && |
| 3800 | ( |
| 3801 | test_commit test && |
| 3802 | |
| 3803 | test_commit msg somename content && |
| 3804 | |
| 3805 | git mv somename othername && |
| 3806 | NEW_TREE=$(git write-tree) && |
| 3807 | MSG="$(git log -1 --format=%B HEAD)" && |
| 3808 | NEW_COMMIT=$(git commit-tree -p HEAD^1 -m "$MSG" $NEW_TREE) && |
| 3809 | git replace main $NEW_COMMIT && |
| 3810 | |
| 3811 | echo more >>othername && |
| 3812 | git add othername && |
| 3813 | git commit -qm more && |
| 3814 | |
| 3815 | git fast-export --all >tmp && |
| 3816 | sed -e s/othername/somename/ tmp >tmp2 && |
| 3817 | git fast-import --force <tmp2 2>msgs && |
| 3818 | |
| 3819 | grep "dropping.*since it would point to itself" msgs && |
| 3820 | git show-ref >refs && |
| 3821 | ! grep refs/replace refs |
| 3822 | ) |
| 3823 | ' |
| 3824 | |
| 3825 | ### |
| 3826 | ### series Y (submodules and hash algorithms) |
| 3827 | ### |
| 3828 | |
| 3829 | cat >Y-sub-input <<\Y_INPUT_END |
| 3830 | blob |
| 3831 | mark :1 |
| 3832 | data 4 |
| 3833 | foo |
| 3834 | |
| 3835 | reset refs/heads/main |
| 3836 | commit refs/heads/main |
| 3837 | mark :2 |
| 3838 | author Full Name <user@company.tld> 1000000000 +0100 |
| 3839 | committer Full Name <user@company.tld> 1000000000 +0100 |
| 3840 | data 24 |
| 3841 | Test submodule commit 1 |
| 3842 | M 100644 :1 file |
| 3843 | |
| 3844 | blob |
| 3845 | mark :3 |
| 3846 | data 8 |
| 3847 | foo |
| 3848 | bar |
| 3849 | |
| 3850 | commit refs/heads/main |
| 3851 | mark :4 |
| 3852 | author Full Name <user@company.tld> 1000000001 +0100 |
| 3853 | committer Full Name <user@company.tld> 1000000001 +0100 |
| 3854 | data 24 |
| 3855 | Test submodule commit 2 |
| 3856 | from :2 |
| 3857 | M 100644 :3 file |
| 3858 | Y_INPUT_END |
| 3859 | |
| 3860 | # Note that the submodule object IDs are intentionally not translated. |
| 3861 | cat >Y-main-input <<\Y_INPUT_END |
| 3862 | blob |
| 3863 | mark :1 |
| 3864 | data 4 |
| 3865 | foo |
| 3866 | |
| 3867 | reset refs/heads/main |
| 3868 | commit refs/heads/main |
| 3869 | mark :2 |
| 3870 | author Full Name <user@company.tld> 2000000000 +0100 |
| 3871 | committer Full Name <user@company.tld> 2000000000 +0100 |
| 3872 | data 14 |
| 3873 | Test commit 1 |
| 3874 | M 100644 :1 file |
| 3875 | |
| 3876 | blob |
| 3877 | mark :3 |
| 3878 | data 73 |
| 3879 | [submodule "sub1"] |
| 3880 | path = sub1 |
| 3881 | url = https://void.example.com/main.git |
| 3882 | |
| 3883 | commit refs/heads/main |
| 3884 | mark :4 |
| 3885 | author Full Name <user@company.tld> 2000000001 +0100 |
| 3886 | committer Full Name <user@company.tld> 2000000001 +0100 |
| 3887 | data 14 |
| 3888 | Test commit 2 |
| 3889 | from :2 |
| 3890 | M 100644 :3 .gitmodules |
| 3891 | M 160000 0712c5be7cf681388e355ef47525aaf23aee1a6d sub1 |
| 3892 | |
| 3893 | blob |
| 3894 | mark :5 |
| 3895 | data 8 |
| 3896 | foo |
| 3897 | bar |
| 3898 | |
| 3899 | commit refs/heads/main |
| 3900 | mark :6 |
| 3901 | author Full Name <user@company.tld> 2000000002 +0100 |
| 3902 | committer Full Name <user@company.tld> 2000000002 +0100 |
| 3903 | data 14 |
| 3904 | Test commit 3 |
| 3905 | from :4 |
| 3906 | M 100644 :5 file |
| 3907 | M 160000 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 sub1 |
| 3908 | Y_INPUT_END |
| 3909 | |
| 3910 | cat >Y-marks <<\Y_INPUT_END |
| 3911 | :2 0712c5be7cf681388e355ef47525aaf23aee1a6d |
| 3912 | :4 ff729f5e62f72c0c3978207d9a80e5f3a65f14d7 |
| 3913 | Y_INPUT_END |
| 3914 | |
| 3915 | test_expect_success 'Y: setup' ' |
| 3916 | test_oid_cache <<-EOF |
| 3917 | Ymain sha1:9afed2f9161ddf416c0a1863b8b0725b00070504 |
| 3918 | Ymain sha256:c0a1010da1df187b2e287654793df01b464bd6f8e3f17fc1481a7dadf84caee3 |
| 3919 | EOF |
| 3920 | ' |
| 3921 | |
| 3922 | test_expect_success 'Y: rewrite submodules' ' |
| 3923 | git init main1 && |
| 3924 | ( |
| 3925 | cd main1 && |
| 3926 | git init sub2 && |
| 3927 | git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input && |
| 3928 | git fast-import --rewrite-submodules-from=sub:../Y-marks \ |
| 3929 | --rewrite-submodules-to=sub:sub2-marks <../Y-main-input && |
| 3930 | test "$(git rev-parse main)" = "$(test_oid Ymain)" |
| 3931 | ) |
| 3932 | ' |
| 3933 | |
| 3934 | test_done |