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.
91 Another annotated tag that annotates a blob.
94 reset refs/tags/to-be-deleted
95 from 0000000000000000000000000000000000000000
101 Tag of our lovely commit
104 reset refs/tags/nested
105 from 0000000000000000000000000000000000000000
111 Tag of tag of our lovely commit
119 git fast-import --export-marks=marks.out <input &&
120 git whatchanged master
123 test_expect_success 'A: verify pack' '
127 test_expect_success 'A: verify commit' '
128 cat >expect <<-EOF &&
129 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
130 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
134 git cat-file commit master | sed 1d >actual &&
135 test_cmp expect actual
138 test_expect_success 'A: verify tree' '
139 cat >expect <<-EOF &&
144 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
145 test_cmp expect actual
148 test_expect_success 'A: verify file2' '
149 echo "$file2_data" >expect &&
150 git cat-file blob master:file2 >actual &&
151 test_cmp expect actual
154 test_expect_success 'A: verify file3' '
155 echo "$file3_data" >expect &&
156 git cat-file blob master:file3 >actual &&
157 test_cmp expect actual
160 test_expect_success 'A: verify file4' '
161 printf "$file4_data" >expect &&
162 git cat-file blob master:file4 >actual &&
163 test_cmp expect actual
166 test_expect_success 'A: verify tag/series-A' '
167 cat >expect <<-EOF &&
168 object $(git rev-parse refs/heads/master)
172 An annotated tag without a tagger
174 git cat-file tag tags/series-A >actual &&
175 test_cmp expect actual
178 test_expect_success 'A: verify tag/series-A-blob' '
179 cat >expect <<-EOF &&
180 object $(git rev-parse refs/heads/master:file3)
184 An annotated tag that annotates a blob.
186 git cat-file tag tags/series-A-blob >actual &&
187 test_cmp expect actual
190 test_expect_success 'A: verify tag deletion is successful' '
191 test_must_fail git rev-parse --verify refs/tags/to-be-deleted
194 test_expect_success 'A: verify marks output' '
195 cat >expect <<-EOF &&
196 :2 $(git rev-parse --verify master:file2)
197 :3 $(git rev-parse --verify master:file3)
198 :4 $(git rev-parse --verify master:file4)
199 :5 $(git rev-parse --verify master^0)
200 :6 $(git cat-file tag nested | grep object | cut -d" " -f 2)
201 :7 $(git rev-parse --verify nested)
202 :8 $(git rev-parse --verify master^0)
204 test_cmp expect marks.out
207 test_expect_success 'A: verify marks import' '
209 --import-marks=marks.out \
210 --export-marks=marks.new \
212 test_cmp expect marks.new
215 test_expect_success 'A: tag blob by sha1' '
217 new_blob=$(echo testing | git hash-object --stdin) &&
218 cat >input <<-INPUT_END &&
220 from $(git rev-parse refs/heads/master:file3)
231 commit refs/heads/new_blob
235 #pretend we got sha1 from fast-import
245 cat >expect <<-EOF &&
246 object $(git rev-parse refs/heads/master:file3)
258 git fast-import <input &&
259 git cat-file tag tags/series-A-blob-2 >actual &&
260 git cat-file tag tags/series-A-blob-3 >>actual &&
261 test_cmp expect actual
264 test_expect_success 'A: verify marks import does not crash' '
266 cat >input <<-INPUT_END &&
267 commit refs/heads/verify--import-marks
268 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
274 M 755 :2 copy-of-file2
278 git fast-import --import-marks=marks.out <input &&
279 git whatchanged verify--import-marks
282 test_expect_success 'A: verify pack' '
286 test_expect_success 'A: verify diff' '
287 cat >expect <<-EOF &&
288 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
290 git diff-tree -M -r master verify--import-marks >actual &&
291 compare_diff_raw expect actual &&
292 test $(git rev-parse --verify master:file2) \
293 = $(git rev-parse --verify verify--import-marks:copy-of-file2)
296 test_expect_success 'A: export marks with large values' '
298 mt=$(git hash-object --stdin < /dev/null) &&
303 cat >input.commit <<-EOF &&
304 commit refs/heads/verify--dump-marks
305 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
307 test the sparse array dumping routines with exponentially growing marks
312 while test "$i" -lt 27
314 cat >>input.blob <<-EOF &&
325 echo "M 100644 :$l l$i" >>input.commit &&
326 echo "M 100644 :$m m$i" >>input.commit &&
327 echo "M 100644 :$n n$i" >>input.commit &&
329 echo ":$l $mt" >>marks.exp &&
330 echo ":$m $mt" >>marks.exp &&
331 echo ":$n $mt" >>marks.exp &&
333 printf "100644 blob $mt\tl$i\n" >>tree.exp &&
334 printf "100644 blob $mt\tm$i\n" >>tree.exp &&
335 printf "100644 blob $mt\tn$i\n" >>tree.exp &&
341 i=$((1 + $i)) || return 1
344 sort tree.exp > tree.exp_s &&
346 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
347 git ls-tree refs/heads/verify--dump-marks >tree.out &&
348 test_cmp tree.exp_s tree.out &&
349 test_cmp marks.exp marks.large
356 test_expect_success 'B: fail on invalid blob sha1' '
358 cat >input <<-INPUT_END &&
359 commit refs/heads/branch
361 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
366 from refs/heads/master
367 M 755 0000000000000000000000000000000000000001 zero1
371 test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
372 test_must_fail git fast-import <input
375 test_expect_success 'B: accept branch name "TEMP_TAG"' '
376 cat >input <<-INPUT_END &&
378 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
383 from refs/heads/master
387 test_when_finished "rm -f .git/TEMP_TAG
390 git fast-import <input &&
391 test -f .git/TEMP_TAG &&
392 test $(git rev-parse master) = $(git rev-parse TEMP_TAG^)
395 test_expect_success 'B: accept empty committer' '
396 cat >input <<-INPUT_END &&
397 commit refs/heads/empty-committer-1
398 committer <> $GIT_COMMITTER_DATE
404 test_when_finished "git update-ref -d refs/heads/empty-committer-1
407 git fast-import <input &&
413 test_expect_success 'B: accept and fixup committer with no name' '
414 cat >input <<-INPUT_END &&
415 commit refs/heads/empty-committer-2
416 committer <a@b.com> $GIT_COMMITTER_DATE
422 test_when_finished "git update-ref -d refs/heads/empty-committer-2
425 git fast-import <input &&
431 test_expect_success 'B: fail on invalid committer (1)' '
432 cat >input <<-INPUT_END &&
433 commit refs/heads/invalid-committer
434 committer Name email> $GIT_COMMITTER_DATE
440 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
441 test_must_fail git fast-import <input
444 test_expect_success 'B: fail on invalid committer (2)' '
445 cat >input <<-INPUT_END &&
446 commit refs/heads/invalid-committer
447 committer Name <e<mail> $GIT_COMMITTER_DATE
453 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
454 test_must_fail git fast-import <input
457 test_expect_success 'B: fail on invalid committer (3)' '
458 cat >input <<-INPUT_END &&
459 commit refs/heads/invalid-committer
460 committer Name <email>> $GIT_COMMITTER_DATE
466 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
467 test_must_fail git fast-import <input
470 test_expect_success 'B: fail on invalid committer (4)' '
471 cat >input <<-INPUT_END &&
472 commit refs/heads/invalid-committer
473 committer Name <email $GIT_COMMITTER_DATE
479 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
480 test_must_fail git fast-import <input
483 test_expect_success 'B: fail on invalid committer (5)' '
484 cat >input <<-INPUT_END &&
485 commit refs/heads/invalid-committer
486 committer Name<email> $GIT_COMMITTER_DATE
492 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
493 test_must_fail git fast-import <input
500 test_expect_success 'C: incremental import create pack from stdin' '
501 newf=$(echo hi newf | git hash-object -w --stdin) &&
502 oldf=$(git rev-parse --verify master:file2) &&
504 cat >input <<-INPUT_END &&
505 commit refs/heads/branch
506 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
511 from refs/heads/master
512 M 644 $oldf file2/oldf
513 M 755 $newf file2/newf
518 git fast-import <input &&
519 git whatchanged branch
522 test_expect_success 'C: verify pack' '
526 test_expect_success 'C: validate reuse existing blob' '
527 test $newf = $(git rev-parse --verify branch:file2/newf) &&
528 test $oldf = $(git rev-parse --verify branch:file2/oldf)
531 test_expect_success 'C: verify commit' '
532 cat >expect <<-EOF &&
533 parent $(git rev-parse --verify master^0)
534 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
535 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
540 git cat-file commit branch | sed 1d >actual &&
541 test_cmp expect actual
544 test_expect_success 'C: validate rename result' '
545 cat >expect <<-EOF &&
546 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
547 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
548 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
550 git diff-tree -M -r master branch >actual &&
551 compare_diff_raw expect actual
558 test_expect_success 'D: inline data in commit' '
560 cat >input <<-INPUT_END &&
561 commit refs/heads/branch
562 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
567 from refs/heads/branch^0
568 M 644 inline newdir/interesting
573 M 755 inline newdir/exec.sh
580 git fast-import <input &&
581 git whatchanged branch
584 test_expect_success 'D: verify pack' '
588 test_expect_success 'D: validate new files added' '
589 cat >expect <<-EOF &&
590 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
591 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
593 git diff-tree -M -r branch^ branch >actual &&
594 compare_diff_raw expect actual
597 test_expect_success 'D: verify file5' '
598 echo "$file5_data" >expect &&
599 git cat-file blob branch:newdir/interesting >actual &&
600 test_cmp expect actual
603 test_expect_success 'D: verify file6' '
604 echo "$file6_data" >expect &&
605 git cat-file blob branch:newdir/exec.sh >actual &&
606 test_cmp expect actual
613 test_expect_success 'E: rfc2822 date, --date-format=raw' '
614 cat >input <<-INPUT_END &&
615 commit refs/heads/branch
616 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
617 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
622 from refs/heads/branch^0
626 test_must_fail git fast-import --date-format=raw <input
628 test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
629 git fast-import --date-format=rfc2822 <input
632 test_expect_success 'E: verify pack' '
636 test_expect_success 'E: verify commit' '
637 cat >expect <<-EOF &&
638 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
639 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
643 git cat-file commit branch | sed 1,2d >actual &&
644 test_cmp expect actual
651 test_expect_success 'F: non-fast-forward update skips' '
652 old_branch=$(git rev-parse --verify branch^0) &&
654 cat >input <<-INPUT_END &&
655 commit refs/heads/branch
656 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
658 losing things already?
661 from refs/heads/branch~1
663 reset refs/heads/other
664 from refs/heads/branch
668 test_must_fail git fast-import <input &&
669 # branch must remain unaffected
670 test $old_branch = $(git rev-parse --verify branch^0)
673 test_expect_success 'F: verify pack' '
677 test_expect_success 'F: verify other commit' '
678 cat >expect <<-EOF &&
679 tree $(git rev-parse branch~1^{tree})
680 parent $(git rev-parse branch~1)
681 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
682 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
684 losing things already?
686 git cat-file commit other >actual &&
687 test_cmp expect actual
694 test_expect_success 'G: non-fast-forward update forced' '
695 old_branch=$(git rev-parse --verify branch^0) &&
697 cat >input <<-INPUT_END &&
698 commit refs/heads/branch
699 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
701 losing things already?
704 from refs/heads/branch~1
707 git fast-import --force <input
710 test_expect_success 'G: verify pack' '
714 test_expect_success 'G: branch changed, but logged' '
715 test $old_branch != $(git rev-parse --verify branch^0) &&
716 test $old_branch = $(git rev-parse --verify branch@{1})
723 test_expect_success 'H: deletall, add 1' '
725 cat >input <<-INPUT_END &&
727 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
732 from refs/heads/branch^0
733 M 644 inline i-will-die
735 this file will never exist.
739 M 644 inline h/e/l/lo
745 git fast-import <input &&
749 test_expect_success 'H: verify pack' '
753 test_expect_success 'H: validate old files removed, new files added' '
754 cat >expect <<-EOF &&
755 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
756 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
757 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
758 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
759 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
761 git diff-tree -M -r H^ H >actual &&
762 compare_diff_raw expect actual
765 test_expect_success 'H: verify file' '
766 echo "$file5_data" >expect &&
767 git cat-file blob H:h/e/l/lo >actual &&
768 test_cmp expect actual
775 test_expect_success 'I: export-pack-edges' '
776 cat >input <<-INPUT_END &&
777 commit refs/heads/export-boundary
778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
780 we have a border. its only 40 characters wide.
783 from refs/heads/branch
786 git fast-import --export-pack-edges=edges.list <input
789 test_expect_success 'I: verify edge list' '
790 cat >expect <<-EOF &&
791 .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
793 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
794 test_cmp expect actual
801 test_expect_success 'J: reset existing branch creates empty commit' '
802 cat >input <<-INPUT_END &&
804 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
809 from refs/heads/branch
814 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
820 git fast-import <input
822 test_expect_success 'J: branch has 1 commit, empty tree' '
823 test 1 = $(git rev-list J | wc -l) &&
824 test 0 = $(git ls-tree J | wc -l)
827 test_expect_success 'J: tag must fail on empty branch' '
828 cat >input <<-INPUT_END &&
834 Tag branch that was reset.
837 test_must_fail git fast-import <input
844 test_expect_success 'K: reinit branch with from' '
845 cat >input <<-INPUT_END &&
847 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
852 from refs/heads/branch
855 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
860 from refs/heads/branch^1
863 git fast-import <input
865 test_expect_success 'K: verify K^1 = branch^1' '
866 test $(git rev-parse --verify branch^1) \
867 = $(git rev-parse --verify K^1)
874 test_expect_success 'L: verify internal tree sorting' '
875 cat >input <<-INPUT_END &&
889 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
899 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
909 cat >expect <<-EXPECT_END &&
910 :100644 100644 4268632... 55d3a52... M b.
911 :040000 040000 0ae5cac... 443c768... M b
912 :100644 100644 4268632... 55d3a52... M ba
915 git fast-import <input &&
916 GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev --raw L^ L >output &&
917 test_cmp expect output
920 test_expect_success 'L: nested tree copy does not corrupt deltas' '
921 cat >input <<-INPUT_END &&
929 committer C O Mitter <committer@example.com> 1112912473 -0700
938 committer C O Mitter <committer@example.com> 1112912473 -0700
947 cat >expect <<-\EOF &&
952 test_when_finished "git update-ref -d refs/heads/L2" &&
953 git fast-import <input &&
954 git ls-tree L2 g/b/ >tmp &&
955 cat tmp | cut -f 2 >actual &&
956 test_cmp expect actual &&
957 git fsck $(git rev-parse L2)
964 test_expect_success 'M: rename file in same subdirectory' '
966 cat >input <<-INPUT_END &&
968 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
973 from refs/heads/branch^0
974 R file2/newf file2/n.e.w.f
978 cat >expect <<-EOF &&
979 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
981 git fast-import <input &&
982 git diff-tree -M -r M1^ M1 >actual &&
983 compare_diff_raw expect actual
986 test_expect_success 'M: rename file to new subdirectory' '
987 cat >input <<-INPUT_END &&
989 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
994 from refs/heads/branch^0
995 R file2/newf i/am/new/to/you
999 cat >expect <<-EOF &&
1000 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
1002 git fast-import <input &&
1003 git diff-tree -M -r M2^ M2 >actual &&
1004 compare_diff_raw expect actual
1007 test_expect_success 'M: rename subdirectory to new subdirectory' '
1008 cat >input <<-INPUT_END &&
1009 commit refs/heads/M3
1010 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1015 from refs/heads/M2^0
1020 cat >expect <<-EOF &&
1021 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1023 git fast-import <input &&
1024 git diff-tree -M -r M3^ M3 >actual &&
1025 compare_diff_raw expect actual
1028 test_expect_success 'M: rename root to subdirectory' '
1029 cat >input <<-INPUT_END &&
1030 commit refs/heads/M4
1031 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1036 from refs/heads/M2^0
1041 cat >expect <<-EOF &&
1042 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1043 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1044 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1045 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1046 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1048 git fast-import <input &&
1049 git diff-tree -M -r M4^ M4 >actual &&
1051 compare_diff_raw expect actual
1058 test_expect_success 'N: copy file in same subdirectory' '
1060 cat >input <<-INPUT_END &&
1061 commit refs/heads/N1
1062 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1067 from refs/heads/branch^0
1068 C file2/newf file2/n.e.w.f
1072 cat >expect <<-EOF &&
1073 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1075 git fast-import <input &&
1076 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1077 compare_diff_raw expect actual
1080 test_expect_success 'N: copy then modify subdirectory' '
1081 cat >input <<-INPUT_END &&
1082 commit refs/heads/N2
1083 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1085 clean directory copy
1088 from refs/heads/branch^0
1091 commit refs/heads/N2
1092 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1094 modify directory copy
1097 M 644 inline file3/file5
1104 cat >expect <<-EOF &&
1105 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1106 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1107 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1109 git fast-import <input &&
1110 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1111 compare_diff_raw expect actual
1114 test_expect_success 'N: copy dirty subdirectory' '
1115 cat >input <<-INPUT_END &&
1116 commit refs/heads/N3
1117 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1119 dirty directory copy
1122 from refs/heads/branch^0
1123 M 644 inline file2/file5
1133 git fast-import <input &&
1134 test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})
1137 test_expect_success 'N: copy directory by id' '
1138 cat >expect <<-\EOF &&
1139 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1140 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1142 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1143 cat >input <<-INPUT_END &&
1144 commit refs/heads/N4
1145 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1150 from refs/heads/branch^0
1151 M 040000 $subdir file3
1153 git fast-import <input &&
1154 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1155 compare_diff_raw expect actual
1158 test_expect_success PIPE 'N: read and copy directory' '
1159 cat >expect <<-\EOF &&
1160 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1161 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1163 git update-ref -d refs/heads/N4 &&
1169 commit refs/heads/N4
1170 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1172 copy by tree hash, part 2
1175 from refs/heads/branch^0
1178 read mode type tree filename &&
1179 echo "M 040000 $tree file3"
1181 git fast-import --cat-blob-fd=3 3>backflow &&
1182 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1183 compare_diff_raw expect actual
1186 test_expect_success PIPE 'N: empty directory reads as missing' '
1187 cat <<-\EOF >expect &&
1189 :000000 100644 OBJNAME OBJNAME A unrelated
1191 echo "missing src" >expect.response &&
1192 git update-ref -d refs/heads/read-empty &&
1198 commit refs/heads/read-empty
1199 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1201 read "empty" (missing) directory
1204 M 100644 inline src/greeting
1208 C src/greeting dst1/non-greeting
1209 C src/greeting unrelated
1210 # leave behind "empty" src directory
1215 printf "%s\n" "$line" >response &&
1221 git fast-import --cat-blob-fd=3 3>backflow &&
1222 test_cmp expect.response response &&
1223 git rev-list read-empty |
1224 git diff-tree -r --root --stdin |
1225 sed "s/$OID_REGEX/OBJNAME/g" >actual &&
1226 test_cmp expect actual
1229 test_expect_success 'N: copy root directory by tree hash' '
1230 cat >expect <<-\EOF &&
1231 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1232 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1234 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1235 cat >input <<-INPUT_END &&
1236 commit refs/heads/N6
1237 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1239 copy root directory by tree hash
1242 from refs/heads/branch^0
1245 git fast-import <input &&
1246 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1247 compare_diff_raw expect actual
1250 test_expect_success 'N: copy root by path' '
1251 cat >expect <<-\EOF &&
1252 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1253 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1254 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1255 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1256 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1258 cat >input <<-INPUT_END &&
1259 commit refs/heads/N-copy-root-path
1260 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1262 copy root directory by (empty) path
1265 from refs/heads/branch^0
1268 git fast-import <input &&
1269 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1270 compare_diff_raw expect actual
1273 test_expect_success 'N: delete directory by copying' '
1274 cat >expect <<-\EOF &&
1276 :100644 000000 OBJID OBJID D foo/bar/qux
1278 :000000 100644 OBJID OBJID A foo/bar/baz
1279 :000000 100644 OBJID OBJID A foo/bar/qux
1281 empty_tree=$(git mktree </dev/null) &&
1282 cat >input <<-INPUT_END &&
1283 commit refs/heads/N-delete
1284 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1286 collect data to be deleted
1290 M 100644 inline foo/bar/baz
1294 C "foo/bar/baz" "foo/bar/qux"
1295 C "foo/bar/baz" "foo/bar/quux/1"
1296 C "foo/bar/baz" "foo/bar/quuux"
1297 M 040000 $empty_tree foo/bar/quux
1298 M 040000 $empty_tree foo/bar/quuux
1300 commit refs/heads/N-delete
1301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1306 M 040000 $empty_tree foo/bar/qux
1308 git fast-import <input &&
1309 git rev-list N-delete |
1310 git diff-tree -r --stdin --root --always |
1311 sed -e "s/$OID_REGEX/OBJID/g" >actual &&
1312 test_cmp expect actual
1315 test_expect_success 'N: modify copied tree' '
1316 cat >expect <<-\EOF &&
1317 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1318 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1319 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1321 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1322 cat >input <<-INPUT_END &&
1323 commit refs/heads/N5
1324 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1329 from refs/heads/branch^0
1330 M 040000 $subdir file3
1332 commit refs/heads/N5
1333 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1335 modify directory copy
1338 M 644 inline file3/file5
1343 git fast-import <input &&
1344 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1345 compare_diff_raw expect actual
1348 test_expect_success 'N: reject foo/ syntax' '
1349 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1350 test_must_fail git fast-import <<-INPUT_END
1351 commit refs/heads/N5B
1352 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1354 copy with invalid syntax
1357 from refs/heads/branch^0
1358 M 040000 $subdir file3/
1362 test_expect_success 'N: reject foo/ syntax in copy source' '
1363 test_must_fail git fast-import <<-INPUT_END
1364 commit refs/heads/N5C
1365 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1367 copy with invalid syntax
1370 from refs/heads/branch^0
1375 test_expect_success 'N: reject foo/ syntax in rename source' '
1376 test_must_fail git fast-import <<-INPUT_END
1377 commit refs/heads/N5D
1378 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1380 rename with invalid syntax
1383 from refs/heads/branch^0
1388 test_expect_success 'N: reject foo/ syntax in ls argument' '
1389 test_must_fail git fast-import <<-INPUT_END
1390 commit refs/heads/N5E
1391 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1393 copy with invalid syntax
1396 from refs/heads/branch^0
1401 test_expect_success 'N: copy to root by id and modify' '
1402 echo "hello, world" >expect.foo &&
1403 echo hello >expect.bar &&
1404 git fast-import <<-SETUP_END &&
1405 commit refs/heads/N7
1406 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1412 M 644 inline foo/bar
1418 tree=$(git rev-parse --verify N7:) &&
1419 git fast-import <<-INPUT_END &&
1420 commit refs/heads/N8
1421 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1423 copy to root by id and modify
1427 M 644 inline foo/foo
1432 git show N8:foo/foo >actual.foo &&
1433 git show N8:foo/bar >actual.bar &&
1434 test_cmp expect.foo actual.foo &&
1435 test_cmp expect.bar actual.bar
1438 test_expect_success 'N: extract subtree' '
1439 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1440 cat >input <<-INPUT_END &&
1441 commit refs/heads/N9
1442 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1444 extract subtree branch:newdir
1450 git fast-import <input &&
1451 git diff --exit-code branch:newdir N9
1454 test_expect_success 'N: modify subtree, extract it, and modify again' '
1455 echo hello >expect.baz &&
1456 echo hello, world >expect.qux &&
1457 git fast-import <<-SETUP_END &&
1458 commit refs/heads/N10
1459 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1465 M 644 inline foo/bar/baz
1471 tree=$(git rev-parse --verify N10:) &&
1472 git fast-import <<-INPUT_END &&
1473 commit refs/heads/N11
1474 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1476 copy to root by id and modify
1480 M 100644 inline foo/bar/qux
1485 C "bar/qux" "bar/quux"
1487 git show N11:bar/baz >actual.baz &&
1488 git show N11:bar/qux >actual.qux &&
1489 git show N11:bar/quux >actual.quux &&
1490 test_cmp expect.baz actual.baz &&
1491 test_cmp expect.qux actual.qux &&
1492 test_cmp expect.qux actual.quux'
1498 test_expect_success 'O: comments are all skipped' '
1499 cat >input <<-INPUT_END &&
1501 commit refs/heads/O1
1502 # -- ignore all of this text
1503 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1504 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1506 dirty directory copy
1509 # do not forget the import blank line!
1511 # yes, we started from our usual base of branch^0.
1513 from refs/heads/branch^0
1514 # and we need to reuse file2/file5 from N3 above.
1515 M 644 inline file2/file5
1516 # otherwise the tree will be different
1521 # do not forget to copy file2 to file3
1524 # or to delete file5 from file2.
1530 git fast-import <input &&
1531 test $(git rev-parse N3) = $(git rev-parse O1)
1534 test_expect_success 'O: blank lines not necessary after data commands' '
1535 cat >input <<-INPUT_END &&
1536 commit refs/heads/O2
1537 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1539 dirty directory copy
1541 from refs/heads/branch^0
1542 M 644 inline file2/file5
1551 git fast-import <input &&
1552 test $(git rev-parse N3) = $(git rev-parse O2)
1555 test_expect_success 'O: repack before next test' '
1559 test_expect_success 'O: blank lines not necessary after other commands' '
1560 cat >input <<-INPUT_END &&
1561 commit refs/heads/O3
1562 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1566 commit refs/heads/O3
1567 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1572 commit refs/heads/O3
1574 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1579 commit refs/heads/O3
1580 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1584 reset refs/tags/O3-2nd
1586 reset refs/tags/O3-3rd
1590 cat >expect <<-INPUT_END &&
1597 git fast-import <input &&
1598 test 8 = $(find .git/objects/pack -type f | grep -v multi-pack-index | wc -l) &&
1599 test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
1600 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1601 test_cmp expect actual
1604 test_expect_success 'O: progress outputs as requested by input' '
1605 cat >input <<-INPUT_END &&
1606 commit refs/heads/O4
1607 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1611 commit refs/heads/O4
1612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1616 progress Two commits down, 2 to go!
1617 commit refs/heads/O4
1618 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1622 progress Three commits down, 1 to go!
1623 commit refs/heads/O4
1624 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1630 git fast-import <input >actual &&
1631 grep "progress " <input >expect &&
1632 test_cmp expect actual
1636 ### series P (gitlinks)
1639 test_expect_success 'P: superproject & submodule mix' '
1640 cat >input <<-INPUT_END &&
1646 reset refs/heads/sub
1647 commit refs/heads/sub
1649 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1662 commit refs/heads/subuse1
1664 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1667 from refs/heads/master
1668 M 100644 :3 .gitmodules
1677 commit refs/heads/sub
1679 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1685 commit refs/heads/subuse1
1687 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1695 git fast-import <input &&
1696 git checkout subuse1 &&
1702 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1705 git submodule init &&
1706 git submodule update
1709 test_expect_success 'P: verbatim SHA gitlinks' '
1710 SUBLAST=$(git rev-parse --verify sub) &&
1711 SUBPREV=$(git rev-parse --verify sub^) &&
1713 cat >input <<-INPUT_END &&
1722 commit refs/heads/subuse2
1724 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1727 from refs/heads/master
1728 M 100644 :1 .gitmodules
1729 M 160000 $SUBPREV sub
1731 commit refs/heads/subuse2
1733 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1737 M 160000 $SUBLAST sub
1741 git branch -D sub &&
1744 git fast-import <input &&
1745 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1748 test_expect_success 'P: fail on inline gitlink' '
1750 cat >input <<-INPUT_END &&
1751 commit refs/heads/subuse3
1753 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1758 from refs/heads/subuse2
1766 test_must_fail git fast-import <input
1769 test_expect_success 'P: fail on blob mark in gitlink' '
1771 cat >input <<-INPUT_END &&
1778 commit refs/heads/subuse3
1780 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1785 from refs/heads/subuse2
1790 test_must_fail git fast-import <input
1794 ### series Q (notes)
1797 test_expect_success 'Q: commit notes' '
1798 note1_data="The first note for the first commit" &&
1799 note2_data="The first note for the second commit" &&
1800 note3_data="The first note for the third commit" &&
1801 note1b_data="The second note for the first commit" &&
1802 note1c_data="The third note for the first commit" &&
1803 note2b_data="The second note for the second commit" &&
1806 cat >input <<-INPUT_END &&
1813 commit refs/heads/notes-test
1815 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1826 commit refs/heads/notes-test
1828 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1835 commit refs/heads/notes-test
1837 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1864 commit refs/notes/foobar
1866 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1878 commit refs/notes/foobar
1880 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1890 commit refs/notes/foobar2
1892 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1902 commit refs/notes/foobar
1904 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1917 git fast-import <input &&
1918 git whatchanged notes-test
1921 test_expect_success 'Q: verify pack' '
1925 test_expect_success 'Q: verify first commit' '
1926 commit1=$(git rev-parse notes-test~2) &&
1927 commit2=$(git rev-parse notes-test^) &&
1928 commit3=$(git rev-parse notes-test) &&
1930 cat >expect <<-EOF &&
1931 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1932 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1936 git cat-file commit notes-test~2 | sed 1d >actual &&
1937 test_cmp expect actual
1940 test_expect_success 'Q: verify second commit' '
1941 cat >expect <<-EOF &&
1943 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1944 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1948 git cat-file commit notes-test^ | sed 1d >actual &&
1949 test_cmp expect actual
1952 test_expect_success 'Q: verify third commit' '
1953 cat >expect <<-EOF &&
1955 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1956 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1960 git cat-file commit notes-test | sed 1d >actual &&
1961 test_cmp expect actual
1964 test_expect_success 'Q: verify first notes commit' '
1965 cat >expect <<-EOF &&
1966 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1967 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1971 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1972 test_cmp expect actual
1975 test_expect_success 'Q: verify first notes tree' '
1976 cat >expect.unsorted <<-EOF &&
1977 100644 blob $commit1
1978 100644 blob $commit2
1979 100644 blob $commit3
1981 cat expect.unsorted | sort >expect &&
1982 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1983 test_cmp expect actual
1986 test_expect_success 'Q: verify first note for first commit' '
1987 echo "$note1_data" >expect &&
1988 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1989 test_cmp expect actual
1992 test_expect_success 'Q: verify first note for second commit' '
1993 echo "$note2_data" >expect &&
1994 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1995 test_cmp expect actual
1998 test_expect_success 'Q: verify first note for third commit' '
1999 echo "$note3_data" >expect &&
2000 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
2001 test_cmp expect actual
2004 test_expect_success 'Q: verify second notes commit' '
2005 cat >expect <<-EOF &&
2006 parent $(git rev-parse --verify refs/notes/foobar~2)
2007 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2008 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2012 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
2013 test_cmp expect actual
2016 test_expect_success 'Q: verify second notes tree' '
2017 cat >expect.unsorted <<-EOF &&
2018 100644 blob $commit1
2019 100644 blob $commit2
2020 100644 blob $commit3
2022 cat expect.unsorted | sort >expect &&
2023 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2024 test_cmp expect actual
2027 test_expect_success 'Q: verify second note for first commit' '
2028 echo "$note1b_data" >expect &&
2029 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
2030 test_cmp expect actual
2033 test_expect_success 'Q: verify first note for second commit' '
2034 echo "$note2_data" >expect &&
2035 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
2036 test_cmp expect actual
2039 test_expect_success 'Q: verify first note for third commit' '
2040 echo "$note3_data" >expect &&
2041 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2042 test_cmp expect actual
2045 test_expect_success 'Q: verify third notes commit' '
2046 cat >expect <<-EOF &&
2047 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2048 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2052 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2053 test_cmp expect actual
2056 test_expect_success 'Q: verify third notes tree' '
2057 cat >expect.unsorted <<-EOF &&
2058 100644 blob $commit1
2060 cat expect.unsorted | sort >expect &&
2061 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2062 test_cmp expect actual
2065 test_expect_success 'Q: verify third note for first commit' '
2066 echo "$note1c_data" >expect &&
2067 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2068 test_cmp expect actual
2071 test_expect_success 'Q: verify fourth notes commit' '
2072 cat >expect <<-EOF &&
2073 parent $(git rev-parse --verify refs/notes/foobar^)
2074 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2075 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2079 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2080 test_cmp expect actual
2083 test_expect_success 'Q: verify fourth notes tree' '
2084 cat >expect.unsorted <<-EOF &&
2085 100644 blob $commit2
2087 cat expect.unsorted | sort >expect &&
2088 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2089 test_cmp expect actual
2092 test_expect_success 'Q: verify second note for second commit' '
2093 echo "$note2b_data" >expect &&
2094 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2095 test_cmp expect actual
2098 test_expect_success 'Q: deny note on empty branch' '
2099 cat >input <<-EOF &&
2102 commit refs/heads/note-Q0
2103 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2105 Note for an empty branch.
2108 N inline refs/heads/Q0
2113 test_must_fail git fast-import <input
2116 ### series R (feature and option)
2119 test_expect_success 'R: abort on unsupported feature' '
2120 cat >input <<-EOF &&
2121 feature no-such-feature-exists
2124 test_must_fail git fast-import <input
2127 test_expect_success 'R: supported feature is accepted' '
2128 cat >input <<-EOF &&
2129 feature date-format=now
2132 git fast-import <input
2135 test_expect_success 'R: abort on receiving feature after data command' '
2136 cat >input <<-EOF &&
2140 feature date-format=now
2143 test_must_fail git fast-import <input
2146 test_expect_success 'R: import-marks features forbidden by default' '
2148 echo "feature import-marks=git.marks" >input &&
2149 test_must_fail git fast-import <input &&
2150 echo "feature import-marks-if-exists=git.marks" >input &&
2151 test_must_fail git fast-import <input
2154 test_expect_success 'R: only one import-marks feature allowed per stream' '
2157 cat >input <<-EOF &&
2158 feature import-marks=git.marks
2159 feature import-marks=git2.marks
2162 test_must_fail git fast-import --allow-unsafe-features <input
2165 test_expect_success 'R: export-marks feature forbidden by default' '
2166 echo "feature export-marks=git.marks" >input &&
2167 test_must_fail git fast-import <input
2170 test_expect_success 'R: export-marks feature results in a marks file being created' '
2171 cat >input <<-EOF &&
2172 feature export-marks=git.marks
2180 git fast-import --allow-unsafe-features <input &&
2184 test_expect_success 'R: export-marks options can be overridden by commandline options' '
2185 cat >input <<-\EOF &&
2186 feature export-marks=feature-sub/git.marks
2193 git fast-import --allow-unsafe-features \
2194 --export-marks=cmdline-sub/other.marks <input &&
2195 grep :1 cmdline-sub/other.marks &&
2196 test_path_is_missing feature-sub
2199 test_expect_success 'R: catch typo in marks file name' '
2200 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2201 echo "feature import-marks=nonexistent.marks" |
2202 test_must_fail git fast-import --allow-unsafe-features
2205 test_expect_success 'R: import and output marks can be the same file' '
2207 blob=$(echo hi | git hash-object --stdin) &&
2208 cat >expect <<-EOF &&
2212 git fast-import --export-marks=io.marks <<-\EOF &&
2219 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2226 test_cmp expect io.marks
2229 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2231 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2240 test_expect_success 'R: --import-marks-if-exists' '
2242 blob=$(echo hi | git hash-object --stdin) &&
2243 echo ":1 $blob" >expect &&
2244 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2251 test_cmp expect io.marks
2254 test_expect_success 'R: feature import-marks-if-exists' '
2257 git fast-import --export-marks=io.marks \
2258 --allow-unsafe-features <<-\EOF &&
2259 feature import-marks-if-exists=not_io.marks
2261 test_must_be_empty io.marks &&
2263 blob=$(echo hi | git hash-object --stdin) &&
2265 echo ":1 $blob" >io.marks &&
2266 echo ":1 $blob" >expect &&
2267 echo ":2 $blob" >>expect &&
2269 git fast-import --export-marks=io.marks \
2270 --allow-unsafe-features <<-\EOF &&
2271 feature import-marks-if-exists=io.marks
2278 test_cmp expect io.marks &&
2280 echo ":3 $blob" >>expect &&
2282 git fast-import --import-marks=io.marks \
2283 --export-marks=io.marks \
2284 --allow-unsafe-features <<-\EOF &&
2285 feature import-marks-if-exists=not_io.marks
2292 test_cmp expect io.marks &&
2294 git fast-import --import-marks-if-exists=not_io.marks \
2295 --export-marks=io.marks \
2296 --allow-unsafe-features <<-\EOF &&
2297 feature import-marks-if-exists=io.marks
2299 test_must_be_empty io.marks
2302 test_expect_success 'R: import to output marks works without any content' '
2303 cat >input <<-EOF &&
2304 feature import-marks=marks.out
2305 feature export-marks=marks.new
2308 git fast-import --allow-unsafe-features <input &&
2309 test_cmp marks.out marks.new
2312 test_expect_success 'R: import marks prefers commandline marks file over the stream' '
2313 cat >input <<-EOF &&
2314 feature import-marks=nonexistent.marks
2315 feature export-marks=marks.new
2318 git fast-import --import-marks=marks.out --allow-unsafe-features <input &&
2319 test_cmp marks.out marks.new
2323 test_expect_success 'R: multiple --import-marks= should be honoured' '
2324 cat >input <<-EOF &&
2325 feature import-marks=nonexistent.marks
2326 feature export-marks=combined.marks
2329 head -n2 marks.out > one.marks &&
2330 tail -n +3 marks.out > two.marks &&
2331 git fast-import --import-marks=one.marks --import-marks=two.marks \
2332 --allow-unsafe-features <input &&
2333 test_cmp marks.out combined.marks
2336 test_expect_success 'R: feature relative-marks should be honoured' '
2337 cat >input <<-EOF &&
2338 feature relative-marks
2339 feature import-marks=relative.in
2340 feature export-marks=relative.out
2343 mkdir -p .git/info/fast-import/ &&
2344 cp marks.new .git/info/fast-import/relative.in &&
2345 git fast-import --allow-unsafe-features <input &&
2346 test_cmp marks.new .git/info/fast-import/relative.out
2349 test_expect_success 'R: feature no-relative-marks should be honoured' '
2350 cat >input <<-EOF &&
2351 feature relative-marks
2352 feature import-marks=relative.in
2353 feature no-relative-marks
2354 feature export-marks=non-relative.out
2357 git fast-import --allow-unsafe-features <input &&
2358 test_cmp marks.new non-relative.out
2361 test_expect_success 'R: feature ls supported' '
2366 test_expect_success 'R: feature cat-blob supported' '
2367 echo "feature cat-blob" |
2371 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2372 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2375 test_expect_success !MINGW 'R: print old blob' '
2376 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2377 cat >expect <<-EOF &&
2382 echo "cat-blob $blob" |
2383 git fast-import --cat-blob-fd=6 6>actual &&
2384 test_cmp expect actual
2387 test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
2388 echo hello >greeting &&
2389 blob=$(git hash-object -w greeting) &&
2390 cat >expect <<-EOF &&
2395 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2398 test_cmp expect actual.3 &&
2399 test_must_be_empty actual.1 &&
2400 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2401 option cat-blob-fd=3
2404 test_must_be_empty actual.3 &&
2405 test_cmp expect actual.1
2408 test_expect_success !MINGW 'R: print mark for new blob' '
2409 echo "effluentish" | git hash-object --stdin >expect &&
2410 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2418 test_cmp expect actual
2421 test_expect_success !MINGW 'R: print new blob' '
2422 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2423 cat >expect <<-EOF &&
2428 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2436 test_cmp expect actual
2439 test_expect_success !MINGW 'R: print new blob by sha1' '
2440 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2441 cat >expect <<-EOF &&
2443 a new blob named by sha1
2446 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2449 a new blob named by sha1
2453 test_cmp expect actual
2456 test_expect_success 'setup: big file' '
2458 echo "the quick brown fox jumps over the lazy dog" >big &&
2461 cat big big big big >bigger &&
2462 cat bigger bigger bigger bigger >big ||
2468 test_expect_success 'R: print two blobs to stdout' '
2469 blob1=$(git hash-object big) &&
2470 blob1_len=$(wc -c <big) &&
2471 blob2=$(echo hello | git hash-object --stdin) &&
2473 echo ${blob1} blob $blob1_len &&
2483 cat <<-\END_PART1 &&
2500 git fast-import >actual &&
2501 test_cmp expect actual
2504 test_expect_success PIPE 'R: copy using cat-file' '
2505 expect_id=$(git hash-object big) &&
2506 expect_len=$(wc -c <big) &&
2507 echo $expect_id blob $expect_len >expect.response &&
2513 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2526 read blob_id type size <&3 &&
2527 echo "$blob_id $type $size" >response &&
2528 test_copy_bytes $size >blob <&3 &&
2532 commit refs/heads/copied
2533 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2535 copy big file as file3
2543 git fast-import --cat-blob-fd=3 3>blobs &&
2544 git show copied:file3 >actual &&
2545 test_cmp expect.response response &&
2549 test_expect_success PIPE 'R: print blob mid-commit' '
2551 echo "A blob from _before_ the commit." >expect &&
2560 A blob from _before_ the commit.
2562 commit refs/heads/temporary
2563 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2570 read blob_id type size <&3 &&
2571 test_copy_bytes $size >actual <&3 &&
2576 git fast-import --cat-blob-fd=3 3>blobs &&
2577 test_cmp expect actual
2580 test_expect_success PIPE 'R: print staged blob within commit' '
2582 echo "A blob from _within_ the commit." >expect &&
2588 commit refs/heads/within
2589 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2595 A blob from _within_ the commit.
2600 echo "A blob from _within_ the commit." |
2601 git hash-object --stdin
2603 echo "cat-blob $to_get" &&
2605 read blob_id type size <&3 &&
2606 test_copy_bytes $size >actual <&3 &&
2611 git fast-import --cat-blob-fd=3 3>blobs &&
2612 test_cmp expect actual
2615 test_expect_success 'R: quiet option results in no stats being output' '
2616 cat >input <<-EOF &&
2624 git fast-import 2>output <input &&
2625 test_must_be_empty output
2628 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2629 echo feature done | test_must_fail git fast-import &&
2630 test_must_fail git fast-import --done </dev/null
2633 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2634 git fast-import <<-\EOF &&
2639 git fast-import <<-\EOF
2641 more trailing gibberish
2645 test_expect_success 'R: terminating "done" within commit' '
2646 cat >expect <<-\EOF &&
2648 :000000 100644 OBJID OBJID A hello.c
2649 :000000 100644 OBJID OBJID A hello2.c
2651 git fast-import <<-EOF &&
2652 commit refs/heads/done-ends
2653 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2655 Commit terminated by "done" command
2657 M 100644 inline hello.c
2664 git rev-list done-ends |
2665 git diff-tree -r --stdin --root --always |
2666 sed -e "s/$OID_REGEX/OBJID/g" >actual &&
2667 test_cmp expect actual
2670 test_expect_success 'R: die on unknown option' '
2671 cat >input <<-EOF &&
2672 option git non-existing-option
2675 test_must_fail git fast-import <input
2678 test_expect_success 'R: unknown commandline options are rejected' '\
2679 test_must_fail git fast-import --non-existing-option < /dev/null
2682 test_expect_success 'R: die on invalid option argument' '
2683 echo "option git active-branches=-5" |
2684 test_must_fail git fast-import &&
2685 echo "option git depth=" |
2686 test_must_fail git fast-import &&
2687 test_must_fail git fast-import --depth="5 elephants" </dev/null
2690 test_expect_success 'R: ignore non-git options' '
2691 cat >input <<-EOF &&
2692 option non-existing-vcs non-existing-option
2695 git fast-import <input
2698 test_expect_success 'R: corrupt lines do not mess marks file' '
2700 blob=$(echo hi | git hash-object --stdin) &&
2701 cat >expect <<-EOF &&
2702 :3 0000000000000000000000000000000000000000
2706 cp expect io.marks &&
2707 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2710 test_cmp expect io.marks
2714 ## R: very large blobs
2716 test_expect_success 'R: blob bigger than threshold' '
2717 blobsize=$((2*1024*1024 + 53)) &&
2718 test-tool genrandom bar $blobsize >expect &&
2719 cat >input <<-INPUT_END &&
2720 commit refs/heads/big-file
2721 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2729 cat expect >>input &&
2730 cat >>input <<-INPUT_END &&
2734 cat expect >>input &&
2737 test_create_repo R &&
2738 git --git-dir=R/.git config fastimport.unpackLimit 0 &&
2739 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2742 test_expect_success 'R: verify created pack' '
2745 verify_packs -v > ../verify
2749 test_expect_success 'R: verify written objects' '
2750 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2751 test_cmp_bin expect actual &&
2752 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2753 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2757 test_expect_success 'R: blob appears only once' '
2758 n=$(grep $a verify | wc -l) &&
2766 # Make sure missing spaces and EOLs after mark references
2775 # commit marks: 301, 302, 303, 304
2776 # blob marks: 403, 404, resp.
2779 # The error message when a space is missing not at the
2780 # end of the line is:
2782 # Missing space after ..
2784 # or when extra characters come after the mark at the end
2789 # or when the dataref is neither "inline " or a known SHA1,
2791 # Invalid dataref ..
2793 test_expect_success 'S: initialize for S tests' '
2796 cat >input <<-INPUT_END &&
2799 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2803 M 100644 inline hello.c
2810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2815 M 100644 inline hello.c
2833 git fast-import --export-marks=marks <input
2837 # filemodify, three datarefs
2839 test_expect_success 'S: filemodify with garbage after mark must fail' '
2840 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2842 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2846 M 100644 :403x hello.c
2848 test_i18ngrep "space after mark" err
2851 # inline is misspelled; fast-import thinks it is some unknown dataref
2852 test_expect_success 'S: filemodify with garbage after inline must fail' '
2853 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2855 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2859 M 100644 inlineX hello.c
2864 test_i18ngrep "nvalid dataref" err
2867 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2868 sha1=$(grep :403 marks | cut -d\ -f2) &&
2869 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2871 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2875 M 100644 ${sha1}x hello.c
2877 test_i18ngrep "space after SHA1" err
2881 # notemodify, three ways to say dataref
2883 test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
2884 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2886 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2888 commit S note dataref markref
2892 test_i18ngrep "space after mark" err
2895 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2896 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2898 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2900 commit S note dataref inline
2907 test_i18ngrep "nvalid dataref" err
2910 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2911 sha1=$(grep :202 marks | cut -d\ -f2) &&
2912 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2914 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2916 commit S note dataref sha1
2920 test_i18ngrep "space after SHA1" err
2924 # notemodify, mark in commit-ish
2926 test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
2927 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2928 commit refs/heads/Snotes
2929 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2931 commit S note commit-ish
2935 test_i18ngrep "after mark" err
2941 test_expect_success 'S: from with garbage after mark must fail' '
2943 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2944 commit refs/heads/S2
2946 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2951 M 100644 :403 hello.c
2955 # go create the commit, need it for merge test
2956 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2957 commit refs/heads/S2
2959 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2964 M 100644 :403 hello.c
2967 # now evaluate the error
2968 test_i18ngrep "after mark" err
2975 test_expect_success 'S: merge with garbage after mark must fail' '
2976 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2979 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2985 M 100644 :403 hello.c
2987 test_i18ngrep "after mark" err
2993 test_expect_success 'S: tag with garbage after mark must fail' '
2994 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2997 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3002 test_i18ngrep "after mark" err
3008 test_expect_success 'S: cat-blob with garbage after mark must fail' '
3009 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
3012 test_i18ngrep "after mark" err
3018 test_expect_success 'S: ls with garbage after mark must fail' '
3019 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
3022 test_i18ngrep "space after mark" err
3025 test_expect_success 'S: ls with garbage after sha1 must fail' '
3026 sha1=$(grep :302 marks | cut -d\ -f2) &&
3027 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
3030 test_i18ngrep "space after tree-ish" err
3036 # Setup is carried over from series S.
3038 test_expect_success 'T: ls root tree' '
3039 sed -e "s/Z\$//" >expect <<-EOF &&
3040 040000 tree $(git rev-parse S^{tree}) Z
3042 sha1=$(git rev-parse --verify S) &&
3043 git fast-import --import-marks=marks <<-EOF >actual &&
3046 test_cmp expect actual
3049 test_expect_success 'T: delete branch' '
3050 git branch to-delete &&
3051 git fast-import <<-EOF &&
3052 reset refs/heads/to-delete
3053 from 0000000000000000000000000000000000000000
3055 test_must_fail git rev-parse --verify refs/heads/to-delete
3058 test_expect_success 'T: empty reset doesnt delete branch' '
3059 git branch not-to-delete &&
3060 git fast-import <<-EOF &&
3061 reset refs/heads/not-to-delete
3064 git rev-parse --verify refs/heads/not-to-delete
3068 ### series U (filedelete)
3071 test_expect_success 'U: initialize for U tests' '
3072 cat >input <<-INPUT_END &&
3074 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3078 M 100644 inline hello.c
3082 M 100644 inline good/night.txt
3086 M 100644 inline good/bye.txt
3093 git fast-import <input
3096 test_expect_success 'U: filedelete file succeeds' '
3097 cat >input <<-INPUT_END &&
3099 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3101 delete good/night.txt
3108 git fast-import <input
3111 test_expect_success 'U: validate file delete result' '
3112 cat >expect <<-EOF &&
3113 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3116 git diff-tree -M -r U^1 U >actual &&
3118 compare_diff_raw expect actual
3121 test_expect_success 'U: filedelete directory succeeds' '
3122 cat >input <<-INPUT_END &&
3124 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3133 git fast-import <input
3136 test_expect_success 'U: validate directory delete result' '
3137 cat >expect <<-EOF &&
3138 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3141 git diff-tree -M -r U^1 U >actual &&
3143 compare_diff_raw expect actual
3146 test_expect_success 'U: filedelete root succeeds' '
3147 cat >input <<-INPUT_END &&
3149 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3158 git fast-import <input
3161 test_expect_success 'U: validate root delete result' '
3162 cat >expect <<-EOF &&
3163 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3166 git diff-tree -M -r U^1 U >actual &&
3168 compare_diff_raw expect actual
3172 ### series V (checkpoint)
3175 # The commands in input_file should not produce any output on the file
3176 # descriptor set with --cat-blob-fd (or stdout if unspecified).
3178 # To make sure you're observing the side effects of checkpoint *before*
3179 # fast-import terminates (and thus writes out its state), check that the
3180 # fast-import process is still running using background_import_still_running
3181 # *after* evaluating the test conditions.
3182 background_import_then_checkpoint () {
3195 git fast-import $options <&8 >&9 &
3198 echo >&2 "background fast-import terminated too early with exit code $?"
3199 # Un-block the read loop in the main shell process.
3204 # We don't mind if fast-import has already died by the time the test
3206 test_when_finished "
3207 exec 8>&-; exec 9>&-;
3208 kill $sh_pid && wait $sh_pid
3209 kill $fi_pid && wait $fi_pid
3212 # Start in the background to ensure we adhere strictly to (blocking)
3213 # pipes writing sequence. We want to assume that the write below could
3214 # block, e.g. if fast-import blocks writing its own output to &9
3215 # because there is no reader on &9 yet.
3219 echo "progress checkpoint"
3222 error=1 ;# assume the worst
3223 while read output <&9
3225 if test "$output" = "progress checkpoint"
3229 elif test "$output" = "UNEXPECTED"
3233 # otherwise ignore cruft
3234 echo >&2 "cruft: $output"
3237 if test $error -eq 1
3243 background_import_still_running () {
3244 if ! kill -0 "$fi_pid"
3246 echo >&2 "background fast-import terminated too early"
3251 test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' '
3252 cat >input <<-INPUT_END &&
3258 background_import_then_checkpoint "" input &&
3259 background_import_still_running
3262 test_expect_success PIPE 'V: checkpoint updates refs after reset' '
3263 cat >input <<-\INPUT_END &&
3269 background_import_then_checkpoint "" input &&
3270 test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" &&
3271 background_import_still_running
3274 test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' '
3275 cat >input <<-INPUT_END &&
3278 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3284 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3286 echo ":1 $(git rev-parse --verify V)" >marks.expected &&
3288 test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" &&
3289 test_cmp marks.expected marks.actual &&
3290 background_import_still_running
3293 # Re-create the exact same commit, but on a different branch: no new object is
3294 # created in the database, but the refs and marks still need to be updated.
3295 test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' '
3296 cat >input <<-INPUT_END &&
3297 commit refs/heads/V2
3299 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3305 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3307 echo ":2 $(git rev-parse --verify V2)" >marks.expected &&
3309 test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" &&
3310 test_cmp marks.expected marks.actual &&
3311 background_import_still_running
3314 test_expect_success PIPE 'V: checkpoint updates tags after tag' '
3315 cat >input <<-INPUT_END &&
3318 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3323 background_import_then_checkpoint "" input &&
3324 git show-ref -d Vtag &&
3325 background_import_still_running
3329 ### series W (get-mark and empty orphan commits)
3332 cat >>W-input <<-W_INPUT_END
3333 commit refs/heads/W-branch
3335 author Full Name <user@company.tld> 1000000000 +0100
3336 committer Full Name <user@company.tld> 1000000000 +0100
3338 Intentionally empty commit
3342 test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
3343 sed -e s/LFs// W-input | tr L "\n" | git fast-import
3346 test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
3347 sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
3350 test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
3351 # Technically, this should fail as it has too many linefeeds
3352 # according to the grammar in fast-import.txt. But, for whatever
3353 # reason, it works. Since using the correct number of newlines
3354 # does not work with older (pre-2.22) versions of git, allow apps
3355 # that used this second-newline workaround to keep working by
3356 # checking it with this test...
3357 sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import
3360 test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
3361 # ...but do NOT allow more empty lines than that (see previous test).
3362 sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import
3366 ### series X (other new features)
3369 test_expect_success 'X: handling encoding' '
3371 cat >input <<-INPUT_END &&
3372 commit refs/heads/encoding
3373 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3378 printf "Pi: \360\nCOMMIT\n" >>input &&
3380 git fast-import <input &&
3381 git cat-file -p encoding | grep $(printf "\360") &&
3382 git log -1 --format=%B encoding | grep $(printf "\317\200")