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
10 # Print $1 bytes from stdin to stdout.
12 # This could be written as "head -c $1", but IRIX "head" does not
13 # support the -c option.
19 my $nread = sysread(STDIN, $s, $len);
20 die "cannot read: $!" unless defined($nread);
28 for p in .git/objects/pack/*.pack
30 git verify-pack "$@" "$p" || return
44 file5_data='an inline file.
45 we should see it later.'
58 test_expect_success 'empty stream succeeds' '
59 git fast-import </dev/null
62 cat >input <<INPUT_END
79 commit refs/heads/master
81 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
93 An annotated tag without a tagger
99 An annotated tag that annotates a blob.
103 test_expect_success \
104 'A: create pack from stdin' \
105 'git fast-import --export-marks=marks.out <input &&
106 git whatchanged master'
108 test_expect_success 'A: verify pack' '
113 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
114 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
118 test_expect_success \
120 'git cat-file commit master | sed 1d >actual &&
121 test_cmp expect actual'
128 test_expect_success \
130 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
131 test_cmp expect actual'
133 echo "$file2_data" >expect
134 test_expect_success \
136 'git cat-file blob master:file2 >actual && test_cmp expect actual'
138 echo "$file3_data" >expect
139 test_expect_success \
141 'git cat-file blob master:file3 >actual && test_cmp expect actual'
143 printf "$file4_data" >expect
144 test_expect_success \
146 'git cat-file blob master:file4 >actual && test_cmp expect actual'
149 object $(git rev-parse refs/heads/master)
153 An annotated tag without a tagger
155 test_expect_success 'A: verify tag/series-A' '
156 git cat-file tag tags/series-A >actual &&
157 test_cmp expect actual
161 object $(git rev-parse refs/heads/master:file3)
165 An annotated tag that annotates a blob.
167 test_expect_success 'A: verify tag/series-A-blob' '
168 git cat-file tag tags/series-A-blob >actual &&
169 test_cmp expect actual
173 :2 `git rev-parse --verify master:file2`
174 :3 `git rev-parse --verify master:file3`
175 :4 `git rev-parse --verify master:file4`
176 :5 `git rev-parse --verify master^0`
178 test_expect_success \
179 'A: verify marks output' \
180 'test_cmp expect marks.out'
182 test_expect_success \
183 'A: verify marks import' \
185 --import-marks=marks.out \
186 --export-marks=marks.new \
188 test_cmp expect marks.new'
191 new_blob=$(echo testing | git hash-object --stdin)
192 cat >input <<INPUT_END
194 from $(git rev-parse refs/heads/master:file3)
205 commit refs/heads/new_blob
209 #pretend we got sha1 from fast-import
220 object $(git rev-parse refs/heads/master:file3)
232 test_expect_success \
233 'A: tag blob by sha1' \
234 'git fast-import <input &&
235 git cat-file tag tags/series-A-blob-2 >actual &&
236 git cat-file tag tags/series-A-blob-3 >>actual &&
237 test_cmp expect actual'
240 cat >input <<INPUT_END
241 commit refs/heads/verify--import-marks
242 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
248 M 755 :2 copy-of-file2
251 test_expect_success \
252 'A: verify marks import does not crash' \
253 'git fast-import --import-marks=marks.out <input &&
254 git whatchanged verify--import-marks'
256 test_expect_success 'A: verify pack' '
261 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
263 git diff-tree -M -r master verify--import-marks >actual
264 test_expect_success \
266 'compare_diff_raw expect actual &&
267 test `git rev-parse --verify master:file2` \
268 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
271 mt=$(git hash-object --stdin < /dev/null)
276 cat >input.commit <<EOF
277 commit refs/heads/verify--dump-marks
278 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
280 test the sparse array dumping routines with exponentially growing marks
288 while test "$i" -lt 27; do
289 cat >>input.blob <<EOF
300 echo "M 100644 :$l l$i" >>input.commit
301 echo "M 100644 :$m m$i" >>input.commit
302 echo "M 100644 :$n n$i" >>input.commit
304 echo ":$l $mt" >>marks.exp
305 echo ":$m $mt" >>marks.exp
306 echo ":$n $mt" >>marks.exp
308 printf "100644 blob $mt\tl$i\n" >>tree.exp
309 printf "100644 blob $mt\tm$i\n" >>tree.exp
310 printf "100644 blob $mt\tn$i\n" >>tree.exp
319 sort tree.exp > tree.exp_s
321 test_expect_success 'A: export marks with large values' '
322 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
323 git ls-tree refs/heads/verify--dump-marks >tree.out &&
324 test_cmp tree.exp_s tree.out &&
325 test_cmp marks.exp marks.large'
332 cat >input <<INPUT_END
333 commit refs/heads/branch
335 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
340 from refs/heads/master
341 M 755 0000000000000000000000000000000000000001 zero1
344 test_expect_success 'B: fail on invalid blob sha1' '
345 test_must_fail git fast-import <input
347 rm -f .git/objects/pack_* .git/objects/index_*
349 cat >input <<INPUT_END
350 commit .badbranchname
351 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
356 from refs/heads/master
359 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
360 test_must_fail git fast-import <input
362 rm -f .git/objects/pack_* .git/objects/index_*
364 cat >input <<INPUT_END
365 commit bad[branch]name
366 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
371 from refs/heads/master
374 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
375 test_must_fail git fast-import <input
377 rm -f .git/objects/pack_* .git/objects/index_*
379 cat >input <<INPUT_END
381 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
386 from refs/heads/master
389 test_expect_success \
390 'B: accept branch name "TEMP_TAG"' \
391 'git fast-import <input &&
392 test -f .git/TEMP_TAG &&
393 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
396 git gc 2>/dev/null >/dev/null
397 git prune 2>/dev/null >/dev/null
399 cat >input <<INPUT_END
400 commit refs/heads/empty-committer-1
401 committer <> $GIT_COMMITTER_DATE
406 test_expect_success 'B: accept empty committer' '
407 git fast-import <input &&
412 git update-ref -d refs/heads/empty-committer-1 || true
414 git gc 2>/dev/null >/dev/null
415 git prune 2>/dev/null >/dev/null
417 cat >input <<INPUT_END
418 commit refs/heads/empty-committer-2
419 committer <a@b.com> $GIT_COMMITTER_DATE
424 test_expect_success 'B: accept and fixup committer with no name' '
425 git fast-import <input &&
430 git update-ref -d refs/heads/empty-committer-2 || true
432 git gc 2>/dev/null >/dev/null
433 git prune 2>/dev/null >/dev/null
435 cat >input <<INPUT_END
436 commit refs/heads/invalid-committer
437 committer Name email> $GIT_COMMITTER_DATE
442 test_expect_success 'B: fail on invalid committer (1)' '
443 test_must_fail git fast-import <input
445 git update-ref -d refs/heads/invalid-committer || true
447 cat >input <<INPUT_END
448 commit refs/heads/invalid-committer
449 committer Name <e<mail> $GIT_COMMITTER_DATE
454 test_expect_success 'B: fail on invalid committer (2)' '
455 test_must_fail git fast-import <input
457 git update-ref -d refs/heads/invalid-committer || true
459 cat >input <<INPUT_END
460 commit refs/heads/invalid-committer
461 committer Name <email>> $GIT_COMMITTER_DATE
466 test_expect_success 'B: fail on invalid committer (3)' '
467 test_must_fail git fast-import <input
469 git update-ref -d refs/heads/invalid-committer || true
471 cat >input <<INPUT_END
472 commit refs/heads/invalid-committer
473 committer Name <email $GIT_COMMITTER_DATE
478 test_expect_success 'B: fail on invalid committer (4)' '
479 test_must_fail git fast-import <input
481 git update-ref -d refs/heads/invalid-committer || true
483 cat >input <<INPUT_END
484 commit refs/heads/invalid-committer
485 committer Name<email> $GIT_COMMITTER_DATE
490 test_expect_success 'B: fail on invalid committer (5)' '
491 test_must_fail git fast-import <input
493 git update-ref -d refs/heads/invalid-committer || true
499 newf=`echo hi newf | git hash-object -w --stdin`
500 oldf=`git rev-parse --verify master:file2`
502 cat >input <<INPUT_END
503 commit refs/heads/branch
504 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
509 from refs/heads/master
510 M 644 $oldf file2/oldf
511 M 755 $newf file2/newf
515 test_expect_success \
516 'C: incremental import create pack from stdin' \
517 'git fast-import <input &&
518 git whatchanged branch'
520 test_expect_success 'C: verify pack' '
524 test_expect_success \
525 'C: validate reuse existing blob' \
526 'test $newf = `git rev-parse --verify branch:file2/newf` &&
527 test $oldf = `git rev-parse --verify branch:file2/oldf`'
530 parent `git rev-parse --verify master^0`
531 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
536 test_expect_success \
538 'git cat-file commit branch | sed 1d >actual &&
539 test_cmp expect actual'
542 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
543 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
544 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
546 git diff-tree -M -r master branch >actual
547 test_expect_success \
548 'C: validate rename result' \
549 'compare_diff_raw expect actual'
556 cat >input <<INPUT_END
557 commit refs/heads/branch
558 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
563 from refs/heads/branch^0
564 M 644 inline newdir/interesting
569 M 755 inline newdir/exec.sh
575 test_expect_success \
576 'D: inline data in commit' \
577 'git fast-import <input &&
578 git whatchanged branch'
580 test_expect_success 'D: verify pack' '
585 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
586 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
588 git diff-tree -M -r branch^ branch >actual
589 test_expect_success \
590 'D: validate new files added' \
591 'compare_diff_raw expect actual'
593 echo "$file5_data" >expect
594 test_expect_success \
596 'git cat-file blob branch:newdir/interesting >actual &&
597 test_cmp expect actual'
599 echo "$file6_data" >expect
600 test_expect_success \
602 'git cat-file blob branch:newdir/exec.sh >actual &&
603 test_cmp expect actual'
609 cat >input <<INPUT_END
610 commit refs/heads/branch
611 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
617 from refs/heads/branch^0
620 test_expect_success 'E: rfc2822 date, --date-format=raw' '
621 test_must_fail git fast-import --date-format=raw <input
623 test_expect_success \
624 'E: rfc2822 date, --date-format=rfc2822' \
625 'git fast-import --date-format=rfc2822 <input'
627 test_expect_success 'E: verify pack' '
632 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
633 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
637 test_expect_success \
639 'git cat-file commit branch | sed 1,2d >actual &&
640 test_cmp expect actual'
646 old_branch=`git rev-parse --verify branch^0`
648 cat >input <<INPUT_END
649 commit refs/heads/branch
650 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
652 losing things already?
655 from refs/heads/branch~1
657 reset refs/heads/other
658 from refs/heads/branch
661 test_expect_success \
662 'F: non-fast-forward update skips' \
663 'if git fast-import <input
665 echo BAD gfi did not fail
668 if test $old_branch = `git rev-parse --verify branch^0`
670 : branch unaffected and failure returned
673 echo BAD gfi changed branch $old_branch
679 test_expect_success 'F: verify pack' '
684 tree `git rev-parse branch~1^{tree}`
685 parent `git rev-parse branch~1`
686 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
687 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
689 losing things already?
691 test_expect_success \
692 'F: verify other commit' \
693 'git cat-file commit other >actual &&
694 test_cmp expect actual'
700 old_branch=`git rev-parse --verify branch^0`
702 cat >input <<INPUT_END
703 commit refs/heads/branch
704 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
706 losing things already?
709 from refs/heads/branch~1
712 test_expect_success \
713 'G: non-fast-forward update forced' \
714 'git fast-import --force <input'
716 test_expect_success 'G: verify pack' '
720 test_expect_success \
721 'G: branch changed, but logged' \
722 'test $old_branch != `git rev-parse --verify branch^0` &&
723 test $old_branch = `git rev-parse --verify branch@{1}`'
730 cat >input <<INPUT_END
732 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
737 from refs/heads/branch^0
738 M 644 inline i-will-die
740 this file will never exist.
744 M 644 inline h/e/l/lo
750 test_expect_success \
751 'H: deletall, add 1' \
752 'git fast-import <input &&
755 test_expect_success 'H: verify pack' '
760 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
761 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
762 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
763 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
764 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
766 git diff-tree -M -r H^ H >actual
767 test_expect_success \
768 'H: validate old files removed, new files added' \
769 'compare_diff_raw expect actual'
771 echo "$file5_data" >expect
772 test_expect_success \
774 'git cat-file blob H:h/e/l/lo >actual &&
775 test_cmp expect actual'
781 cat >input <<INPUT_END
782 commit refs/heads/export-boundary
783 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
785 we have a border. its only 40 characters wide.
788 from refs/heads/branch
791 test_expect_success \
792 'I: export-pack-edges' \
793 'git fast-import --export-pack-edges=edges.list <input'
796 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
798 test_expect_success \
799 'I: verify edge list' \
800 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
801 test_cmp expect actual'
807 cat >input <<INPUT_END
809 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
814 from refs/heads/branch
819 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
825 test_expect_success \
826 'J: reset existing branch creates empty commit' \
827 'git fast-import <input'
828 test_expect_success \
829 'J: branch has 1 commit, empty tree' \
830 'test 1 = `git rev-list J | wc -l` &&
831 test 0 = `git ls-tree J | wc -l`'
833 cat >input <<INPUT_END
839 Tag branch that was reset.
842 test_expect_success \
843 'J: tag must fail on empty branch' \
844 'test_must_fail git fast-import <input'
849 cat >input <<INPUT_END
851 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
856 from refs/heads/branch
859 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
864 from refs/heads/branch^1
867 test_expect_success \
868 'K: reinit branch with from' \
869 'git fast-import <input'
870 test_expect_success \
871 'K: verify K^1 = branch^1' \
872 'test `git rev-parse --verify branch^1` \
873 = `git rev-parse --verify K^1`'
879 cat >input <<INPUT_END
893 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
903 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
913 cat >expect <<EXPECT_END
914 :100644 100644 4268632... 55d3a52... M b.
915 :040000 040000 0ae5cac... 443c768... M b
916 :100644 100644 4268632... 55d3a52... M ba
919 test_expect_success \
920 'L: verify internal tree sorting' \
921 'git fast-import <input &&
922 git diff-tree --abbrev --raw L^ L >output &&
923 test_cmp expect output'
925 cat >input <<INPUT_END
933 committer C O Mitter <committer@example.com> 1112912473 -0700
942 committer C O Mitter <committer@example.com> 1112912473 -0700
956 test_expect_success \
957 'L: nested tree copy does not corrupt deltas' \
958 'git fast-import <input &&
959 git ls-tree L2 g/b/ >tmp &&
960 cat tmp | cut -f 2 >actual &&
961 test_cmp expect actual &&
962 git fsck `git rev-parse L2`'
964 git update-ref -d refs/heads/L2
971 cat >input <<INPUT_END
973 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
978 from refs/heads/branch^0
979 R file2/newf file2/n.e.w.f
984 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
986 test_expect_success \
987 'M: rename file in same subdirectory' \
988 'git fast-import <input &&
989 git diff-tree -M -r M1^ M1 >actual &&
990 compare_diff_raw expect actual'
992 cat >input <<INPUT_END
994 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
999 from refs/heads/branch^0
1000 R file2/newf i/am/new/to/you
1005 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
1007 test_expect_success \
1008 'M: rename file to new subdirectory' \
1009 'git fast-import <input &&
1010 git diff-tree -M -r M2^ M2 >actual &&
1011 compare_diff_raw expect actual'
1013 cat >input <<INPUT_END
1014 commit refs/heads/M3
1015 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1020 from refs/heads/M2^0
1026 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1028 test_expect_success \
1029 'M: rename subdirectory to new subdirectory' \
1030 'git fast-import <input &&
1031 git diff-tree -M -r M3^ M3 >actual &&
1032 compare_diff_raw expect actual'
1039 cat >input <<INPUT_END
1040 commit refs/heads/N1
1041 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1046 from refs/heads/branch^0
1047 C file2/newf file2/n.e.w.f
1052 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1054 test_expect_success \
1055 'N: copy file in same subdirectory' \
1056 'git fast-import <input &&
1057 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1058 compare_diff_raw expect actual'
1060 cat >input <<INPUT_END
1061 commit refs/heads/N2
1062 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1064 clean directory copy
1067 from refs/heads/branch^0
1070 commit refs/heads/N2
1071 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1073 modify directory copy
1076 M 644 inline file3/file5
1084 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1085 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1086 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1088 test_expect_success \
1089 'N: copy then modify subdirectory' \
1090 'git fast-import <input &&
1091 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1092 compare_diff_raw expect actual'
1094 cat >input <<INPUT_END
1095 commit refs/heads/N3
1096 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1098 dirty directory copy
1101 from refs/heads/branch^0
1102 M 644 inline file2/file5
1112 test_expect_success \
1113 'N: copy dirty subdirectory' \
1114 'git fast-import <input &&
1115 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
1117 test_expect_success \
1118 'N: copy directory by id' \
1119 'cat >expect <<-\EOF &&
1120 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1121 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1123 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1124 cat >input <<-INPUT_END &&
1125 commit refs/heads/N4
1126 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1131 from refs/heads/branch^0
1132 M 040000 $subdir file3
1134 git fast-import <input &&
1135 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1136 compare_diff_raw expect actual'
1138 test_expect_success PIPE 'N: read and copy directory' '
1140 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1141 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1143 git update-ref -d refs/heads/N4 &&
1149 commit refs/heads/N4
1150 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1152 copy by tree hash, part 2
1155 from refs/heads/branch^0
1158 read mode type tree filename &&
1159 echo "M 040000 $tree file3"
1161 git fast-import --cat-blob-fd=3 3>backflow &&
1162 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1163 compare_diff_raw expect actual
1166 test_expect_success PIPE 'N: empty directory reads as missing' '
1167 cat <<-\EOF >expect &&
1169 :000000 100644 OBJNAME OBJNAME A unrelated
1171 echo "missing src" >expect.response &&
1172 git update-ref -d refs/heads/read-empty &&
1178 commit refs/heads/read-empty
1179 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1181 read "empty" (missing) directory
1184 M 100644 inline src/greeting
1188 C src/greeting dst1/non-greeting
1189 C src/greeting unrelated
1190 # leave behind "empty" src directory
1195 printf "%s\n" "$line" >response &&
1201 git fast-import --cat-blob-fd=3 3>backflow &&
1202 test_cmp expect.response response &&
1203 git rev-list read-empty |
1204 git diff-tree -r --root --stdin |
1205 sed "s/$_x40/OBJNAME/g" >actual &&
1206 test_cmp expect actual
1209 test_expect_success \
1210 'N: copy root directory by tree hash' \
1211 'cat >expect <<-\EOF &&
1212 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1213 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1215 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1216 cat >input <<-INPUT_END &&
1217 commit refs/heads/N6
1218 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1220 copy root directory by tree hash
1223 from refs/heads/branch^0
1226 git fast-import <input &&
1227 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1228 compare_diff_raw expect actual'
1230 test_expect_success \
1231 'N: delete directory by copying' \
1232 'cat >expect <<-\EOF &&
1234 :100644 000000 OBJID OBJID D foo/bar/qux
1236 :000000 100644 OBJID OBJID A foo/bar/baz
1237 :000000 100644 OBJID OBJID A foo/bar/qux
1239 empty_tree=$(git mktree </dev/null) &&
1240 cat >input <<-INPUT_END &&
1241 commit refs/heads/N-delete
1242 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1244 collect data to be deleted
1248 M 100644 inline foo/bar/baz
1252 C "foo/bar/baz" "foo/bar/qux"
1253 C "foo/bar/baz" "foo/bar/quux/1"
1254 C "foo/bar/baz" "foo/bar/quuux"
1255 M 040000 $empty_tree foo/bar/quux
1256 M 040000 $empty_tree foo/bar/quuux
1258 commit refs/heads/N-delete
1259 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1264 M 040000 $empty_tree foo/bar/qux
1266 git fast-import <input &&
1267 git rev-list N-delete |
1268 git diff-tree -r --stdin --root --always |
1269 sed -e "s/$_x40/OBJID/g" >actual &&
1270 test_cmp expect actual'
1272 test_expect_success \
1273 'N: modify copied tree' \
1274 'cat >expect <<-\EOF &&
1275 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1276 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1277 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1279 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1280 cat >input <<-INPUT_END &&
1281 commit refs/heads/N5
1282 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1287 from refs/heads/branch^0
1288 M 040000 $subdir file3
1290 commit refs/heads/N5
1291 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1293 modify directory copy
1296 M 644 inline file3/file5
1301 git fast-import <input &&
1302 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1303 compare_diff_raw expect actual'
1305 test_expect_success \
1306 'N: reject foo/ syntax' \
1307 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1308 test_must_fail git fast-import <<-INPUT_END
1309 commit refs/heads/N5B
1310 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1312 copy with invalid syntax
1315 from refs/heads/branch^0
1316 M 040000 $subdir file3/
1319 test_expect_success \
1320 'N: reject foo/ syntax in copy source' \
1321 'test_must_fail git fast-import <<-INPUT_END
1322 commit refs/heads/N5C
1323 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1325 copy with invalid syntax
1328 from refs/heads/branch^0
1332 test_expect_success \
1333 'N: reject foo/ syntax in rename source' \
1334 'test_must_fail git fast-import <<-INPUT_END
1335 commit refs/heads/N5D
1336 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1338 rename with invalid syntax
1341 from refs/heads/branch^0
1345 test_expect_success \
1346 'N: reject foo/ syntax in ls argument' \
1347 'test_must_fail git fast-import <<-INPUT_END
1348 commit refs/heads/N5E
1349 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1351 copy with invalid syntax
1354 from refs/heads/branch^0
1358 test_expect_success \
1359 'N: copy to root by id and modify' \
1360 'echo "hello, world" >expect.foo &&
1361 echo hello >expect.bar &&
1362 git fast-import <<-SETUP_END &&
1363 commit refs/heads/N7
1364 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1370 M 644 inline foo/bar
1376 tree=$(git rev-parse --verify N7:) &&
1377 git fast-import <<-INPUT_END &&
1378 commit refs/heads/N8
1379 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1381 copy to root by id and modify
1385 M 644 inline foo/foo
1390 git show N8:foo/foo >actual.foo &&
1391 git show N8:foo/bar >actual.bar &&
1392 test_cmp expect.foo actual.foo &&
1393 test_cmp expect.bar actual.bar'
1395 test_expect_success \
1396 'N: extract subtree' \
1397 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1398 cat >input <<-INPUT_END &&
1399 commit refs/heads/N9
1400 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1402 extract subtree branch:newdir
1408 git fast-import <input &&
1409 git diff --exit-code branch:newdir N9'
1411 test_expect_success \
1412 'N: modify subtree, extract it, and modify again' \
1413 'echo hello >expect.baz &&
1414 echo hello, world >expect.qux &&
1415 git fast-import <<-SETUP_END &&
1416 commit refs/heads/N10
1417 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1423 M 644 inline foo/bar/baz
1429 tree=$(git rev-parse --verify N10:) &&
1430 git fast-import <<-INPUT_END &&
1431 commit refs/heads/N11
1432 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1434 copy to root by id and modify
1438 M 100644 inline foo/bar/qux
1443 C "bar/qux" "bar/quux"
1445 git show N11:bar/baz >actual.baz &&
1446 git show N11:bar/qux >actual.qux &&
1447 git show N11:bar/quux >actual.quux &&
1448 test_cmp expect.baz actual.baz &&
1449 test_cmp expect.qux actual.qux &&
1450 test_cmp expect.qux actual.quux'
1456 cat >input <<INPUT_END
1458 commit refs/heads/O1
1459 # -- ignore all of this text
1460 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1461 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1463 dirty directory copy
1466 # don't forget the import blank line!
1468 # yes, we started from our usual base of branch^0.
1470 from refs/heads/branch^0
1471 # and we need to reuse file2/file5 from N3 above.
1472 M 644 inline file2/file5
1473 # otherwise the tree will be different
1478 # don't forget to copy file2 to file3
1481 # or to delete file5 from file2.
1487 test_expect_success \
1488 'O: comments are all skipped' \
1489 'git fast-import <input &&
1490 test `git rev-parse N3` = `git rev-parse O1`'
1492 cat >input <<INPUT_END
1493 commit refs/heads/O2
1494 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1496 dirty directory copy
1498 from refs/heads/branch^0
1499 M 644 inline file2/file5
1508 test_expect_success \
1509 'O: blank lines not necessary after data commands' \
1510 'git fast-import <input &&
1511 test `git rev-parse N3` = `git rev-parse O2`'
1513 test_expect_success \
1514 'O: repack before next test' \
1517 cat >input <<INPUT_END
1518 commit refs/heads/O3
1519 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1523 commit refs/heads/O3
1524 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1529 commit refs/heads/O3
1531 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1536 commit refs/heads/O3
1537 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1541 reset refs/tags/O3-2nd
1543 reset refs/tags/O3-3rd
1547 cat >expect <<INPUT_END
1553 test_expect_success \
1554 'O: blank lines not necessary after other commands' \
1555 'git fast-import <input &&
1556 test 8 = `find .git/objects/pack -type f | wc -l` &&
1557 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1558 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1559 test_cmp expect actual'
1561 cat >input <<INPUT_END
1562 commit refs/heads/O4
1563 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1567 commit refs/heads/O4
1568 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1572 progress Two commits down, 2 to go!
1573 commit refs/heads/O4
1574 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1578 progress Three commits down, 1 to go!
1579 commit refs/heads/O4
1580 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1586 test_expect_success \
1587 'O: progress outputs as requested by input' \
1588 'git fast-import <input >actual &&
1589 grep "progress " <input >expect &&
1590 test_cmp expect actual'
1593 ### series P (gitlinks)
1596 cat >input <<INPUT_END
1602 reset refs/heads/sub
1603 commit refs/heads/sub
1605 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1618 commit refs/heads/subuse1
1620 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1623 from refs/heads/master
1624 M 100644 :3 .gitmodules
1633 commit refs/heads/sub
1635 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1641 commit refs/heads/subuse1
1643 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1651 test_expect_success \
1652 'P: superproject & submodule mix' \
1653 'git fast-import <input &&
1654 git checkout subuse1 &&
1655 rm -rf sub && mkdir sub && (cd sub &&
1657 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1658 git checkout master) &&
1659 git submodule init &&
1660 git submodule update'
1662 SUBLAST=$(git rev-parse --verify sub)
1663 SUBPREV=$(git rev-parse --verify sub^)
1665 cat >input <<INPUT_END
1674 commit refs/heads/subuse2
1676 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1679 from refs/heads/master
1680 M 100644 :1 .gitmodules
1681 M 160000 $SUBPREV sub
1683 commit refs/heads/subuse2
1685 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1689 M 160000 $SUBLAST sub
1693 test_expect_success \
1694 'P: verbatim SHA gitlinks' \
1695 'git branch -D sub &&
1696 git gc && git prune &&
1697 git fast-import <input &&
1698 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1701 cat >input <<INPUT_END
1702 commit refs/heads/subuse3
1704 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1709 from refs/heads/subuse2
1717 test_expect_success 'P: fail on inline gitlink' '
1718 test_must_fail git fast-import <input'
1721 cat >input <<INPUT_END
1728 commit refs/heads/subuse3
1730 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1735 from refs/heads/subuse2
1740 test_expect_success 'P: fail on blob mark in gitlink' '
1741 test_must_fail git fast-import <input'
1744 ### series Q (notes)
1747 note1_data="The first note for the first commit"
1748 note2_data="The first note for the second commit"
1749 note3_data="The first note for the third commit"
1750 note1b_data="The second note for the first commit"
1751 note1c_data="The third note for the first commit"
1752 note2b_data="The second note for the second commit"
1755 cat >input <<INPUT_END
1762 commit refs/heads/notes-test
1764 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1775 commit refs/heads/notes-test
1777 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1784 commit refs/heads/notes-test
1786 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1813 commit refs/notes/foobar
1815 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1827 commit refs/notes/foobar
1829 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1839 commit refs/notes/foobar2
1841 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1851 commit refs/notes/foobar
1853 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1866 test_expect_success \
1868 'git fast-import <input &&
1869 git whatchanged notes-test'
1871 test_expect_success 'Q: verify pack' '
1875 commit1=$(git rev-parse notes-test~2)
1876 commit2=$(git rev-parse notes-test^)
1877 commit3=$(git rev-parse notes-test)
1880 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1881 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1885 test_expect_success \
1886 'Q: verify first commit' \
1887 'git cat-file commit notes-test~2 | sed 1d >actual &&
1888 test_cmp expect actual'
1892 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1893 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1897 test_expect_success \
1898 'Q: verify second commit' \
1899 'git cat-file commit notes-test^ | sed 1d >actual &&
1900 test_cmp expect actual'
1904 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1905 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1909 test_expect_success \
1910 'Q: verify third commit' \
1911 'git cat-file commit notes-test | sed 1d >actual &&
1912 test_cmp expect actual'
1915 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1916 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1920 test_expect_success \
1921 'Q: verify first notes commit' \
1922 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1923 test_cmp expect actual'
1925 cat >expect.unsorted <<EOF
1926 100644 blob $commit1
1927 100644 blob $commit2
1928 100644 blob $commit3
1930 cat expect.unsorted | sort >expect
1931 test_expect_success \
1932 'Q: verify first notes tree' \
1933 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1934 test_cmp expect actual'
1936 echo "$note1_data" >expect
1937 test_expect_success \
1938 'Q: verify first note for first commit' \
1939 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1941 echo "$note2_data" >expect
1942 test_expect_success \
1943 'Q: verify first note for second commit' \
1944 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1946 echo "$note3_data" >expect
1947 test_expect_success \
1948 'Q: verify first note for third commit' \
1949 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1952 parent `git rev-parse --verify refs/notes/foobar~2`
1953 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1954 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1958 test_expect_success \
1959 'Q: verify second notes commit' \
1960 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1961 test_cmp expect actual'
1963 cat >expect.unsorted <<EOF
1964 100644 blob $commit1
1965 100644 blob $commit2
1966 100644 blob $commit3
1968 cat expect.unsorted | sort >expect
1969 test_expect_success \
1970 'Q: verify second notes tree' \
1971 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1972 test_cmp expect actual'
1974 echo "$note1b_data" >expect
1975 test_expect_success \
1976 'Q: verify second note for first commit' \
1977 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1979 echo "$note2_data" >expect
1980 test_expect_success \
1981 'Q: verify first note for second commit' \
1982 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1984 echo "$note3_data" >expect
1985 test_expect_success \
1986 'Q: verify first note for third commit' \
1987 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1990 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1991 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1995 test_expect_success \
1996 'Q: verify third notes commit' \
1997 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1998 test_cmp expect actual'
2000 cat >expect.unsorted <<EOF
2001 100644 blob $commit1
2003 cat expect.unsorted | sort >expect
2004 test_expect_success \
2005 'Q: verify third notes tree' \
2006 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2007 test_cmp expect actual'
2009 echo "$note1c_data" >expect
2010 test_expect_success \
2011 'Q: verify third note for first commit' \
2012 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
2015 parent `git rev-parse --verify refs/notes/foobar^`
2016 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2017 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2021 test_expect_success \
2022 'Q: verify fourth notes commit' \
2023 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
2024 test_cmp expect actual'
2026 cat >expect.unsorted <<EOF
2027 100644 blob $commit2
2029 cat expect.unsorted | sort >expect
2030 test_expect_success \
2031 'Q: verify fourth notes tree' \
2032 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2033 test_cmp expect actual'
2035 echo "$note2b_data" >expect
2036 test_expect_success \
2037 'Q: verify second note for second commit' \
2038 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
2043 commit refs/heads/note-Q0
2044 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2046 Note for an empty branch.
2049 N inline refs/heads/Q0
2054 test_expect_success \
2055 'Q: deny note on empty branch' \
2056 'test_must_fail git fast-import <input'
2058 ### series R (feature and option)
2062 feature no-such-feature-exists
2065 test_expect_success 'R: abort on unsupported feature' '
2066 test_must_fail git fast-import <input
2070 feature date-format=now
2073 test_expect_success 'R: supported feature is accepted' '
2074 git fast-import <input
2081 feature date-format=now
2084 test_expect_success 'R: abort on receiving feature after data command' '
2085 test_must_fail git fast-import <input
2089 feature import-marks=git.marks
2090 feature import-marks=git2.marks
2093 test_expect_success 'R: only one import-marks feature allowed per stream' '
2094 test_must_fail git fast-import <input
2098 feature export-marks=git.marks
2106 test_expect_success \
2107 'R: export-marks feature results in a marks file being created' \
2108 'cat input | git fast-import &&
2111 test_expect_success \
2112 'R: export-marks options can be overridden by commandline options' \
2113 'cat input | git fast-import --export-marks=other.marks &&
2114 grep :1 other.marks'
2116 test_expect_success 'R: catch typo in marks file name' '
2117 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2118 echo "feature import-marks=nonexistent.marks" |
2119 test_must_fail git fast-import
2122 test_expect_success 'R: import and output marks can be the same file' '
2124 blob=$(echo hi | git hash-object --stdin) &&
2125 cat >expect <<-EOF &&
2129 git fast-import --export-marks=io.marks <<-\EOF &&
2136 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2143 test_cmp expect io.marks
2146 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2148 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2157 test_expect_success 'R: --import-marks-if-exists' '
2159 blob=$(echo hi | git hash-object --stdin) &&
2160 echo ":1 $blob" >expect &&
2161 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2168 test_cmp expect io.marks
2171 test_expect_success 'R: feature import-marks-if-exists' '
2175 git fast-import --export-marks=io.marks <<-\EOF &&
2176 feature import-marks-if-exists=not_io.marks
2178 test_cmp expect io.marks &&
2180 blob=$(echo hi | git hash-object --stdin) &&
2182 echo ":1 $blob" >io.marks &&
2183 echo ":1 $blob" >expect &&
2184 echo ":2 $blob" >>expect &&
2186 git fast-import --export-marks=io.marks <<-\EOF &&
2187 feature import-marks-if-exists=io.marks
2194 test_cmp expect io.marks &&
2196 echo ":3 $blob" >>expect &&
2198 git fast-import --import-marks=io.marks \
2199 --export-marks=io.marks <<-\EOF &&
2200 feature import-marks-if-exists=not_io.marks
2207 test_cmp expect io.marks &&
2211 git fast-import --import-marks-if-exists=not_io.marks \
2212 --export-marks=io.marks <<-\EOF
2213 feature import-marks-if-exists=io.marks
2215 test_cmp expect io.marks
2219 feature import-marks=marks.out
2220 feature export-marks=marks.new
2223 test_expect_success \
2224 'R: import to output marks works without any content' \
2225 'cat input | git fast-import &&
2226 test_cmp marks.out marks.new'
2229 feature import-marks=nonexistent.marks
2230 feature export-marks=marks.new
2233 test_expect_success \
2234 'R: import marks prefers commandline marks file over the stream' \
2235 'cat input | git fast-import --import-marks=marks.out &&
2236 test_cmp marks.out marks.new'
2240 feature import-marks=nonexistent.marks
2241 feature export-marks=combined.marks
2244 test_expect_success 'R: multiple --import-marks= should be honoured' '
2245 head -n2 marks.out > one.marks &&
2246 tail -n +3 marks.out > two.marks &&
2247 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2248 test_cmp marks.out combined.marks
2252 feature relative-marks
2253 feature import-marks=relative.in
2254 feature export-marks=relative.out
2257 test_expect_success 'R: feature relative-marks should be honoured' '
2258 mkdir -p .git/info/fast-import/ &&
2259 cp marks.new .git/info/fast-import/relative.in &&
2260 git fast-import <input &&
2261 test_cmp marks.new .git/info/fast-import/relative.out
2265 feature relative-marks
2266 feature import-marks=relative.in
2267 feature no-relative-marks
2268 feature export-marks=non-relative.out
2271 test_expect_success 'R: feature no-relative-marks should be honoured' '
2272 git fast-import <input &&
2273 test_cmp marks.new non-relative.out
2276 test_expect_success 'R: feature ls supported' '
2281 test_expect_success 'R: feature cat-blob supported' '
2282 echo "feature cat-blob" |
2286 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2287 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2290 test_expect_success NOT_MINGW 'R: print old blob' '
2291 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2292 cat >expect <<-EOF &&
2297 echo "cat-blob $blob" |
2298 git fast-import --cat-blob-fd=6 6>actual &&
2299 test_cmp expect actual
2302 test_expect_success NOT_MINGW 'R: in-stream cat-blob-fd not respected' '
2303 echo hello >greeting &&
2304 blob=$(git hash-object -w greeting) &&
2305 cat >expect <<-EOF &&
2310 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2313 test_cmp expect actual.3 &&
2314 test_cmp empty actual.1 &&
2315 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2316 option cat-blob-fd=3
2319 test_cmp empty actual.3 &&
2320 test_cmp expect actual.1
2323 test_expect_success NOT_MINGW 'R: print new blob' '
2324 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2325 cat >expect <<-EOF &&
2330 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2338 test_cmp expect actual
2341 test_expect_success NOT_MINGW 'R: print new blob by sha1' '
2342 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2343 cat >expect <<-EOF &&
2345 a new blob named by sha1
2348 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2351 a new blob named by sha1
2355 test_cmp expect actual
2358 test_expect_success 'setup: big file' '
2360 echo "the quick brown fox jumps over the lazy dog" >big &&
2363 cat big big big big >bigger &&
2364 cat bigger bigger bigger bigger >big ||
2370 test_expect_success 'R: print two blobs to stdout' '
2371 blob1=$(git hash-object big) &&
2372 blob1_len=$(wc -c <big) &&
2373 blob2=$(echo hello | git hash-object --stdin) &&
2375 echo ${blob1} blob $blob1_len &&
2385 cat <<-\END_PART1 &&
2402 git fast-import >actual &&
2403 test_cmp expect actual
2406 test_expect_success PIPE 'R: copy using cat-file' '
2407 expect_id=$(git hash-object big) &&
2408 expect_len=$(wc -c <big) &&
2409 echo $expect_id blob $expect_len >expect.response &&
2412 cat >frontend <<-\FRONTEND_END &&
2418 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2431 read blob_id type size <&3 &&
2432 echo "$blob_id $type $size" >response &&
2433 head_c $size >blob <&3 &&
2437 commit refs/heads/copied
2438 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2440 copy big file as file3
2448 git fast-import --cat-blob-fd=3 3>blobs &&
2449 git show copied:file3 >actual &&
2450 test_cmp expect.response response &&
2454 test_expect_success PIPE 'R: print blob mid-commit' '
2456 echo "A blob from _before_ the commit." >expect &&
2465 A blob from _before_ the commit.
2467 commit refs/heads/temporary
2468 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2475 read blob_id type size <&3 &&
2476 head_c $size >actual <&3 &&
2481 git fast-import --cat-blob-fd=3 3>blobs &&
2482 test_cmp expect actual
2485 test_expect_success PIPE 'R: print staged blob within commit' '
2487 echo "A blob from _within_ the commit." >expect &&
2493 commit refs/heads/within
2494 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2500 A blob from _within_ the commit.
2505 echo "A blob from _within_ the commit." |
2506 git hash-object --stdin
2508 echo "cat-blob $to_get" &&
2510 read blob_id type size <&3 &&
2511 head_c $size >actual <&3 &&
2516 git fast-import --cat-blob-fd=3 3>blobs &&
2517 test_cmp expect actual
2528 test_expect_success 'R: quiet option results in no stats being output' '
2529 cat input | git fast-import 2> output &&
2530 test_cmp empty output
2533 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2534 echo feature done | test_must_fail git fast-import &&
2535 test_must_fail git fast-import --done </dev/null
2538 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2539 git fast-import <<-\EOF &&
2544 git fast-import <<-\EOF
2546 more trailing gibberish
2550 test_expect_success 'R: terminating "done" within commit' '
2551 cat >expect <<-\EOF &&
2553 :000000 100644 OBJID OBJID A hello.c
2554 :000000 100644 OBJID OBJID A hello2.c
2556 git fast-import <<-EOF &&
2557 commit refs/heads/done-ends
2558 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2560 Commit terminated by "done" command
2562 M 100644 inline hello.c
2569 git rev-list done-ends |
2570 git diff-tree -r --stdin --root --always |
2571 sed -e "s/$_x40/OBJID/g" >actual &&
2572 test_cmp expect actual
2576 option git non-existing-option
2579 test_expect_success 'R: die on unknown option' '
2580 test_must_fail git fast-import <input
2583 test_expect_success 'R: unknown commandline options are rejected' '\
2584 test_must_fail git fast-import --non-existing-option < /dev/null
2587 test_expect_success 'R: die on invalid option argument' '
2588 echo "option git active-branches=-5" |
2589 test_must_fail git fast-import &&
2590 echo "option git depth=" |
2591 test_must_fail git fast-import &&
2592 test_must_fail git fast-import --depth="5 elephants" </dev/null
2596 option non-existing-vcs non-existing-option
2599 test_expect_success 'R: ignore non-git options' '
2600 git fast-import <input
2604 ## R: very large blobs
2606 blobsize=$((2*1024*1024 + 53))
2607 test-genrandom bar $blobsize >expect
2608 cat >input <<INPUT_END
2609 commit refs/heads/big-file
2610 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2619 cat >>input <<INPUT_END
2626 test_expect_success \
2627 'R: blob bigger than threshold' \
2628 'test_create_repo R &&
2629 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2631 test_expect_success 'R: verify created pack' '
2634 verify_packs -v > ../verify
2638 test_expect_success \
2639 'R: verify written objects' \
2640 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2641 test_cmp expect actual &&
2642 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2643 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2645 test_expect_success \
2646 'R: blob appears only once' \
2647 'n=$(grep $a verify | wc -l) &&
2654 # Make sure missing spaces and EOLs after mark references
2663 # commit marks: 301, 302, 303, 304
2664 # blob marks: 403, 404, resp.
2667 # The error message when a space is missing not at the
2668 # end of the line is:
2670 # Missing space after ..
2672 # or when extra characters come after the mark at the end
2677 # or when the dataref is neither "inline " or a known SHA1,
2679 # Invalid dataref ..
2683 cat >input <<INPUT_END
2686 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2690 M 100644 inline hello.c
2697 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2702 M 100644 inline hello.c
2720 test_expect_success 'S: initialize for S tests' '
2721 git fast-import --export-marks=marks <input
2725 # filemodify, three datarefs
2727 test_expect_success 'S: filemodify with garbage after mark must fail' '
2728 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2730 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2734 M 100644 :403x hello.c
2737 test_i18ngrep "space after mark" err
2740 # inline is misspelled; fast-import thinks it is some unknown dataref
2741 test_expect_success 'S: filemodify with garbage after inline must fail' '
2742 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2744 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2748 M 100644 inlineX hello.c
2754 test_i18ngrep "nvalid dataref" err
2757 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2758 sha1=$(grep :403 marks | cut -d\ -f2) &&
2759 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2761 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2765 M 100644 ${sha1}x hello.c
2768 test_i18ngrep "space after SHA1" err
2772 # notemodify, three ways to say dataref
2774 test_expect_success 'S: notemodify with garabge after mark dataref must fail' '
2775 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2777 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2779 commit S note dataref markref
2784 test_i18ngrep "space after mark" err
2787 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2788 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2790 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2792 commit S note dataref inline
2800 test_i18ngrep "nvalid dataref" err
2803 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2804 sha1=$(grep :202 marks | cut -d\ -f2) &&
2805 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2807 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2809 commit S note dataref sha1
2814 test_i18ngrep "space after SHA1" err
2818 # notemodify, mark in committish
2820 test_expect_success 'S: notemodify with garbarge after mark committish must fail' '
2821 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2822 commit refs/heads/Snotes
2823 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2825 commit S note committish
2830 test_i18ngrep "after mark" err
2836 test_expect_success 'S: from with garbage after mark must fail' '
2838 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err
2839 commit refs/heads/S2
2841 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2846 M 100644 :403 hello.c
2850 echo returned $ret &&
2851 test $ret -ne 0 && # failed, but it created the commit
2853 # go create the commit, need it for merge test
2854 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2855 commit refs/heads/S2
2857 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2862 M 100644 :403 hello.c
2865 # now evaluate the error
2867 test_i18ngrep "after mark" err
2874 test_expect_success 'S: merge with garbage after mark must fail' '
2875 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2878 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2884 M 100644 :403 hello.c
2887 test_i18ngrep "after mark" err
2893 test_expect_success 'S: tag with garbage after mark must fail' '
2894 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2897 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2903 test_i18ngrep "after mark" err
2909 test_expect_success 'S: cat-blob with garbage after mark must fail' '
2910 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2914 test_i18ngrep "after mark" err
2920 test_expect_success 'S: ls with garbage after mark must fail' '
2921 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2925 test_i18ngrep "space after mark" err
2928 test_expect_success 'S: ls with garbage after sha1 must fail' '
2929 sha1=$(grep :302 marks | cut -d\ -f2) &&
2930 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2934 test_i18ngrep "space after tree-ish" err