3 # Copyright (c) 2007 Shawn Pearce
6 test_description='test git fast-import utility'
8 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
11 for p in .git/objects/pack/*.pack
13 git verify-pack "$@" "$p" || return
27 file5_data='an inline file.
28 we should see it later.'
37 test_expect_success 'empty stream succeeds' '
38 git config fastimport.unpackLimit 0 &&
39 git fast-import </dev/null
42 test_expect_success 'truncated stream complains' '
43 echo "tag foo" | test_must_fail git fast-import
46 test_expect_success 'A: create pack from stdin' '
48 cat >input <<-INPUT_END &&
65 commit refs/heads/master
67 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
79 An annotated tag without a tagger
85 An annotated tag that annotates a blob.
89 git fast-import --export-marks=marks.out <input &&
90 git whatchanged master
93 test_expect_success 'A: verify pack' '
97 test_expect_success 'A: verify commit' '
99 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
100 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
104 git cat-file commit master | sed 1d >actual &&
105 test_cmp expect actual
108 test_expect_success 'A: verify tree' '
109 cat >expect <<-EOF &&
114 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
115 test_cmp expect actual
118 test_expect_success 'A: verify file2' '
119 echo "$file2_data" >expect &&
120 git cat-file blob master:file2 >actual &&
121 test_cmp expect actual
124 test_expect_success 'A: verify file3' '
125 echo "$file3_data" >expect &&
126 git cat-file blob master:file3 >actual &&
127 test_cmp expect actual
130 test_expect_success 'A: verify file4' '
131 printf "$file4_data" >expect &&
132 git cat-file blob master:file4 >actual &&
133 test_cmp expect actual
136 test_expect_success 'A: verify tag/series-A' '
137 cat >expect <<-EOF &&
138 object $(git rev-parse refs/heads/master)
142 An annotated tag without a tagger
144 git cat-file tag tags/series-A >actual &&
145 test_cmp expect actual
148 test_expect_success 'A: verify tag/series-A-blob' '
149 cat >expect <<-EOF &&
150 object $(git rev-parse refs/heads/master:file3)
154 An annotated tag that annotates a blob.
156 git cat-file tag tags/series-A-blob >actual &&
157 test_cmp expect actual
160 test_expect_success 'A: verify marks output' '
161 cat >expect <<-EOF &&
162 :2 $(git rev-parse --verify master:file2)
163 :3 $(git rev-parse --verify master:file3)
164 :4 $(git rev-parse --verify master:file4)
165 :5 $(git rev-parse --verify master^0)
167 test_cmp expect marks.out
170 test_expect_success 'A: verify marks import' '
172 --import-marks=marks.out \
173 --export-marks=marks.new \
175 test_cmp expect marks.new
178 test_expect_success 'A: tag blob by sha1' '
180 new_blob=$(echo testing | git hash-object --stdin) &&
181 cat >input <<-INPUT_END &&
183 from $(git rev-parse refs/heads/master:file3)
194 commit refs/heads/new_blob
198 #pretend we got sha1 from fast-import
208 cat >expect <<-EOF &&
209 object $(git rev-parse refs/heads/master:file3)
221 git fast-import <input &&
222 git cat-file tag tags/series-A-blob-2 >actual &&
223 git cat-file tag tags/series-A-blob-3 >>actual &&
224 test_cmp expect actual
227 test_expect_success 'A: verify marks import does not crash' '
229 cat >input <<-INPUT_END &&
230 commit refs/heads/verify--import-marks
231 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
237 M 755 :2 copy-of-file2
241 git fast-import --import-marks=marks.out <input &&
242 git whatchanged verify--import-marks
245 test_expect_success 'A: verify pack' '
249 test_expect_success 'A: verify diff' '
250 cat >expect <<-EOF &&
251 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
253 git diff-tree -M -r master verify--import-marks >actual &&
254 compare_diff_raw expect actual &&
255 test $(git rev-parse --verify master:file2) \
256 = $(git rev-parse --verify verify--import-marks:copy-of-file2)
259 test_expect_success 'A: export marks with large values' '
261 mt=$(git hash-object --stdin < /dev/null) &&
266 cat >input.commit <<-EOF &&
267 commit refs/heads/verify--dump-marks
268 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
270 test the sparse array dumping routines with exponentially growing marks
275 while test "$i" -lt 27
277 cat >>input.blob <<-EOF &&
288 echo "M 100644 :$l l$i" >>input.commit &&
289 echo "M 100644 :$m m$i" >>input.commit &&
290 echo "M 100644 :$n n$i" >>input.commit &&
292 echo ":$l $mt" >>marks.exp &&
293 echo ":$m $mt" >>marks.exp &&
294 echo ":$n $mt" >>marks.exp &&
296 printf "100644 blob $mt\tl$i\n" >>tree.exp &&
297 printf "100644 blob $mt\tm$i\n" >>tree.exp &&
298 printf "100644 blob $mt\tn$i\n" >>tree.exp &&
304 i=$((1 + $i)) || return 1
307 sort tree.exp > tree.exp_s &&
309 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
310 git ls-tree refs/heads/verify--dump-marks >tree.out &&
311 test_cmp tree.exp_s tree.out &&
312 test_cmp marks.exp marks.large
319 test_expect_success 'B: fail on invalid blob sha1' '
321 cat >input <<-INPUT_END &&
322 commit refs/heads/branch
324 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
329 from refs/heads/master
330 M 755 0000000000000000000000000000000000000001 zero1
334 test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
335 test_must_fail git fast-import <input
338 test_expect_success 'B: accept branch name "TEMP_TAG"' '
339 cat >input <<-INPUT_END &&
341 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
346 from refs/heads/master
350 test_when_finished "rm -f .git/TEMP_TAG
353 git fast-import <input &&
354 test -f .git/TEMP_TAG &&
355 test $(git rev-parse master) = $(git rev-parse TEMP_TAG^)
358 test_expect_success 'B: accept empty committer' '
359 cat >input <<-INPUT_END &&
360 commit refs/heads/empty-committer-1
361 committer <> $GIT_COMMITTER_DATE
367 test_when_finished "git update-ref -d refs/heads/empty-committer-1
370 git fast-import <input &&
376 test_expect_success 'B: accept and fixup committer with no name' '
377 cat >input <<-INPUT_END &&
378 commit refs/heads/empty-committer-2
379 committer <a@b.com> $GIT_COMMITTER_DATE
385 test_when_finished "git update-ref -d refs/heads/empty-committer-2
388 git fast-import <input &&
394 test_expect_success 'B: fail on invalid committer (1)' '
395 cat >input <<-INPUT_END &&
396 commit refs/heads/invalid-committer
397 committer Name email> $GIT_COMMITTER_DATE
403 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
404 test_must_fail git fast-import <input
407 test_expect_success 'B: fail on invalid committer (2)' '
408 cat >input <<-INPUT_END &&
409 commit refs/heads/invalid-committer
410 committer Name <e<mail> $GIT_COMMITTER_DATE
416 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
417 test_must_fail git fast-import <input
420 test_expect_success 'B: fail on invalid committer (3)' '
421 cat >input <<-INPUT_END &&
422 commit refs/heads/invalid-committer
423 committer Name <email>> $GIT_COMMITTER_DATE
429 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
430 test_must_fail git fast-import <input
433 test_expect_success 'B: fail on invalid committer (4)' '
434 cat >input <<-INPUT_END &&
435 commit refs/heads/invalid-committer
436 committer Name <email $GIT_COMMITTER_DATE
442 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
443 test_must_fail git fast-import <input
446 test_expect_success 'B: fail on invalid committer (5)' '
447 cat >input <<-INPUT_END &&
448 commit refs/heads/invalid-committer
449 committer Name<email> $GIT_COMMITTER_DATE
455 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
456 test_must_fail git fast-import <input
463 test_expect_success 'C: incremental import create pack from stdin' '
464 newf=$(echo hi newf | git hash-object -w --stdin) &&
465 oldf=$(git rev-parse --verify master:file2) &&
467 cat >input <<-INPUT_END &&
468 commit refs/heads/branch
469 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
474 from refs/heads/master
475 M 644 $oldf file2/oldf
476 M 755 $newf file2/newf
481 git fast-import <input &&
482 git whatchanged branch
485 test_expect_success 'C: verify pack' '
489 test_expect_success 'C: validate reuse existing blob' '
490 test $newf = $(git rev-parse --verify branch:file2/newf) &&
491 test $oldf = $(git rev-parse --verify branch:file2/oldf)
494 test_expect_success 'C: verify commit' '
495 cat >expect <<-EOF &&
496 parent $(git rev-parse --verify master^0)
497 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
498 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
503 git cat-file commit branch | sed 1d >actual &&
504 test_cmp expect actual
507 test_expect_success 'C: validate rename result' '
508 cat >expect <<-EOF &&
509 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
510 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
511 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
513 git diff-tree -M -r master branch >actual &&
514 compare_diff_raw expect actual
521 test_expect_success 'D: inline data in commit' '
523 cat >input <<-INPUT_END &&
524 commit refs/heads/branch
525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
530 from refs/heads/branch^0
531 M 644 inline newdir/interesting
536 M 755 inline newdir/exec.sh
543 git fast-import <input &&
544 git whatchanged branch
547 test_expect_success 'D: verify pack' '
551 test_expect_success 'D: validate new files added' '
552 cat >expect <<-EOF &&
553 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
554 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
556 git diff-tree -M -r branch^ branch >actual &&
557 compare_diff_raw expect actual
560 test_expect_success 'D: verify file5' '
561 echo "$file5_data" >expect &&
562 git cat-file blob branch:newdir/interesting >actual &&
563 test_cmp expect actual
566 test_expect_success 'D: verify file6' '
567 echo "$file6_data" >expect &&
568 git cat-file blob branch:newdir/exec.sh >actual &&
569 test_cmp expect actual
576 test_expect_success 'E: rfc2822 date, --date-format=raw' '
577 cat >input <<-INPUT_END &&
578 commit refs/heads/branch
579 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
580 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
585 from refs/heads/branch^0
589 test_must_fail git fast-import --date-format=raw <input
591 test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
592 git fast-import --date-format=rfc2822 <input
595 test_expect_success 'E: verify pack' '
599 test_expect_success 'E: verify commit' '
600 cat >expect <<-EOF &&
601 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
602 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
606 git cat-file commit branch | sed 1,2d >actual &&
607 test_cmp expect actual
614 test_expect_success 'F: non-fast-forward update skips' '
615 old_branch=$(git rev-parse --verify branch^0) &&
617 cat >input <<-INPUT_END &&
618 commit refs/heads/branch
619 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
621 losing things already?
624 from refs/heads/branch~1
626 reset refs/heads/other
627 from refs/heads/branch
631 test_must_fail git fast-import <input &&
632 # branch must remain unaffected
633 test $old_branch = $(git rev-parse --verify branch^0)
636 test_expect_success 'F: verify pack' '
640 test_expect_success 'F: verify other commit' '
641 cat >expect <<-EOF &&
642 tree $(git rev-parse branch~1^{tree})
643 parent $(git rev-parse branch~1)
644 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
645 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
647 losing things already?
649 git cat-file commit other >actual &&
650 test_cmp expect actual
657 test_expect_success 'G: non-fast-forward update forced' '
658 old_branch=$(git rev-parse --verify branch^0) &&
660 cat >input <<-INPUT_END &&
661 commit refs/heads/branch
662 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
664 losing things already?
667 from refs/heads/branch~1
670 git fast-import --force <input
673 test_expect_success 'G: verify pack' '
677 test_expect_success 'G: branch changed, but logged' '
678 test $old_branch != $(git rev-parse --verify branch^0) &&
679 test $old_branch = $(git rev-parse --verify branch@{1})
686 test_expect_success 'H: deletall, add 1' '
688 cat >input <<-INPUT_END &&
690 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
695 from refs/heads/branch^0
696 M 644 inline i-will-die
698 this file will never exist.
702 M 644 inline h/e/l/lo
708 git fast-import <input &&
712 test_expect_success 'H: verify pack' '
716 test_expect_success 'H: validate old files removed, new files added' '
717 cat >expect <<-EOF &&
718 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
719 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
720 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
721 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
722 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
724 git diff-tree -M -r H^ H >actual &&
725 compare_diff_raw expect actual
728 test_expect_success 'H: verify file' '
729 echo "$file5_data" >expect &&
730 git cat-file blob H:h/e/l/lo >actual &&
731 test_cmp expect actual
738 test_expect_success 'I: export-pack-edges' '
739 cat >input <<-INPUT_END &&
740 commit refs/heads/export-boundary
741 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
743 we have a border. its only 40 characters wide.
746 from refs/heads/branch
749 git fast-import --export-pack-edges=edges.list <input
752 test_expect_success 'I: verify edge list' '
753 cat >expect <<-EOF &&
754 .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
756 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
757 test_cmp expect actual
764 test_expect_success 'J: reset existing branch creates empty commit' '
765 cat >input <<-INPUT_END &&
767 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
772 from refs/heads/branch
777 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
783 git fast-import <input
785 test_expect_success 'J: branch has 1 commit, empty tree' '
786 test 1 = $(git rev-list J | wc -l) &&
787 test 0 = $(git ls-tree J | wc -l)
790 test_expect_success 'J: tag must fail on empty branch' '
791 cat >input <<-INPUT_END &&
797 Tag branch that was reset.
800 test_must_fail git fast-import <input
807 test_expect_success 'K: reinit branch with from' '
808 cat >input <<-INPUT_END &&
810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
815 from refs/heads/branch
818 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
823 from refs/heads/branch^1
826 git fast-import <input
828 test_expect_success 'K: verify K^1 = branch^1' '
829 test $(git rev-parse --verify branch^1) \
830 = $(git rev-parse --verify K^1)
837 test_expect_success 'L: verify internal tree sorting' '
838 cat >input <<-INPUT_END &&
852 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
872 cat >expect <<-EXPECT_END &&
873 :100644 100644 4268632... 55d3a52... M b.
874 :040000 040000 0ae5cac... 443c768... M b
875 :100644 100644 4268632... 55d3a52... M ba
878 git fast-import <input &&
879 GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev --raw L^ L >output &&
880 test_cmp expect output
883 test_expect_success 'L: nested tree copy does not corrupt deltas' '
884 cat >input <<-INPUT_END &&
892 committer C O Mitter <committer@example.com> 1112912473 -0700
901 committer C O Mitter <committer@example.com> 1112912473 -0700
910 cat >expect <<-\EOF &&
915 test_when_finished "git update-ref -d refs/heads/L2" &&
916 git fast-import <input &&
917 git ls-tree L2 g/b/ >tmp &&
918 cat tmp | cut -f 2 >actual &&
919 test_cmp expect actual &&
920 git fsck $(git rev-parse L2)
927 test_expect_success 'M: rename file in same subdirectory' '
929 cat >input <<-INPUT_END &&
931 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
936 from refs/heads/branch^0
937 R file2/newf file2/n.e.w.f
941 cat >expect <<-EOF &&
942 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
944 git fast-import <input &&
945 git diff-tree -M -r M1^ M1 >actual &&
946 compare_diff_raw expect actual
949 test_expect_success 'M: rename file to new subdirectory' '
950 cat >input <<-INPUT_END &&
952 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
957 from refs/heads/branch^0
958 R file2/newf i/am/new/to/you
962 cat >expect <<-EOF &&
963 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
965 git fast-import <input &&
966 git diff-tree -M -r M2^ M2 >actual &&
967 compare_diff_raw expect actual
970 test_expect_success 'M: rename subdirectory to new subdirectory' '
971 cat >input <<-INPUT_END &&
973 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
983 cat >expect <<-EOF &&
984 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
986 git fast-import <input &&
987 git diff-tree -M -r M3^ M3 >actual &&
988 compare_diff_raw expect actual
991 test_expect_success 'M: rename root to subdirectory' '
992 cat >input <<-INPUT_END &&
994 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1004 cat >expect <<-EOF &&
1005 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1006 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1007 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1008 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1009 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1011 git fast-import <input &&
1012 git diff-tree -M -r M4^ M4 >actual &&
1014 compare_diff_raw expect actual
1021 test_expect_success 'N: copy file in same subdirectory' '
1023 cat >input <<-INPUT_END &&
1024 commit refs/heads/N1
1025 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1030 from refs/heads/branch^0
1031 C file2/newf file2/n.e.w.f
1035 cat >expect <<-EOF &&
1036 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1038 git fast-import <input &&
1039 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1040 compare_diff_raw expect actual
1043 test_expect_success 'N: copy then modify subdirectory' '
1044 cat >input <<-INPUT_END &&
1045 commit refs/heads/N2
1046 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1048 clean directory copy
1051 from refs/heads/branch^0
1054 commit refs/heads/N2
1055 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1057 modify directory copy
1060 M 644 inline file3/file5
1067 cat >expect <<-EOF &&
1068 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1069 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1070 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1072 git fast-import <input &&
1073 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1074 compare_diff_raw expect actual
1077 test_expect_success 'N: copy dirty subdirectory' '
1078 cat >input <<-INPUT_END &&
1079 commit refs/heads/N3
1080 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1082 dirty directory copy
1085 from refs/heads/branch^0
1086 M 644 inline file2/file5
1096 git fast-import <input &&
1097 test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})
1100 test_expect_success 'N: copy directory by id' '
1101 cat >expect <<-\EOF &&
1102 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1103 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1105 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1106 cat >input <<-INPUT_END &&
1107 commit refs/heads/N4
1108 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1113 from refs/heads/branch^0
1114 M 040000 $subdir file3
1116 git fast-import <input &&
1117 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1118 compare_diff_raw expect actual
1121 test_expect_success PIPE 'N: read and copy directory' '
1122 cat >expect <<-\EOF &&
1123 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1124 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1126 git update-ref -d refs/heads/N4 &&
1132 commit refs/heads/N4
1133 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1135 copy by tree hash, part 2
1138 from refs/heads/branch^0
1141 read mode type tree filename &&
1142 echo "M 040000 $tree file3"
1144 git fast-import --cat-blob-fd=3 3>backflow &&
1145 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1146 compare_diff_raw expect actual
1149 test_expect_success PIPE 'N: empty directory reads as missing' '
1150 cat <<-\EOF >expect &&
1152 :000000 100644 OBJNAME OBJNAME A unrelated
1154 echo "missing src" >expect.response &&
1155 git update-ref -d refs/heads/read-empty &&
1161 commit refs/heads/read-empty
1162 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1164 read "empty" (missing) directory
1167 M 100644 inline src/greeting
1171 C src/greeting dst1/non-greeting
1172 C src/greeting unrelated
1173 # leave behind "empty" src directory
1178 printf "%s\n" "$line" >response &&
1184 git fast-import --cat-blob-fd=3 3>backflow &&
1185 test_cmp expect.response response &&
1186 git rev-list read-empty |
1187 git diff-tree -r --root --stdin |
1188 sed "s/$OID_REGEX/OBJNAME/g" >actual &&
1189 test_cmp expect actual
1192 test_expect_success 'N: copy root directory by tree hash' '
1193 cat >expect <<-\EOF &&
1194 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1195 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1197 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1198 cat >input <<-INPUT_END &&
1199 commit refs/heads/N6
1200 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1202 copy root directory by tree hash
1205 from refs/heads/branch^0
1208 git fast-import <input &&
1209 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1210 compare_diff_raw expect actual
1213 test_expect_success 'N: copy root by path' '
1214 cat >expect <<-\EOF &&
1215 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1216 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1217 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1218 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1219 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1221 cat >input <<-INPUT_END &&
1222 commit refs/heads/N-copy-root-path
1223 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1225 copy root directory by (empty) path
1228 from refs/heads/branch^0
1231 git fast-import <input &&
1232 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1233 compare_diff_raw expect actual
1236 test_expect_success 'N: delete directory by copying' '
1237 cat >expect <<-\EOF &&
1239 :100644 000000 OBJID OBJID D foo/bar/qux
1241 :000000 100644 OBJID OBJID A foo/bar/baz
1242 :000000 100644 OBJID OBJID A foo/bar/qux
1244 empty_tree=$(git mktree </dev/null) &&
1245 cat >input <<-INPUT_END &&
1246 commit refs/heads/N-delete
1247 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1249 collect data to be deleted
1253 M 100644 inline foo/bar/baz
1257 C "foo/bar/baz" "foo/bar/qux"
1258 C "foo/bar/baz" "foo/bar/quux/1"
1259 C "foo/bar/baz" "foo/bar/quuux"
1260 M 040000 $empty_tree foo/bar/quux
1261 M 040000 $empty_tree foo/bar/quuux
1263 commit refs/heads/N-delete
1264 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1269 M 040000 $empty_tree foo/bar/qux
1271 git fast-import <input &&
1272 git rev-list N-delete |
1273 git diff-tree -r --stdin --root --always |
1274 sed -e "s/$OID_REGEX/OBJID/g" >actual &&
1275 test_cmp expect actual
1278 test_expect_success 'N: modify copied tree' '
1279 cat >expect <<-\EOF &&
1280 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1281 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1282 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1284 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1285 cat >input <<-INPUT_END &&
1286 commit refs/heads/N5
1287 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1292 from refs/heads/branch^0
1293 M 040000 $subdir file3
1295 commit refs/heads/N5
1296 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1298 modify directory copy
1301 M 644 inline file3/file5
1306 git fast-import <input &&
1307 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1308 compare_diff_raw expect actual
1311 test_expect_success 'N: reject foo/ syntax' '
1312 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1313 test_must_fail git fast-import <<-INPUT_END
1314 commit refs/heads/N5B
1315 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1317 copy with invalid syntax
1320 from refs/heads/branch^0
1321 M 040000 $subdir file3/
1325 test_expect_success 'N: reject foo/ syntax in copy source' '
1326 test_must_fail git fast-import <<-INPUT_END
1327 commit refs/heads/N5C
1328 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1330 copy with invalid syntax
1333 from refs/heads/branch^0
1338 test_expect_success 'N: reject foo/ syntax in rename source' '
1339 test_must_fail git fast-import <<-INPUT_END
1340 commit refs/heads/N5D
1341 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1343 rename with invalid syntax
1346 from refs/heads/branch^0
1351 test_expect_success 'N: reject foo/ syntax in ls argument' '
1352 test_must_fail git fast-import <<-INPUT_END
1353 commit refs/heads/N5E
1354 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1356 copy with invalid syntax
1359 from refs/heads/branch^0
1364 test_expect_success 'N: copy to root by id and modify' '
1365 echo "hello, world" >expect.foo &&
1366 echo hello >expect.bar &&
1367 git fast-import <<-SETUP_END &&
1368 commit refs/heads/N7
1369 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1375 M 644 inline foo/bar
1381 tree=$(git rev-parse --verify N7:) &&
1382 git fast-import <<-INPUT_END &&
1383 commit refs/heads/N8
1384 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1386 copy to root by id and modify
1390 M 644 inline foo/foo
1395 git show N8:foo/foo >actual.foo &&
1396 git show N8:foo/bar >actual.bar &&
1397 test_cmp expect.foo actual.foo &&
1398 test_cmp expect.bar actual.bar
1401 test_expect_success 'N: extract subtree' '
1402 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1403 cat >input <<-INPUT_END &&
1404 commit refs/heads/N9
1405 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1407 extract subtree branch:newdir
1413 git fast-import <input &&
1414 git diff --exit-code branch:newdir N9
1417 test_expect_success 'N: modify subtree, extract it, and modify again' '
1418 echo hello >expect.baz &&
1419 echo hello, world >expect.qux &&
1420 git fast-import <<-SETUP_END &&
1421 commit refs/heads/N10
1422 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1428 M 644 inline foo/bar/baz
1434 tree=$(git rev-parse --verify N10:) &&
1435 git fast-import <<-INPUT_END &&
1436 commit refs/heads/N11
1437 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1439 copy to root by id and modify
1443 M 100644 inline foo/bar/qux
1448 C "bar/qux" "bar/quux"
1450 git show N11:bar/baz >actual.baz &&
1451 git show N11:bar/qux >actual.qux &&
1452 git show N11:bar/quux >actual.quux &&
1453 test_cmp expect.baz actual.baz &&
1454 test_cmp expect.qux actual.qux &&
1455 test_cmp expect.qux actual.quux'
1461 test_expect_success 'O: comments are all skipped' '
1462 cat >input <<-INPUT_END &&
1464 commit refs/heads/O1
1465 # -- ignore all of this text
1466 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1467 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1469 dirty directory copy
1472 # do not forget the import blank line!
1474 # yes, we started from our usual base of branch^0.
1476 from refs/heads/branch^0
1477 # and we need to reuse file2/file5 from N3 above.
1478 M 644 inline file2/file5
1479 # otherwise the tree will be different
1484 # do not forget to copy file2 to file3
1487 # or to delete file5 from file2.
1493 git fast-import <input &&
1494 test $(git rev-parse N3) = $(git rev-parse O1)
1497 test_expect_success 'O: blank lines not necessary after data commands' '
1498 cat >input <<-INPUT_END &&
1499 commit refs/heads/O2
1500 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1502 dirty directory copy
1504 from refs/heads/branch^0
1505 M 644 inline file2/file5
1514 git fast-import <input &&
1515 test $(git rev-parse N3) = $(git rev-parse O2)
1518 test_expect_success 'O: repack before next test' '
1522 test_expect_success 'O: blank lines not necessary after other commands' '
1523 cat >input <<-INPUT_END &&
1524 commit refs/heads/O3
1525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1529 commit refs/heads/O3
1530 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1535 commit refs/heads/O3
1537 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1542 commit refs/heads/O3
1543 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1547 reset refs/tags/O3-2nd
1549 reset refs/tags/O3-3rd
1553 cat >expect <<-INPUT_END &&
1560 git fast-import <input &&
1561 test 8 = $(find .git/objects/pack -type f | grep -v multi-pack-index | wc -l) &&
1562 test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
1563 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1564 test_cmp expect actual
1567 test_expect_success 'O: progress outputs as requested by input' '
1568 cat >input <<-INPUT_END &&
1569 commit refs/heads/O4
1570 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1574 commit refs/heads/O4
1575 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1579 progress Two commits down, 2 to go!
1580 commit refs/heads/O4
1581 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1585 progress Three commits down, 1 to go!
1586 commit refs/heads/O4
1587 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1593 git fast-import <input >actual &&
1594 grep "progress " <input >expect &&
1595 test_cmp expect actual
1599 ### series P (gitlinks)
1602 test_expect_success 'P: superproject & submodule mix' '
1603 cat >input <<-INPUT_END &&
1609 reset refs/heads/sub
1610 commit refs/heads/sub
1612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1625 commit refs/heads/subuse1
1627 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1630 from refs/heads/master
1631 M 100644 :3 .gitmodules
1640 commit refs/heads/sub
1642 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1648 commit refs/heads/subuse1
1650 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1658 git fast-import <input &&
1659 git checkout subuse1 &&
1665 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1668 git submodule init &&
1669 git submodule update
1672 test_expect_success 'P: verbatim SHA gitlinks' '
1673 SUBLAST=$(git rev-parse --verify sub) &&
1674 SUBPREV=$(git rev-parse --verify sub^) &&
1676 cat >input <<-INPUT_END &&
1685 commit refs/heads/subuse2
1687 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1690 from refs/heads/master
1691 M 100644 :1 .gitmodules
1692 M 160000 $SUBPREV sub
1694 commit refs/heads/subuse2
1696 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1700 M 160000 $SUBLAST sub
1704 git branch -D sub &&
1707 git fast-import <input &&
1708 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1711 test_expect_success 'P: fail on inline gitlink' '
1713 cat >input <<-INPUT_END &&
1714 commit refs/heads/subuse3
1716 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1721 from refs/heads/subuse2
1729 test_must_fail git fast-import <input
1732 test_expect_success 'P: fail on blob mark in gitlink' '
1734 cat >input <<-INPUT_END &&
1741 commit refs/heads/subuse3
1743 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1748 from refs/heads/subuse2
1753 test_must_fail git fast-import <input
1757 ### series Q (notes)
1760 test_expect_success 'Q: commit notes' '
1761 note1_data="The first note for the first commit" &&
1762 note2_data="The first note for the second commit" &&
1763 note3_data="The first note for the third commit" &&
1764 note1b_data="The second note for the first commit" &&
1765 note1c_data="The third note for the first commit" &&
1766 note2b_data="The second note for the second commit" &&
1769 cat >input <<-INPUT_END &&
1776 commit refs/heads/notes-test
1778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1789 commit refs/heads/notes-test
1791 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1798 commit refs/heads/notes-test
1800 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1827 commit refs/notes/foobar
1829 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1841 commit refs/notes/foobar
1843 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1853 commit refs/notes/foobar2
1855 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1865 commit refs/notes/foobar
1867 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1880 git fast-import <input &&
1881 git whatchanged notes-test
1884 test_expect_success 'Q: verify pack' '
1888 test_expect_success 'Q: verify first commit' '
1889 commit1=$(git rev-parse notes-test~2) &&
1890 commit2=$(git rev-parse notes-test^) &&
1891 commit3=$(git rev-parse notes-test) &&
1893 cat >expect <<-EOF &&
1894 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1895 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1899 git cat-file commit notes-test~2 | sed 1d >actual &&
1900 test_cmp expect actual
1903 test_expect_success 'Q: verify second commit' '
1904 cat >expect <<-EOF &&
1906 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1907 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1911 git cat-file commit notes-test^ | sed 1d >actual &&
1912 test_cmp expect actual
1915 test_expect_success 'Q: verify third commit' '
1916 cat >expect <<-EOF &&
1918 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1919 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1923 git cat-file commit notes-test | sed 1d >actual &&
1924 test_cmp expect actual
1927 test_expect_success 'Q: verify first notes commit' '
1928 cat >expect <<-EOF &&
1929 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1930 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1934 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1935 test_cmp expect actual
1938 test_expect_success 'Q: verify first notes tree' '
1939 cat >expect.unsorted <<-EOF &&
1940 100644 blob $commit1
1941 100644 blob $commit2
1942 100644 blob $commit3
1944 cat expect.unsorted | sort >expect &&
1945 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1946 test_cmp expect actual
1949 test_expect_success 'Q: verify first note for first commit' '
1950 echo "$note1_data" >expect &&
1951 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1952 test_cmp expect actual
1955 test_expect_success 'Q: verify first note for second commit' '
1956 echo "$note2_data" >expect &&
1957 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1958 test_cmp expect actual
1961 test_expect_success 'Q: verify first note for third commit' '
1962 echo "$note3_data" >expect &&
1963 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
1964 test_cmp expect actual
1967 test_expect_success 'Q: verify second notes commit' '
1968 cat >expect <<-EOF &&
1969 parent $(git rev-parse --verify refs/notes/foobar~2)
1970 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1971 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1975 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1976 test_cmp expect actual
1979 test_expect_success 'Q: verify second notes tree' '
1980 cat >expect.unsorted <<-EOF &&
1981 100644 blob $commit1
1982 100644 blob $commit2
1983 100644 blob $commit3
1985 cat expect.unsorted | sort >expect &&
1986 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1987 test_cmp expect actual
1990 test_expect_success 'Q: verify second note for first commit' '
1991 echo "$note1b_data" >expect &&
1992 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
1993 test_cmp expect actual
1996 test_expect_success 'Q: verify first note for second commit' '
1997 echo "$note2_data" >expect &&
1998 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
1999 test_cmp expect actual
2002 test_expect_success 'Q: verify first note for third commit' '
2003 echo "$note3_data" >expect &&
2004 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2005 test_cmp expect actual
2008 test_expect_success 'Q: verify third notes commit' '
2009 cat >expect <<-EOF &&
2010 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2011 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2015 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2016 test_cmp expect actual
2019 test_expect_success 'Q: verify third notes tree' '
2020 cat >expect.unsorted <<-EOF &&
2021 100644 blob $commit1
2023 cat expect.unsorted | sort >expect &&
2024 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2025 test_cmp expect actual
2028 test_expect_success 'Q: verify third note for first commit' '
2029 echo "$note1c_data" >expect &&
2030 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2031 test_cmp expect actual
2034 test_expect_success 'Q: verify fourth notes commit' '
2035 cat >expect <<-EOF &&
2036 parent $(git rev-parse --verify refs/notes/foobar^)
2037 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2038 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2042 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2043 test_cmp expect actual
2046 test_expect_success 'Q: verify fourth notes tree' '
2047 cat >expect.unsorted <<-EOF &&
2048 100644 blob $commit2
2050 cat expect.unsorted | sort >expect &&
2051 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2052 test_cmp expect actual
2055 test_expect_success 'Q: verify second note for second commit' '
2056 echo "$note2b_data" >expect &&
2057 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2058 test_cmp expect actual
2061 test_expect_success 'Q: deny note on empty branch' '
2062 cat >input <<-EOF &&
2065 commit refs/heads/note-Q0
2066 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2068 Note for an empty branch.
2071 N inline refs/heads/Q0
2076 test_must_fail git fast-import <input
2079 ### series R (feature and option)
2082 test_expect_success 'R: abort on unsupported feature' '
2083 cat >input <<-EOF &&
2084 feature no-such-feature-exists
2087 test_must_fail git fast-import <input
2090 test_expect_success 'R: supported feature is accepted' '
2091 cat >input <<-EOF &&
2092 feature date-format=now
2095 git fast-import <input
2098 test_expect_success 'R: abort on receiving feature after data command' '
2099 cat >input <<-EOF &&
2103 feature date-format=now
2106 test_must_fail git fast-import <input
2109 test_expect_success 'R: only one import-marks feature allowed per stream' '
2110 cat >input <<-EOF &&
2111 feature import-marks=git.marks
2112 feature import-marks=git2.marks
2115 test_must_fail git fast-import <input
2118 test_expect_success 'R: export-marks feature results in a marks file being created' '
2119 cat >input <<-EOF &&
2120 feature export-marks=git.marks
2128 cat input | git fast-import &&
2132 test_expect_success 'R: export-marks options can be overridden by commandline options' '
2133 cat input | git fast-import --export-marks=other.marks &&
2137 test_expect_success 'R: catch typo in marks file name' '
2138 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2139 echo "feature import-marks=nonexistent.marks" |
2140 test_must_fail git fast-import
2143 test_expect_success 'R: import and output marks can be the same file' '
2145 blob=$(echo hi | git hash-object --stdin) &&
2146 cat >expect <<-EOF &&
2150 git fast-import --export-marks=io.marks <<-\EOF &&
2157 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2164 test_cmp expect io.marks
2167 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2169 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2178 test_expect_success 'R: --import-marks-if-exists' '
2180 blob=$(echo hi | git hash-object --stdin) &&
2181 echo ":1 $blob" >expect &&
2182 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2189 test_cmp expect io.marks
2192 test_expect_success 'R: feature import-marks-if-exists' '
2195 git fast-import --export-marks=io.marks <<-\EOF &&
2196 feature import-marks-if-exists=not_io.marks
2198 test_must_be_empty io.marks &&
2200 blob=$(echo hi | git hash-object --stdin) &&
2202 echo ":1 $blob" >io.marks &&
2203 echo ":1 $blob" >expect &&
2204 echo ":2 $blob" >>expect &&
2206 git fast-import --export-marks=io.marks <<-\EOF &&
2207 feature import-marks-if-exists=io.marks
2214 test_cmp expect io.marks &&
2216 echo ":3 $blob" >>expect &&
2218 git fast-import --import-marks=io.marks \
2219 --export-marks=io.marks <<-\EOF &&
2220 feature import-marks-if-exists=not_io.marks
2227 test_cmp expect io.marks &&
2229 git fast-import --import-marks-if-exists=not_io.marks \
2230 --export-marks=io.marks <<-\EOF &&
2231 feature import-marks-if-exists=io.marks
2233 test_must_be_empty io.marks
2236 test_expect_success 'R: import to output marks works without any content' '
2237 cat >input <<-EOF &&
2238 feature import-marks=marks.out
2239 feature export-marks=marks.new
2242 cat input | git fast-import &&
2243 test_cmp marks.out marks.new
2246 test_expect_success 'R: import marks prefers commandline marks file over the stream' '
2247 cat >input <<-EOF &&
2248 feature import-marks=nonexistent.marks
2249 feature export-marks=marks.new
2252 cat input | git fast-import --import-marks=marks.out &&
2253 test_cmp marks.out marks.new
2257 test_expect_success 'R: multiple --import-marks= should be honoured' '
2258 cat >input <<-EOF &&
2259 feature import-marks=nonexistent.marks
2260 feature export-marks=combined.marks
2263 head -n2 marks.out > one.marks &&
2264 tail -n +3 marks.out > two.marks &&
2265 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2266 test_cmp marks.out combined.marks
2269 test_expect_success 'R: feature relative-marks should be honoured' '
2270 cat >input <<-EOF &&
2271 feature relative-marks
2272 feature import-marks=relative.in
2273 feature export-marks=relative.out
2276 mkdir -p .git/info/fast-import/ &&
2277 cp marks.new .git/info/fast-import/relative.in &&
2278 git fast-import <input &&
2279 test_cmp marks.new .git/info/fast-import/relative.out
2282 test_expect_success 'R: feature no-relative-marks should be honoured' '
2283 cat >input <<-EOF &&
2284 feature relative-marks
2285 feature import-marks=relative.in
2286 feature no-relative-marks
2287 feature export-marks=non-relative.out
2290 git fast-import <input &&
2291 test_cmp marks.new non-relative.out
2294 test_expect_success 'R: feature ls supported' '
2299 test_expect_success 'R: feature cat-blob supported' '
2300 echo "feature cat-blob" |
2304 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2305 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2308 test_expect_success !MINGW 'R: print old blob' '
2309 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2310 cat >expect <<-EOF &&
2315 echo "cat-blob $blob" |
2316 git fast-import --cat-blob-fd=6 6>actual &&
2317 test_cmp expect actual
2320 test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
2321 echo hello >greeting &&
2322 blob=$(git hash-object -w greeting) &&
2323 cat >expect <<-EOF &&
2328 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2331 test_cmp expect actual.3 &&
2332 test_must_be_empty actual.1 &&
2333 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2334 option cat-blob-fd=3
2337 test_must_be_empty actual.3 &&
2338 test_cmp expect actual.1
2341 test_expect_success !MINGW 'R: print mark for new blob' '
2342 echo "effluentish" | git hash-object --stdin >expect &&
2343 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2351 test_cmp expect actual
2354 test_expect_success !MINGW 'R: print new blob' '
2355 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2356 cat >expect <<-EOF &&
2361 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2369 test_cmp expect actual
2372 test_expect_success !MINGW 'R: print new blob by sha1' '
2373 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2374 cat >expect <<-EOF &&
2376 a new blob named by sha1
2379 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2382 a new blob named by sha1
2386 test_cmp expect actual
2389 test_expect_success 'setup: big file' '
2391 echo "the quick brown fox jumps over the lazy dog" >big &&
2394 cat big big big big >bigger &&
2395 cat bigger bigger bigger bigger >big ||
2401 test_expect_success 'R: print two blobs to stdout' '
2402 blob1=$(git hash-object big) &&
2403 blob1_len=$(wc -c <big) &&
2404 blob2=$(echo hello | git hash-object --stdin) &&
2406 echo ${blob1} blob $blob1_len &&
2416 cat <<-\END_PART1 &&
2433 git fast-import >actual &&
2434 test_cmp expect actual
2437 test_expect_success PIPE 'R: copy using cat-file' '
2438 expect_id=$(git hash-object big) &&
2439 expect_len=$(wc -c <big) &&
2440 echo $expect_id blob $expect_len >expect.response &&
2443 cat >frontend <<-\FRONTEND_END &&
2449 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2462 read blob_id type size <&3 &&
2463 echo "$blob_id $type $size" >response &&
2464 test_copy_bytes $size >blob <&3 &&
2468 commit refs/heads/copied
2469 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2471 copy big file as file3
2479 git fast-import --cat-blob-fd=3 3>blobs &&
2480 git show copied:file3 >actual &&
2481 test_cmp expect.response response &&
2485 test_expect_success PIPE 'R: print blob mid-commit' '
2487 echo "A blob from _before_ the commit." >expect &&
2496 A blob from _before_ the commit.
2498 commit refs/heads/temporary
2499 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2506 read blob_id type size <&3 &&
2507 test_copy_bytes $size >actual <&3 &&
2512 git fast-import --cat-blob-fd=3 3>blobs &&
2513 test_cmp expect actual
2516 test_expect_success PIPE 'R: print staged blob within commit' '
2518 echo "A blob from _within_ the commit." >expect &&
2524 commit refs/heads/within
2525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2531 A blob from _within_ the commit.
2536 echo "A blob from _within_ the commit." |
2537 git hash-object --stdin
2539 echo "cat-blob $to_get" &&
2541 read blob_id type size <&3 &&
2542 test_copy_bytes $size >actual <&3 &&
2547 git fast-import --cat-blob-fd=3 3>blobs &&
2548 test_cmp expect actual
2551 test_expect_success 'R: quiet option results in no stats being output' '
2552 cat >input <<-EOF &&
2560 cat input | git fast-import 2> output &&
2561 test_must_be_empty output
2564 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2565 echo feature done | test_must_fail git fast-import &&
2566 test_must_fail git fast-import --done </dev/null
2569 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2570 git fast-import <<-\EOF &&
2575 git fast-import <<-\EOF
2577 more trailing gibberish
2581 test_expect_success 'R: terminating "done" within commit' '
2582 cat >expect <<-\EOF &&
2584 :000000 100644 OBJID OBJID A hello.c
2585 :000000 100644 OBJID OBJID A hello2.c
2587 git fast-import <<-EOF &&
2588 commit refs/heads/done-ends
2589 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2591 Commit terminated by "done" command
2593 M 100644 inline hello.c
2600 git rev-list done-ends |
2601 git diff-tree -r --stdin --root --always |
2602 sed -e "s/$OID_REGEX/OBJID/g" >actual &&
2603 test_cmp expect actual
2606 test_expect_success 'R: die on unknown option' '
2607 cat >input <<-EOF &&
2608 option git non-existing-option
2611 test_must_fail git fast-import <input
2614 test_expect_success 'R: unknown commandline options are rejected' '\
2615 test_must_fail git fast-import --non-existing-option < /dev/null
2618 test_expect_success 'R: die on invalid option argument' '
2619 echo "option git active-branches=-5" |
2620 test_must_fail git fast-import &&
2621 echo "option git depth=" |
2622 test_must_fail git fast-import &&
2623 test_must_fail git fast-import --depth="5 elephants" </dev/null
2626 test_expect_success 'R: ignore non-git options' '
2627 cat >input <<-EOF &&
2628 option non-existing-vcs non-existing-option
2631 git fast-import <input
2634 test_expect_success 'R: corrupt lines do not mess marks file' '
2636 blob=$(echo hi | git hash-object --stdin) &&
2637 cat >expect <<-EOF &&
2638 :3 0000000000000000000000000000000000000000
2642 cp expect io.marks &&
2643 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2646 test_cmp expect io.marks
2650 ## R: very large blobs
2652 test_expect_success 'R: blob bigger than threshold' '
2653 blobsize=$((2*1024*1024 + 53)) &&
2654 test-tool genrandom bar $blobsize >expect &&
2655 cat >input <<-INPUT_END &&
2656 commit refs/heads/big-file
2657 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2665 cat expect >>input &&
2666 cat >>input <<-INPUT_END &&
2670 cat expect >>input &&
2673 test_create_repo R &&
2674 git --git-dir=R/.git config fastimport.unpackLimit 0 &&
2675 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2678 test_expect_success 'R: verify created pack' '
2681 verify_packs -v > ../verify
2685 test_expect_success 'R: verify written objects' '
2686 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2687 test_cmp_bin expect actual &&
2688 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2689 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2693 test_expect_success 'R: blob appears only once' '
2694 n=$(grep $a verify | wc -l) &&
2702 # Make sure missing spaces and EOLs after mark references
2711 # commit marks: 301, 302, 303, 304
2712 # blob marks: 403, 404, resp.
2715 # The error message when a space is missing not at the
2716 # end of the line is:
2718 # Missing space after ..
2720 # or when extra characters come after the mark at the end
2725 # or when the dataref is neither "inline " or a known SHA1,
2727 # Invalid dataref ..
2729 test_expect_success 'S: initialize for S tests' '
2732 cat >input <<-INPUT_END &&
2735 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2739 M 100644 inline hello.c
2746 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2751 M 100644 inline hello.c
2769 git fast-import --export-marks=marks <input
2773 # filemodify, three datarefs
2775 test_expect_success 'S: filemodify with garbage after mark must fail' '
2776 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2782 M 100644 :403x hello.c
2784 test_i18ngrep "space after mark" err
2787 # inline is misspelled; fast-import thinks it is some unknown dataref
2788 test_expect_success 'S: filemodify with garbage after inline must fail' '
2789 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2791 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2795 M 100644 inlineX hello.c
2800 test_i18ngrep "nvalid dataref" err
2803 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2804 sha1=$(grep :403 marks | cut -d\ -f2) &&
2805 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2807 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2811 M 100644 ${sha1}x hello.c
2813 test_i18ngrep "space after SHA1" err
2817 # notemodify, three ways to say dataref
2819 test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
2820 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2822 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2824 commit S note dataref markref
2828 test_i18ngrep "space after mark" err
2831 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2832 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2834 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2836 commit S note dataref inline
2843 test_i18ngrep "nvalid dataref" err
2846 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2847 sha1=$(grep :202 marks | cut -d\ -f2) &&
2848 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2850 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2852 commit S note dataref sha1
2856 test_i18ngrep "space after SHA1" err
2860 # notemodify, mark in commit-ish
2862 test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
2863 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2864 commit refs/heads/Snotes
2865 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2867 commit S note commit-ish
2871 test_i18ngrep "after mark" err
2877 test_expect_success 'S: from with garbage after mark must fail' '
2879 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2880 commit refs/heads/S2
2882 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2887 M 100644 :403 hello.c
2891 # go create the commit, need it for merge test
2892 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2893 commit refs/heads/S2
2895 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2900 M 100644 :403 hello.c
2903 # now evaluate the error
2904 test_i18ngrep "after mark" err
2911 test_expect_success 'S: merge with garbage after mark must fail' '
2912 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2915 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2921 M 100644 :403 hello.c
2923 test_i18ngrep "after mark" err
2929 test_expect_success 'S: tag with garbage after mark must fail' '
2930 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2933 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2938 test_i18ngrep "after mark" err
2944 test_expect_success 'S: cat-blob with garbage after mark must fail' '
2945 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2948 test_i18ngrep "after mark" err
2954 test_expect_success 'S: ls with garbage after mark must fail' '
2955 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2958 test_i18ngrep "space after mark" err
2961 test_expect_success 'S: ls with garbage after sha1 must fail' '
2962 sha1=$(grep :302 marks | cut -d\ -f2) &&
2963 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2966 test_i18ngrep "space after tree-ish" err
2972 # Setup is carried over from series S.
2974 test_expect_success 'T: ls root tree' '
2975 sed -e "s/Z\$//" >expect <<-EOF &&
2976 040000 tree $(git rev-parse S^{tree}) Z
2978 sha1=$(git rev-parse --verify S) &&
2979 git fast-import --import-marks=marks <<-EOF >actual &&
2982 test_cmp expect actual
2985 test_expect_success 'T: delete branch' '
2986 git branch to-delete &&
2987 git fast-import <<-EOF &&
2988 reset refs/heads/to-delete
2989 from 0000000000000000000000000000000000000000
2991 test_must_fail git rev-parse --verify refs/heads/to-delete
2994 test_expect_success 'T: empty reset doesnt delete branch' '
2995 git branch not-to-delete &&
2996 git fast-import <<-EOF &&
2997 reset refs/heads/not-to-delete
3000 git rev-parse --verify refs/heads/not-to-delete
3004 ### series U (filedelete)
3007 test_expect_success 'U: initialize for U tests' '
3008 cat >input <<-INPUT_END &&
3010 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3014 M 100644 inline hello.c
3018 M 100644 inline good/night.txt
3022 M 100644 inline good/bye.txt
3029 git fast-import <input
3032 test_expect_success 'U: filedelete file succeeds' '
3033 cat >input <<-INPUT_END &&
3035 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3037 delete good/night.txt
3044 git fast-import <input
3047 test_expect_success 'U: validate file delete result' '
3048 cat >expect <<-EOF &&
3049 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3052 git diff-tree -M -r U^1 U >actual &&
3054 compare_diff_raw expect actual
3057 test_expect_success 'U: filedelete directory succeeds' '
3058 cat >input <<-INPUT_END &&
3060 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3069 git fast-import <input
3072 test_expect_success 'U: validate directory delete result' '
3073 cat >expect <<-EOF &&
3074 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3077 git diff-tree -M -r U^1 U >actual &&
3079 compare_diff_raw expect actual
3082 test_expect_success 'U: filedelete root succeeds' '
3083 cat >input <<-INPUT_END &&
3085 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3094 git fast-import <input
3097 test_expect_success 'U: validate root delete result' '
3098 cat >expect <<-EOF &&
3099 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3102 git diff-tree -M -r U^1 U >actual &&
3104 compare_diff_raw expect actual
3108 ### series V (checkpoint)
3111 # The commands in input_file should not produce any output on the file
3112 # descriptor set with --cat-blob-fd (or stdout if unspecified).
3114 # To make sure you're observing the side effects of checkpoint *before*
3115 # fast-import terminates (and thus writes out its state), check that the
3116 # fast-import process is still running using background_import_still_running
3117 # *after* evaluating the test conditions.
3118 background_import_then_checkpoint () {
3130 git fast-import $options <&8 >&9 &
3132 # We don't mind if fast-import has already died by the time the test
3134 test_when_finished "
3135 exec 8>&-; exec 9>&-;
3136 kill $(cat V.pid) && wait $(cat V.pid)
3139 # Start in the background to ensure we adhere strictly to (blocking)
3140 # pipes writing sequence. We want to assume that the write below could
3141 # block, e.g. if fast-import blocks writing its own output to &9
3142 # because there is no reader on &9 yet.
3146 echo "progress checkpoint"
3149 error=1 ;# assume the worst
3150 while read output <&9
3152 if test "$output" = "progress checkpoint"
3157 # otherwise ignore cruft
3158 echo >&2 "cruft: $output"
3161 if test $error -eq 1
3167 background_import_still_running () {
3168 if ! kill -0 "$(cat V.pid)"
3170 echo >&2 "background fast-import terminated too early"
3175 test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' '
3176 cat >input <<-INPUT_END &&
3182 background_import_then_checkpoint "" input &&
3183 background_import_still_running
3186 test_expect_success PIPE 'V: checkpoint updates refs after reset' '
3187 cat >input <<-\INPUT_END &&
3193 background_import_then_checkpoint "" input &&
3194 test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" &&
3195 background_import_still_running
3198 test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' '
3199 cat >input <<-INPUT_END &&
3202 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3208 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3210 echo ":1 $(git rev-parse --verify V)" >marks.expected &&
3212 test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" &&
3213 test_cmp marks.expected marks.actual &&
3214 background_import_still_running
3217 # Re-create the exact same commit, but on a different branch: no new object is
3218 # created in the database, but the refs and marks still need to be updated.
3219 test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' '
3220 cat >input <<-INPUT_END &&
3221 commit refs/heads/V2
3223 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3229 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3231 echo ":2 $(git rev-parse --verify V2)" >marks.expected &&
3233 test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" &&
3234 test_cmp marks.expected marks.actual &&
3235 background_import_still_running
3238 test_expect_success PIPE 'V: checkpoint updates tags after tag' '
3239 cat >input <<-INPUT_END &&
3242 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3247 background_import_then_checkpoint "" input &&
3248 git show-ref -d Vtag &&
3249 background_import_still_running
3253 ### series W (get-mark and empty orphan commits)
3256 cat >>W-input <<-W_INPUT_END
3257 commit refs/heads/W-branch
3259 author Full Name <user@company.tld> 1000000000 +0100
3260 committer Full Name <user@company.tld> 1000000000 +0100
3262 Intentionally empty commit
3266 test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
3267 sed -e s/LFs// W-input | tr L "\n" | git fast-import
3270 test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
3271 sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
3274 test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
3275 # Technically, this should fail as it has too many linefeeds
3276 # according to the grammar in fast-import.txt. But, for whatever
3277 # reason, it works. Since using the correct number of newlines
3278 # does not work with older (pre-2.22) versions of git, allow apps
3279 # that used this second-newline workaround to keep working by
3280 # checking it with this test...
3281 sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import
3284 test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
3285 # ...but do NOT allow more empty lines than that (see previous test).
3286 sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import
3290 ### series X (other new features)
3293 test_expect_success 'X: handling encoding' '
3295 cat >input <<-INPUT_END &&
3296 commit refs/heads/encoding
3297 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3302 printf "Pi: \360\nCOMMIT\n" >>input &&
3304 git fast-import <input &&
3305 git cat-file -p encoding | grep $(printf "\360") &&
3306 git log -1 --format=%B encoding | grep $(printf "\317\200")