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 &&
1050 compare_diff_raw expect actual
1057 test_expect_success 'N: copy file in same subdirectory' '
1059 cat >input <<-INPUT_END &&
1060 commit refs/heads/N1
1061 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1066 from refs/heads/branch^0
1067 C file2/newf file2/n.e.w.f
1071 cat >expect <<-EOF &&
1072 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1074 git fast-import <input &&
1075 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1076 compare_diff_raw expect actual
1079 test_expect_success 'N: copy then modify subdirectory' '
1080 cat >input <<-INPUT_END &&
1081 commit refs/heads/N2
1082 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1084 clean directory copy
1087 from refs/heads/branch^0
1090 commit refs/heads/N2
1091 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1093 modify directory copy
1096 M 644 inline file3/file5
1103 cat >expect <<-EOF &&
1104 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1105 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1106 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1108 git fast-import <input &&
1109 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1110 compare_diff_raw expect actual
1113 test_expect_success 'N: copy dirty subdirectory' '
1114 cat >input <<-INPUT_END &&
1115 commit refs/heads/N3
1116 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1118 dirty directory copy
1121 from refs/heads/branch^0
1122 M 644 inline file2/file5
1132 git fast-import <input &&
1133 test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})
1136 test_expect_success 'N: copy directory by id' '
1137 cat >expect <<-\EOF &&
1138 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1139 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1141 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1142 cat >input <<-INPUT_END &&
1143 commit refs/heads/N4
1144 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1149 from refs/heads/branch^0
1150 M 040000 $subdir file3
1152 git fast-import <input &&
1153 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1154 compare_diff_raw expect actual
1157 test_expect_success PIPE 'N: read and copy directory' '
1158 cat >expect <<-\EOF &&
1159 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1160 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1162 git update-ref -d refs/heads/N4 &&
1168 commit refs/heads/N4
1169 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1171 copy by tree hash, part 2
1174 from refs/heads/branch^0
1177 read mode type tree filename &&
1178 echo "M 040000 $tree file3"
1180 git fast-import --cat-blob-fd=3 3>backflow &&
1181 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1182 compare_diff_raw expect actual
1185 test_expect_success PIPE 'N: empty directory reads as missing' '
1186 cat <<-\EOF >expect &&
1188 :000000 100644 OBJNAME OBJNAME A unrelated
1190 echo "missing src" >expect.response &&
1191 git update-ref -d refs/heads/read-empty &&
1197 commit refs/heads/read-empty
1198 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1200 read "empty" (missing) directory
1203 M 100644 inline src/greeting
1207 C src/greeting dst1/non-greeting
1208 C src/greeting unrelated
1209 # leave behind "empty" src directory
1214 printf "%s\n" "$line" >response &&
1220 git fast-import --cat-blob-fd=3 3>backflow &&
1221 test_cmp expect.response response &&
1222 git rev-list read-empty |
1223 git diff-tree -r --root --stdin |
1224 sed "s/$OID_REGEX/OBJNAME/g" >actual &&
1225 test_cmp expect actual
1228 test_expect_success 'N: copy root directory by tree hash' '
1229 cat >expect <<-\EOF &&
1230 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1231 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1233 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1234 cat >input <<-INPUT_END &&
1235 commit refs/heads/N6
1236 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1238 copy root directory by tree hash
1241 from refs/heads/branch^0
1244 git fast-import <input &&
1245 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1246 compare_diff_raw expect actual
1249 test_expect_success 'N: copy root by path' '
1250 cat >expect <<-\EOF &&
1251 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1252 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1253 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1254 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1255 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1257 cat >input <<-INPUT_END &&
1258 commit refs/heads/N-copy-root-path
1259 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1261 copy root directory by (empty) path
1264 from refs/heads/branch^0
1267 git fast-import <input &&
1268 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1269 compare_diff_raw expect actual
1272 test_expect_success 'N: delete directory by copying' '
1273 cat >expect <<-\EOF &&
1275 :100644 000000 OBJID OBJID D foo/bar/qux
1277 :000000 100644 OBJID OBJID A foo/bar/baz
1278 :000000 100644 OBJID OBJID A foo/bar/qux
1280 empty_tree=$(git mktree </dev/null) &&
1281 cat >input <<-INPUT_END &&
1282 commit refs/heads/N-delete
1283 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1285 collect data to be deleted
1289 M 100644 inline foo/bar/baz
1293 C "foo/bar/baz" "foo/bar/qux"
1294 C "foo/bar/baz" "foo/bar/quux/1"
1295 C "foo/bar/baz" "foo/bar/quuux"
1296 M 040000 $empty_tree foo/bar/quux
1297 M 040000 $empty_tree foo/bar/quuux
1299 commit refs/heads/N-delete
1300 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1305 M 040000 $empty_tree foo/bar/qux
1307 git fast-import <input &&
1308 git rev-list N-delete |
1309 git diff-tree -r --stdin --root --always |
1310 sed -e "s/$OID_REGEX/OBJID/g" >actual &&
1311 test_cmp expect actual
1314 test_expect_success 'N: modify copied tree' '
1315 cat >expect <<-\EOF &&
1316 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1317 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1318 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1320 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1321 cat >input <<-INPUT_END &&
1322 commit refs/heads/N5
1323 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1328 from refs/heads/branch^0
1329 M 040000 $subdir file3
1331 commit refs/heads/N5
1332 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1334 modify directory copy
1337 M 644 inline file3/file5
1342 git fast-import <input &&
1343 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1344 compare_diff_raw expect actual
1347 test_expect_success 'N: reject foo/ syntax' '
1348 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1349 test_must_fail git fast-import <<-INPUT_END
1350 commit refs/heads/N5B
1351 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1353 copy with invalid syntax
1356 from refs/heads/branch^0
1357 M 040000 $subdir file3/
1361 test_expect_success 'N: reject foo/ syntax in copy source' '
1362 test_must_fail git fast-import <<-INPUT_END
1363 commit refs/heads/N5C
1364 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1366 copy with invalid syntax
1369 from refs/heads/branch^0
1374 test_expect_success 'N: reject foo/ syntax in rename source' '
1375 test_must_fail git fast-import <<-INPUT_END
1376 commit refs/heads/N5D
1377 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1379 rename with invalid syntax
1382 from refs/heads/branch^0
1387 test_expect_success 'N: reject foo/ syntax in ls argument' '
1388 test_must_fail git fast-import <<-INPUT_END
1389 commit refs/heads/N5E
1390 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1392 copy with invalid syntax
1395 from refs/heads/branch^0
1400 test_expect_success 'N: copy to root by id and modify' '
1401 echo "hello, world" >expect.foo &&
1402 echo hello >expect.bar &&
1403 git fast-import <<-SETUP_END &&
1404 commit refs/heads/N7
1405 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1411 M 644 inline foo/bar
1417 tree=$(git rev-parse --verify N7:) &&
1418 git fast-import <<-INPUT_END &&
1419 commit refs/heads/N8
1420 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1422 copy to root by id and modify
1426 M 644 inline foo/foo
1431 git show N8:foo/foo >actual.foo &&
1432 git show N8:foo/bar >actual.bar &&
1433 test_cmp expect.foo actual.foo &&
1434 test_cmp expect.bar actual.bar
1437 test_expect_success 'N: extract subtree' '
1438 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1439 cat >input <<-INPUT_END &&
1440 commit refs/heads/N9
1441 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1443 extract subtree branch:newdir
1449 git fast-import <input &&
1450 git diff --exit-code branch:newdir N9
1453 test_expect_success 'N: modify subtree, extract it, and modify again' '
1454 echo hello >expect.baz &&
1455 echo hello, world >expect.qux &&
1456 git fast-import <<-SETUP_END &&
1457 commit refs/heads/N10
1458 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1464 M 644 inline foo/bar/baz
1470 tree=$(git rev-parse --verify N10:) &&
1471 git fast-import <<-INPUT_END &&
1472 commit refs/heads/N11
1473 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1475 copy to root by id and modify
1479 M 100644 inline foo/bar/qux
1484 C "bar/qux" "bar/quux"
1486 git show N11:bar/baz >actual.baz &&
1487 git show N11:bar/qux >actual.qux &&
1488 git show N11:bar/quux >actual.quux &&
1489 test_cmp expect.baz actual.baz &&
1490 test_cmp expect.qux actual.qux &&
1491 test_cmp expect.qux actual.quux'
1497 test_expect_success 'O: comments are all skipped' '
1498 cat >input <<-INPUT_END &&
1500 commit refs/heads/O1
1501 # -- ignore all of this text
1502 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1503 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1505 dirty directory copy
1508 # do not forget the import blank line!
1510 # yes, we started from our usual base of branch^0.
1512 from refs/heads/branch^0
1513 # and we need to reuse file2/file5 from N3 above.
1514 M 644 inline file2/file5
1515 # otherwise the tree will be different
1520 # do not forget to copy file2 to file3
1523 # or to delete file5 from file2.
1529 git fast-import <input &&
1530 test $(git rev-parse N3) = $(git rev-parse O1)
1533 test_expect_success 'O: blank lines not necessary after data commands' '
1534 cat >input <<-INPUT_END &&
1535 commit refs/heads/O2
1536 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1538 dirty directory copy
1540 from refs/heads/branch^0
1541 M 644 inline file2/file5
1550 git fast-import <input &&
1551 test $(git rev-parse N3) = $(git rev-parse O2)
1554 test_expect_success 'O: repack before next test' '
1558 test_expect_success 'O: blank lines not necessary after other commands' '
1559 cat >input <<-INPUT_END &&
1560 commit refs/heads/O3
1561 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1565 commit refs/heads/O3
1566 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1571 commit refs/heads/O3
1573 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1578 commit refs/heads/O3
1579 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1583 reset refs/tags/O3-2nd
1585 reset refs/tags/O3-3rd
1589 cat >expect <<-INPUT_END &&
1596 git fast-import <input &&
1597 test 8 = $(find .git/objects/pack -type f | grep -v multi-pack-index | wc -l) &&
1598 test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
1599 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1600 test_cmp expect actual
1603 test_expect_success 'O: progress outputs as requested by input' '
1604 cat >input <<-INPUT_END &&
1605 commit refs/heads/O4
1606 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1610 commit refs/heads/O4
1611 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1615 progress Two commits down, 2 to go!
1616 commit refs/heads/O4
1617 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1621 progress Three commits down, 1 to go!
1622 commit refs/heads/O4
1623 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1629 git fast-import <input >actual &&
1630 grep "progress " <input >expect &&
1631 test_cmp expect actual
1635 ### series P (gitlinks)
1638 test_expect_success 'P: superproject & submodule mix' '
1639 cat >input <<-INPUT_END &&
1645 reset refs/heads/sub
1646 commit refs/heads/sub
1648 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1661 commit refs/heads/subuse1
1663 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1666 from refs/heads/master
1667 M 100644 :3 .gitmodules
1676 commit refs/heads/sub
1678 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1684 commit refs/heads/subuse1
1686 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1694 git fast-import <input &&
1695 git checkout subuse1 &&
1701 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1704 git submodule init &&
1705 git submodule update
1708 test_expect_success 'P: verbatim SHA gitlinks' '
1709 SUBLAST=$(git rev-parse --verify sub) &&
1710 SUBPREV=$(git rev-parse --verify sub^) &&
1712 cat >input <<-INPUT_END &&
1721 commit refs/heads/subuse2
1723 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1726 from refs/heads/master
1727 M 100644 :1 .gitmodules
1728 M 160000 $SUBPREV sub
1730 commit refs/heads/subuse2
1732 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1736 M 160000 $SUBLAST sub
1740 git branch -D sub &&
1743 git fast-import <input &&
1744 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1747 test_expect_success 'P: fail on inline gitlink' '
1749 cat >input <<-INPUT_END &&
1750 commit refs/heads/subuse3
1752 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1757 from refs/heads/subuse2
1765 test_must_fail git fast-import <input
1768 test_expect_success 'P: fail on blob mark in gitlink' '
1770 cat >input <<-INPUT_END &&
1777 commit refs/heads/subuse3
1779 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1784 from refs/heads/subuse2
1789 test_must_fail git fast-import <input
1793 ### series Q (notes)
1796 test_expect_success 'Q: commit notes' '
1797 note1_data="The first note for the first commit" &&
1798 note2_data="The first note for the second commit" &&
1799 note3_data="The first note for the third commit" &&
1800 note1b_data="The second note for the first commit" &&
1801 note1c_data="The third note for the first commit" &&
1802 note2b_data="The second note for the second commit" &&
1805 cat >input <<-INPUT_END &&
1812 commit refs/heads/notes-test
1814 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1825 commit refs/heads/notes-test
1827 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1834 commit refs/heads/notes-test
1836 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1863 commit refs/notes/foobar
1865 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1877 commit refs/notes/foobar
1879 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1889 commit refs/notes/foobar2
1891 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1901 commit refs/notes/foobar
1903 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1916 git fast-import <input &&
1917 git whatchanged notes-test
1920 test_expect_success 'Q: verify pack' '
1924 test_expect_success 'Q: verify first commit' '
1925 commit1=$(git rev-parse notes-test~2) &&
1926 commit2=$(git rev-parse notes-test^) &&
1927 commit3=$(git rev-parse notes-test) &&
1929 cat >expect <<-EOF &&
1930 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1931 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1935 git cat-file commit notes-test~2 | sed 1d >actual &&
1936 test_cmp expect actual
1939 test_expect_success 'Q: verify second commit' '
1940 cat >expect <<-EOF &&
1942 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1943 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1947 git cat-file commit notes-test^ | sed 1d >actual &&
1948 test_cmp expect actual
1951 test_expect_success 'Q: verify third commit' '
1952 cat >expect <<-EOF &&
1954 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1955 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1959 git cat-file commit notes-test | sed 1d >actual &&
1960 test_cmp expect actual
1963 test_expect_success 'Q: verify first notes commit' '
1964 cat >expect <<-EOF &&
1965 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1966 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1970 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1971 test_cmp expect actual
1974 test_expect_success 'Q: verify first notes tree' '
1975 cat >expect.unsorted <<-EOF &&
1976 100644 blob $commit1
1977 100644 blob $commit2
1978 100644 blob $commit3
1980 cat expect.unsorted | sort >expect &&
1981 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1982 test_cmp expect actual
1985 test_expect_success 'Q: verify first note for first commit' '
1986 echo "$note1_data" >expect &&
1987 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1988 test_cmp expect actual
1991 test_expect_success 'Q: verify first note for second commit' '
1992 echo "$note2_data" >expect &&
1993 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1994 test_cmp expect actual
1997 test_expect_success 'Q: verify first note for third commit' '
1998 echo "$note3_data" >expect &&
1999 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
2000 test_cmp expect actual
2003 test_expect_success 'Q: verify second notes commit' '
2004 cat >expect <<-EOF &&
2005 parent $(git rev-parse --verify refs/notes/foobar~2)
2006 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2007 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2011 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
2012 test_cmp expect actual
2015 test_expect_success 'Q: verify second notes tree' '
2016 cat >expect.unsorted <<-EOF &&
2017 100644 blob $commit1
2018 100644 blob $commit2
2019 100644 blob $commit3
2021 cat expect.unsorted | sort >expect &&
2022 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2023 test_cmp expect actual
2026 test_expect_success 'Q: verify second note for first commit' '
2027 echo "$note1b_data" >expect &&
2028 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
2029 test_cmp expect actual
2032 test_expect_success 'Q: verify first note for second commit' '
2033 echo "$note2_data" >expect &&
2034 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
2035 test_cmp expect actual
2038 test_expect_success 'Q: verify first note for third commit' '
2039 echo "$note3_data" >expect &&
2040 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2041 test_cmp expect actual
2044 test_expect_success 'Q: verify third notes commit' '
2045 cat >expect <<-EOF &&
2046 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2047 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2051 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2052 test_cmp expect actual
2055 test_expect_success 'Q: verify third notes tree' '
2056 cat >expect.unsorted <<-EOF &&
2057 100644 blob $commit1
2059 cat expect.unsorted | sort >expect &&
2060 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2061 test_cmp expect actual
2064 test_expect_success 'Q: verify third note for first commit' '
2065 echo "$note1c_data" >expect &&
2066 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2067 test_cmp expect actual
2070 test_expect_success 'Q: verify fourth notes commit' '
2071 cat >expect <<-EOF &&
2072 parent $(git rev-parse --verify refs/notes/foobar^)
2073 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2074 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2078 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2079 test_cmp expect actual
2082 test_expect_success 'Q: verify fourth notes tree' '
2083 cat >expect.unsorted <<-EOF &&
2084 100644 blob $commit2
2086 cat expect.unsorted | sort >expect &&
2087 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2088 test_cmp expect actual
2091 test_expect_success 'Q: verify second note for second commit' '
2092 echo "$note2b_data" >expect &&
2093 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2094 test_cmp expect actual
2097 test_expect_success 'Q: deny note on empty branch' '
2098 cat >input <<-EOF &&
2101 commit refs/heads/note-Q0
2102 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2104 Note for an empty branch.
2107 N inline refs/heads/Q0
2112 test_must_fail git fast-import <input
2115 ### series R (feature and option)
2118 test_expect_success 'R: abort on unsupported feature' '
2119 cat >input <<-EOF &&
2120 feature no-such-feature-exists
2123 test_must_fail git fast-import <input
2126 test_expect_success 'R: supported feature is accepted' '
2127 cat >input <<-EOF &&
2128 feature date-format=now
2131 git fast-import <input
2134 test_expect_success 'R: abort on receiving feature after data command' '
2135 cat >input <<-EOF &&
2139 feature date-format=now
2142 test_must_fail git fast-import <input
2145 test_expect_success 'R: import-marks features forbidden by default' '
2147 echo "feature import-marks=git.marks" >input &&
2148 test_must_fail git fast-import <input &&
2149 echo "feature import-marks-if-exists=git.marks" >input &&
2150 test_must_fail git fast-import <input
2153 test_expect_success 'R: only one import-marks feature allowed per stream' '
2156 cat >input <<-EOF &&
2157 feature import-marks=git.marks
2158 feature import-marks=git2.marks
2161 test_must_fail git fast-import --allow-unsafe-features <input
2164 test_expect_success 'R: export-marks feature forbidden by default' '
2165 echo "feature export-marks=git.marks" >input &&
2166 test_must_fail git fast-import <input
2169 test_expect_success 'R: export-marks feature results in a marks file being created' '
2170 cat >input <<-EOF &&
2171 feature export-marks=git.marks
2179 git fast-import --allow-unsafe-features <input &&
2183 test_expect_success 'R: export-marks options can be overridden by commandline options' '
2184 cat >input <<-\EOF &&
2185 feature export-marks=feature-sub/git.marks
2192 git fast-import --allow-unsafe-features \
2193 --export-marks=cmdline-sub/other.marks <input &&
2194 grep :1 cmdline-sub/other.marks &&
2195 test_path_is_missing feature-sub
2198 test_expect_success 'R: catch typo in marks file name' '
2199 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2200 echo "feature import-marks=nonexistent.marks" |
2201 test_must_fail git fast-import --allow-unsafe-features
2204 test_expect_success 'R: import and output marks can be the same file' '
2206 blob=$(echo hi | git hash-object --stdin) &&
2207 cat >expect <<-EOF &&
2211 git fast-import --export-marks=io.marks <<-\EOF &&
2218 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2225 test_cmp expect io.marks
2228 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2230 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2239 test_expect_success 'R: --import-marks-if-exists' '
2241 blob=$(echo hi | git hash-object --stdin) &&
2242 echo ":1 $blob" >expect &&
2243 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2250 test_cmp expect io.marks
2253 test_expect_success 'R: feature import-marks-if-exists' '
2256 git fast-import --export-marks=io.marks \
2257 --allow-unsafe-features <<-\EOF &&
2258 feature import-marks-if-exists=not_io.marks
2260 test_must_be_empty io.marks &&
2262 blob=$(echo hi | git hash-object --stdin) &&
2264 echo ":1 $blob" >io.marks &&
2265 echo ":1 $blob" >expect &&
2266 echo ":2 $blob" >>expect &&
2268 git fast-import --export-marks=io.marks \
2269 --allow-unsafe-features <<-\EOF &&
2270 feature import-marks-if-exists=io.marks
2277 test_cmp expect io.marks &&
2279 echo ":3 $blob" >>expect &&
2281 git fast-import --import-marks=io.marks \
2282 --export-marks=io.marks \
2283 --allow-unsafe-features <<-\EOF &&
2284 feature import-marks-if-exists=not_io.marks
2291 test_cmp expect io.marks &&
2293 git fast-import --import-marks-if-exists=not_io.marks \
2294 --export-marks=io.marks \
2295 --allow-unsafe-features <<-\EOF &&
2296 feature import-marks-if-exists=io.marks
2298 test_must_be_empty io.marks
2301 test_expect_success 'R: import to output marks works without any content' '
2302 cat >input <<-EOF &&
2303 feature import-marks=marks.out
2304 feature export-marks=marks.new
2307 git fast-import --allow-unsafe-features <input &&
2308 test_cmp marks.out marks.new
2311 test_expect_success 'R: import marks prefers commandline marks file over the stream' '
2312 cat >input <<-EOF &&
2313 feature import-marks=nonexistent.marks
2314 feature export-marks=marks.new
2317 git fast-import --import-marks=marks.out --allow-unsafe-features <input &&
2318 test_cmp marks.out marks.new
2322 test_expect_success 'R: multiple --import-marks= should be honoured' '
2323 cat >input <<-EOF &&
2324 feature import-marks=nonexistent.marks
2325 feature export-marks=combined.marks
2328 head -n2 marks.out > one.marks &&
2329 tail -n +3 marks.out > two.marks &&
2330 git fast-import --import-marks=one.marks --import-marks=two.marks \
2331 --allow-unsafe-features <input &&
2332 test_cmp marks.out combined.marks
2335 test_expect_success 'R: feature relative-marks should be honoured' '
2336 cat >input <<-EOF &&
2337 feature relative-marks
2338 feature import-marks=relative.in
2339 feature export-marks=relative.out
2342 mkdir -p .git/info/fast-import/ &&
2343 cp marks.new .git/info/fast-import/relative.in &&
2344 git fast-import --allow-unsafe-features <input &&
2345 test_cmp marks.new .git/info/fast-import/relative.out
2348 test_expect_success 'R: feature no-relative-marks should be honoured' '
2349 cat >input <<-EOF &&
2350 feature relative-marks
2351 feature import-marks=relative.in
2352 feature no-relative-marks
2353 feature export-marks=non-relative.out
2356 git fast-import --allow-unsafe-features <input &&
2357 test_cmp marks.new non-relative.out
2360 test_expect_success 'R: feature ls supported' '
2365 test_expect_success 'R: feature cat-blob supported' '
2366 echo "feature cat-blob" |
2370 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2371 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2374 test_expect_success !MINGW 'R: print old blob' '
2375 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2376 cat >expect <<-EOF &&
2381 echo "cat-blob $blob" |
2382 git fast-import --cat-blob-fd=6 6>actual &&
2383 test_cmp expect actual
2386 test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
2387 echo hello >greeting &&
2388 blob=$(git hash-object -w greeting) &&
2389 cat >expect <<-EOF &&
2394 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2397 test_cmp expect actual.3 &&
2398 test_must_be_empty actual.1 &&
2399 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2400 option cat-blob-fd=3
2403 test_must_be_empty actual.3 &&
2404 test_cmp expect actual.1
2407 test_expect_success !MINGW 'R: print mark for new blob' '
2408 echo "effluentish" | git hash-object --stdin >expect &&
2409 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2417 test_cmp expect actual
2420 test_expect_success !MINGW 'R: print new blob' '
2421 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2422 cat >expect <<-EOF &&
2427 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2435 test_cmp expect actual
2438 test_expect_success !MINGW 'R: print new blob by sha1' '
2439 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2440 cat >expect <<-EOF &&
2442 a new blob named by sha1
2445 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2448 a new blob named by sha1
2452 test_cmp expect actual
2455 test_expect_success 'setup: big file' '
2457 echo "the quick brown fox jumps over the lazy dog" >big &&
2460 cat big big big big >bigger &&
2461 cat bigger bigger bigger bigger >big ||
2467 test_expect_success 'R: print two blobs to stdout' '
2468 blob1=$(git hash-object big) &&
2469 blob1_len=$(wc -c <big) &&
2470 blob2=$(echo hello | git hash-object --stdin) &&
2472 echo ${blob1} blob $blob1_len &&
2482 cat <<-\END_PART1 &&
2499 git fast-import >actual &&
2500 test_cmp expect actual
2503 test_expect_success PIPE 'R: copy using cat-file' '
2504 expect_id=$(git hash-object big) &&
2505 expect_len=$(wc -c <big) &&
2506 echo $expect_id blob $expect_len >expect.response &&
2512 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2525 read blob_id type size <&3 &&
2526 echo "$blob_id $type $size" >response &&
2527 test_copy_bytes $size >blob <&3 &&
2531 commit refs/heads/copied
2532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2534 copy big file as file3
2542 git fast-import --cat-blob-fd=3 3>blobs &&
2543 git show copied:file3 >actual &&
2544 test_cmp expect.response response &&
2548 test_expect_success PIPE 'R: print blob mid-commit' '
2550 echo "A blob from _before_ the commit." >expect &&
2559 A blob from _before_ the commit.
2561 commit refs/heads/temporary
2562 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2569 read blob_id type size <&3 &&
2570 test_copy_bytes $size >actual <&3 &&
2575 git fast-import --cat-blob-fd=3 3>blobs &&
2576 test_cmp expect actual
2579 test_expect_success PIPE 'R: print staged blob within commit' '
2581 echo "A blob from _within_ the commit." >expect &&
2587 commit refs/heads/within
2588 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2594 A blob from _within_ the commit.
2599 echo "A blob from _within_ the commit." |
2600 git hash-object --stdin
2602 echo "cat-blob $to_get" &&
2604 read blob_id type size <&3 &&
2605 test_copy_bytes $size >actual <&3 &&
2610 git fast-import --cat-blob-fd=3 3>blobs &&
2611 test_cmp expect actual
2614 test_expect_success 'R: quiet option results in no stats being output' '
2615 cat >input <<-EOF &&
2623 git fast-import 2>output <input &&
2624 test_must_be_empty output
2627 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2628 echo feature done | test_must_fail git fast-import &&
2629 test_must_fail git fast-import --done </dev/null
2632 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2633 git fast-import <<-\EOF &&
2638 git fast-import <<-\EOF
2640 more trailing gibberish
2644 test_expect_success 'R: terminating "done" within commit' '
2645 cat >expect <<-\EOF &&
2647 :000000 100644 OBJID OBJID A hello.c
2648 :000000 100644 OBJID OBJID A hello2.c
2650 git fast-import <<-EOF &&
2651 commit refs/heads/done-ends
2652 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2654 Commit terminated by "done" command
2656 M 100644 inline hello.c
2663 git rev-list done-ends |
2664 git diff-tree -r --stdin --root --always |
2665 sed -e "s/$OID_REGEX/OBJID/g" >actual &&
2666 test_cmp expect actual
2669 test_expect_success 'R: die on unknown option' '
2670 cat >input <<-EOF &&
2671 option git non-existing-option
2674 test_must_fail git fast-import <input
2677 test_expect_success 'R: unknown commandline options are rejected' '\
2678 test_must_fail git fast-import --non-existing-option < /dev/null
2681 test_expect_success 'R: die on invalid option argument' '
2682 echo "option git active-branches=-5" |
2683 test_must_fail git fast-import &&
2684 echo "option git depth=" |
2685 test_must_fail git fast-import &&
2686 test_must_fail git fast-import --depth="5 elephants" </dev/null
2689 test_expect_success 'R: ignore non-git options' '
2690 cat >input <<-EOF &&
2691 option non-existing-vcs non-existing-option
2694 git fast-import <input
2697 test_expect_success 'R: corrupt lines do not mess marks file' '
2699 blob=$(echo hi | git hash-object --stdin) &&
2700 cat >expect <<-EOF &&
2701 :3 0000000000000000000000000000000000000000
2705 cp expect io.marks &&
2706 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2709 test_cmp expect io.marks
2713 ## R: very large blobs
2715 test_expect_success 'R: blob bigger than threshold' '
2716 blobsize=$((2*1024*1024 + 53)) &&
2717 test-tool genrandom bar $blobsize >expect &&
2718 cat >input <<-INPUT_END &&
2719 commit refs/heads/big-file
2720 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2728 cat expect >>input &&
2729 cat >>input <<-INPUT_END &&
2733 cat expect >>input &&
2736 test_create_repo R &&
2737 git --git-dir=R/.git config fastimport.unpackLimit 0 &&
2738 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2741 test_expect_success 'R: verify created pack' '
2744 verify_packs -v > ../verify
2748 test_expect_success 'R: verify written objects' '
2749 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2750 test_cmp_bin expect actual &&
2751 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2752 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2756 test_expect_success 'R: blob appears only once' '
2757 n=$(grep $a verify | wc -l) &&
2765 # Make sure missing spaces and EOLs after mark references
2774 # commit marks: 301, 302, 303, 304
2775 # blob marks: 403, 404, resp.
2778 # The error message when a space is missing not at the
2779 # end of the line is:
2781 # Missing space after ..
2783 # or when extra characters come after the mark at the end
2788 # or when the dataref is neither "inline " or a known SHA1,
2790 # Invalid dataref ..
2792 test_expect_success 'S: initialize for S tests' '
2795 cat >input <<-INPUT_END &&
2798 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2802 M 100644 inline hello.c
2809 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2814 M 100644 inline hello.c
2832 git fast-import --export-marks=marks <input
2836 # filemodify, three datarefs
2838 test_expect_success 'S: filemodify with garbage after mark must fail' '
2839 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2841 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2845 M 100644 :403x hello.c
2847 test_i18ngrep "space after mark" err
2850 # inline is misspelled; fast-import thinks it is some unknown dataref
2851 test_expect_success 'S: filemodify with garbage after inline must fail' '
2852 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2854 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2858 M 100644 inlineX hello.c
2863 test_i18ngrep "nvalid dataref" err
2866 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2867 sha1=$(grep :403 marks | cut -d\ -f2) &&
2868 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2870 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2874 M 100644 ${sha1}x hello.c
2876 test_i18ngrep "space after SHA1" err
2880 # notemodify, three ways to say dataref
2882 test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
2883 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2885 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2887 commit S note dataref markref
2891 test_i18ngrep "space after mark" err
2894 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2895 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2897 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2899 commit S note dataref inline
2906 test_i18ngrep "nvalid dataref" err
2909 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2910 sha1=$(grep :202 marks | cut -d\ -f2) &&
2911 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2913 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2915 commit S note dataref sha1
2919 test_i18ngrep "space after SHA1" err
2923 # notemodify, mark in commit-ish
2925 test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
2926 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2927 commit refs/heads/Snotes
2928 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2930 commit S note commit-ish
2934 test_i18ngrep "after mark" err
2940 test_expect_success 'S: from with garbage after mark must fail' '
2942 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2943 commit refs/heads/S2
2945 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2950 M 100644 :403 hello.c
2954 # go create the commit, need it for merge test
2955 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2956 commit refs/heads/S2
2958 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2963 M 100644 :403 hello.c
2966 # now evaluate the error
2967 test_i18ngrep "after mark" err
2974 test_expect_success 'S: merge with garbage after mark must fail' '
2975 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2978 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2984 M 100644 :403 hello.c
2986 test_i18ngrep "after mark" err
2992 test_expect_success 'S: tag with garbage after mark must fail' '
2993 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2996 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3001 test_i18ngrep "after mark" err
3007 test_expect_success 'S: cat-blob with garbage after mark must fail' '
3008 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
3011 test_i18ngrep "after mark" err
3017 test_expect_success 'S: ls with garbage after mark must fail' '
3018 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
3021 test_i18ngrep "space after mark" err
3024 test_expect_success 'S: ls with garbage after sha1 must fail' '
3025 sha1=$(grep :302 marks | cut -d\ -f2) &&
3026 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
3029 test_i18ngrep "space after tree-ish" err
3035 # Setup is carried over from series S.
3037 test_expect_success 'T: ls root tree' '
3038 sed -e "s/Z\$//" >expect <<-EOF &&
3039 040000 tree $(git rev-parse S^{tree}) Z
3041 sha1=$(git rev-parse --verify S) &&
3042 git fast-import --import-marks=marks <<-EOF >actual &&
3045 test_cmp expect actual
3048 test_expect_success 'T: delete branch' '
3049 git branch to-delete &&
3050 git fast-import <<-EOF &&
3051 reset refs/heads/to-delete
3052 from 0000000000000000000000000000000000000000
3054 test_must_fail git rev-parse --verify refs/heads/to-delete
3057 test_expect_success 'T: empty reset doesnt delete branch' '
3058 git branch not-to-delete &&
3059 git fast-import <<-EOF &&
3060 reset refs/heads/not-to-delete
3063 git rev-parse --verify refs/heads/not-to-delete
3067 ### series U (filedelete)
3070 test_expect_success 'U: initialize for U tests' '
3071 cat >input <<-INPUT_END &&
3073 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3077 M 100644 inline hello.c
3081 M 100644 inline good/night.txt
3085 M 100644 inline good/bye.txt
3092 git fast-import <input
3095 test_expect_success 'U: filedelete file succeeds' '
3096 cat >input <<-INPUT_END &&
3098 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3100 delete good/night.txt
3107 git fast-import <input
3110 test_expect_success 'U: validate file delete result' '
3111 cat >expect <<-EOF &&
3112 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3115 git diff-tree -M -r U^1 U >actual &&
3117 compare_diff_raw expect actual
3120 test_expect_success 'U: filedelete directory succeeds' '
3121 cat >input <<-INPUT_END &&
3123 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3132 git fast-import <input
3135 test_expect_success 'U: validate directory delete result' '
3136 cat >expect <<-EOF &&
3137 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3140 git diff-tree -M -r U^1 U >actual &&
3142 compare_diff_raw expect actual
3145 test_expect_success 'U: filedelete root succeeds' '
3146 cat >input <<-INPUT_END &&
3148 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3157 git fast-import <input
3160 test_expect_success 'U: validate root delete result' '
3161 cat >expect <<-EOF &&
3162 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3165 git diff-tree -M -r U^1 U >actual &&
3167 compare_diff_raw expect actual
3171 ### series V (checkpoint)
3174 # The commands in input_file should not produce any output on the file
3175 # descriptor set with --cat-blob-fd (or stdout if unspecified).
3177 # To make sure you're observing the side effects of checkpoint *before*
3178 # fast-import terminates (and thus writes out its state), check that the
3179 # fast-import process is still running using background_import_still_running
3180 # *after* evaluating the test conditions.
3181 background_import_then_checkpoint () {
3194 git fast-import $options <&8 >&9 &
3197 echo >&2 "background fast-import terminated too early with exit code $?"
3198 # Un-block the read loop in the main shell process.
3203 # We don't mind if fast-import has already died by the time the test
3205 test_when_finished "
3206 exec 8>&-; exec 9>&-;
3207 kill $sh_pid && wait $sh_pid
3208 kill $fi_pid && wait $fi_pid
3211 # Start in the background to ensure we adhere strictly to (blocking)
3212 # pipes writing sequence. We want to assume that the write below could
3213 # block, e.g. if fast-import blocks writing its own output to &9
3214 # because there is no reader on &9 yet.
3218 echo "progress checkpoint"
3221 error=1 ;# assume the worst
3222 while read output <&9
3224 if test "$output" = "progress checkpoint"
3228 elif test "$output" = "UNEXPECTED"
3232 # otherwise ignore cruft
3233 echo >&2 "cruft: $output"
3236 if test $error -eq 1
3242 background_import_still_running () {
3243 if ! kill -0 "$fi_pid"
3245 echo >&2 "background fast-import terminated too early"
3250 test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' '
3251 cat >input <<-INPUT_END &&
3257 background_import_then_checkpoint "" input &&
3258 background_import_still_running
3261 test_expect_success PIPE 'V: checkpoint updates refs after reset' '
3262 cat >input <<-\INPUT_END &&
3268 background_import_then_checkpoint "" input &&
3269 test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" &&
3270 background_import_still_running
3273 test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' '
3274 cat >input <<-INPUT_END &&
3277 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3283 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3285 echo ":1 $(git rev-parse --verify V)" >marks.expected &&
3287 test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" &&
3288 test_cmp marks.expected marks.actual &&
3289 background_import_still_running
3292 # Re-create the exact same commit, but on a different branch: no new object is
3293 # created in the database, but the refs and marks still need to be updated.
3294 test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' '
3295 cat >input <<-INPUT_END &&
3296 commit refs/heads/V2
3298 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3304 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3306 echo ":2 $(git rev-parse --verify V2)" >marks.expected &&
3308 test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" &&
3309 test_cmp marks.expected marks.actual &&
3310 background_import_still_running
3313 test_expect_success PIPE 'V: checkpoint updates tags after tag' '
3314 cat >input <<-INPUT_END &&
3317 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3322 background_import_then_checkpoint "" input &&
3323 git show-ref -d Vtag &&
3324 background_import_still_running
3328 ### series W (get-mark and empty orphan commits)
3331 cat >>W-input <<-W_INPUT_END
3332 commit refs/heads/W-branch
3334 author Full Name <user@company.tld> 1000000000 +0100
3335 committer Full Name <user@company.tld> 1000000000 +0100
3337 Intentionally empty commit
3341 test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
3342 sed -e s/LFs// W-input | tr L "\n" | git fast-import
3345 test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
3346 sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
3349 test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
3350 # Technically, this should fail as it has too many linefeeds
3351 # according to the grammar in fast-import.txt. But, for whatever
3352 # reason, it works. Since using the correct number of newlines
3353 # does not work with older (pre-2.22) versions of git, allow apps
3354 # that used this second-newline workaround to keep working by
3355 # checking it with this test...
3356 sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import
3359 test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
3360 # ...but do NOT allow more empty lines than that (see previous test).
3361 sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import
3365 ### series X (other new features)
3368 test_expect_success 'X: handling encoding' '
3370 cat >input <<-INPUT_END &&
3371 commit refs/heads/encoding
3372 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3377 printf "Pi: \360\nCOMMIT\n" >>input &&
3379 git fast-import <input &&
3380 git cat-file -p encoding | grep $(printf "\360") &&
3381 git log -1 --format=%B encoding | grep $(printf "\317\200")