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);
37 file5_data='an inline file.
38 we should see it later.'
45 test_expect_success 'setup: have pipes?' '
59 test_expect_success 'empty stream succeeds' '
60 git fast-import </dev/null
63 cat >input <<INPUT_END
80 commit refs/heads/master
82 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
94 An annotated tag without a tagger
99 'A: create pack from stdin' \
100 'git fast-import --export-marks=marks.out <input &&
101 git whatchanged master'
102 test_expect_success \
104 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
107 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
108 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
112 test_expect_success \
114 'git cat-file commit master | sed 1d >actual &&
115 test_cmp expect actual'
122 test_expect_success \
124 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
125 test_cmp expect actual'
127 echo "$file2_data" >expect
128 test_expect_success \
130 'git cat-file blob master:file2 >actual && test_cmp expect actual'
132 echo "$file3_data" >expect
133 test_expect_success \
135 'git cat-file blob master:file3 >actual && test_cmp expect actual'
137 printf "$file4_data" >expect
138 test_expect_success \
140 'git cat-file blob master:file4 >actual && test_cmp expect actual'
143 object $(git rev-parse refs/heads/master)
147 An annotated tag without a tagger
149 test_expect_success 'A: verify tag/series-A' '
150 git cat-file tag tags/series-A >actual &&
151 test_cmp expect actual
155 :2 `git rev-parse --verify master:file2`
156 :3 `git rev-parse --verify master:file3`
157 :4 `git rev-parse --verify master:file4`
158 :5 `git rev-parse --verify master^0`
160 test_expect_success \
161 'A: verify marks output' \
162 'test_cmp expect marks.out'
164 test_expect_success \
165 'A: verify marks import' \
167 --import-marks=marks.out \
168 --export-marks=marks.new \
170 test_cmp expect marks.new'
173 cat >input <<INPUT_END
174 commit refs/heads/verify--import-marks
175 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
181 M 755 :2 copy-of-file2
184 test_expect_success \
185 'A: verify marks import does not crash' \
186 'git fast-import --import-marks=marks.out <input &&
187 git whatchanged verify--import-marks'
188 test_expect_success \
190 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
192 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
194 git diff-tree -M -r master verify--import-marks >actual
195 test_expect_success \
197 'compare_diff_raw expect actual &&
198 test `git rev-parse --verify master:file2` \
199 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
202 mt=$(git hash-object --stdin < /dev/null)
207 cat >input.commit <<EOF
208 commit refs/heads/verify--dump-marks
209 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
211 test the sparse array dumping routines with exponentially growing marks
219 while test "$i" -lt 27; do
220 cat >>input.blob <<EOF
231 echo "M 100644 :$l l$i" >>input.commit
232 echo "M 100644 :$m m$i" >>input.commit
233 echo "M 100644 :$n n$i" >>input.commit
235 echo ":$l $mt" >>marks.exp
236 echo ":$m $mt" >>marks.exp
237 echo ":$n $mt" >>marks.exp
239 printf "100644 blob $mt\tl$i\n" >>tree.exp
240 printf "100644 blob $mt\tm$i\n" >>tree.exp
241 printf "100644 blob $mt\tn$i\n" >>tree.exp
250 sort tree.exp > tree.exp_s
252 test_expect_success 'A: export marks with large values' '
253 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
254 git ls-tree refs/heads/verify--dump-marks >tree.out &&
255 test_cmp tree.exp_s tree.out &&
256 test_cmp marks.exp marks.large'
263 cat >input <<INPUT_END
264 commit refs/heads/branch
266 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
271 from refs/heads/master
272 M 755 0000000000000000000000000000000000000001 zero1
275 test_expect_success 'B: fail on invalid blob sha1' '
276 test_must_fail git fast-import <input
278 rm -f .git/objects/pack_* .git/objects/index_*
280 cat >input <<INPUT_END
281 commit .badbranchname
282 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
287 from refs/heads/master
290 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
291 test_must_fail git fast-import <input
293 rm -f .git/objects/pack_* .git/objects/index_*
295 cat >input <<INPUT_END
296 commit bad[branch]name
297 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
302 from refs/heads/master
305 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
306 test_must_fail git fast-import <input
308 rm -f .git/objects/pack_* .git/objects/index_*
310 cat >input <<INPUT_END
312 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
317 from refs/heads/master
320 test_expect_success \
321 'B: accept branch name "TEMP_TAG"' \
322 'git fast-import <input &&
323 test -f .git/TEMP_TAG &&
324 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
327 git gc 2>/dev/null >/dev/null
328 git prune 2>/dev/null >/dev/null
330 cat >input <<INPUT_END
331 commit refs/heads/empty-committer-1
332 committer <> $GIT_COMMITTER_DATE
337 test_expect_success 'B: accept empty committer' '
338 git fast-import <input &&
343 git update-ref -d refs/heads/empty-committer-1 || true
345 git gc 2>/dev/null >/dev/null
346 git prune 2>/dev/null >/dev/null
348 cat >input <<INPUT_END
349 commit refs/heads/empty-committer-2
350 committer <a@b.com> $GIT_COMMITTER_DATE
355 test_expect_success 'B: accept and fixup committer with no name' '
356 git fast-import <input &&
361 git update-ref -d refs/heads/empty-committer-2 || true
363 git gc 2>/dev/null >/dev/null
364 git prune 2>/dev/null >/dev/null
366 cat >input <<INPUT_END
367 commit refs/heads/invalid-committer
368 committer Name email> $GIT_COMMITTER_DATE
373 test_expect_success 'B: fail on invalid committer (1)' '
374 test_must_fail git fast-import <input
376 git update-ref -d refs/heads/invalid-committer || true
378 cat >input <<INPUT_END
379 commit refs/heads/invalid-committer
380 committer Name <e<mail> $GIT_COMMITTER_DATE
385 test_expect_success 'B: fail on invalid committer (2)' '
386 test_must_fail git fast-import <input
388 git update-ref -d refs/heads/invalid-committer || true
390 cat >input <<INPUT_END
391 commit refs/heads/invalid-committer
392 committer Name <email>> $GIT_COMMITTER_DATE
397 test_expect_success 'B: fail on invalid committer (3)' '
398 test_must_fail git fast-import <input
400 git update-ref -d refs/heads/invalid-committer || true
402 cat >input <<INPUT_END
403 commit refs/heads/invalid-committer
404 committer Name <email $GIT_COMMITTER_DATE
409 test_expect_success 'B: fail on invalid committer (4)' '
410 test_must_fail git fast-import <input
412 git update-ref -d refs/heads/invalid-committer || true
414 cat >input <<INPUT_END
415 commit refs/heads/invalid-committer
416 committer Name<email> $GIT_COMMITTER_DATE
421 test_expect_success 'B: fail on invalid committer (5)' '
422 test_must_fail git fast-import <input
424 git update-ref -d refs/heads/invalid-committer || true
430 newf=`echo hi newf | git hash-object -w --stdin`
431 oldf=`git rev-parse --verify master:file2`
433 cat >input <<INPUT_END
434 commit refs/heads/branch
435 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
440 from refs/heads/master
441 M 644 $oldf file2/oldf
442 M 755 $newf file2/newf
446 test_expect_success \
447 'C: incremental import create pack from stdin' \
448 'git fast-import <input &&
449 git whatchanged branch'
450 test_expect_success \
452 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
453 test_expect_success \
454 'C: validate reuse existing blob' \
455 'test $newf = `git rev-parse --verify branch:file2/newf` &&
456 test $oldf = `git rev-parse --verify branch:file2/oldf`'
459 parent `git rev-parse --verify master^0`
460 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
461 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
465 test_expect_success \
467 'git cat-file commit branch | sed 1d >actual &&
468 test_cmp expect actual'
471 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
472 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
473 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
475 git diff-tree -M -r master branch >actual
476 test_expect_success \
477 'C: validate rename result' \
478 'compare_diff_raw expect actual'
485 cat >input <<INPUT_END
486 commit refs/heads/branch
487 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
492 from refs/heads/branch^0
493 M 644 inline newdir/interesting
498 M 755 inline newdir/exec.sh
504 test_expect_success \
505 'D: inline data in commit' \
506 'git fast-import <input &&
507 git whatchanged branch'
508 test_expect_success \
510 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
513 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
514 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
516 git diff-tree -M -r branch^ branch >actual
517 test_expect_success \
518 'D: validate new files added' \
519 'compare_diff_raw expect actual'
521 echo "$file5_data" >expect
522 test_expect_success \
524 'git cat-file blob branch:newdir/interesting >actual &&
525 test_cmp expect actual'
527 echo "$file6_data" >expect
528 test_expect_success \
530 'git cat-file blob branch:newdir/exec.sh >actual &&
531 test_cmp expect actual'
537 cat >input <<INPUT_END
538 commit refs/heads/branch
539 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
540 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
545 from refs/heads/branch^0
548 test_expect_success 'E: rfc2822 date, --date-format=raw' '
549 test_must_fail git fast-import --date-format=raw <input
551 test_expect_success \
552 'E: rfc2822 date, --date-format=rfc2822' \
553 'git fast-import --date-format=rfc2822 <input'
554 test_expect_success \
556 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
559 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
560 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
564 test_expect_success \
566 'git cat-file commit branch | sed 1,2d >actual &&
567 test_cmp expect actual'
573 old_branch=`git rev-parse --verify branch^0`
575 cat >input <<INPUT_END
576 commit refs/heads/branch
577 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
579 losing things already?
582 from refs/heads/branch~1
584 reset refs/heads/other
585 from refs/heads/branch
588 test_expect_success \
589 'F: non-fast-forward update skips' \
590 'if git fast-import <input
592 echo BAD gfi did not fail
595 if test $old_branch = `git rev-parse --verify branch^0`
597 : branch unaffected and failure returned
600 echo BAD gfi changed branch $old_branch
605 test_expect_success \
607 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
610 tree `git rev-parse branch~1^{tree}`
611 parent `git rev-parse branch~1`
612 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
613 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
615 losing things already?
617 test_expect_success \
618 'F: verify other commit' \
619 'git cat-file commit other >actual &&
620 test_cmp expect actual'
626 old_branch=`git rev-parse --verify branch^0`
628 cat >input <<INPUT_END
629 commit refs/heads/branch
630 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
632 losing things already?
635 from refs/heads/branch~1
638 test_expect_success \
639 'G: non-fast-forward update forced' \
640 'git fast-import --force <input'
641 test_expect_success \
643 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
644 test_expect_success \
645 'G: branch changed, but logged' \
646 'test $old_branch != `git rev-parse --verify branch^0` &&
647 test $old_branch = `git rev-parse --verify branch@{1}`'
654 cat >input <<INPUT_END
656 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
661 from refs/heads/branch^0
662 M 644 inline i-will-die
664 this file will never exist.
668 M 644 inline h/e/l/lo
674 test_expect_success \
675 'H: deletall, add 1' \
676 'git fast-import <input &&
678 test_expect_success \
680 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
683 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
684 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
685 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
686 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
687 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
689 git diff-tree -M -r H^ H >actual
690 test_expect_success \
691 'H: validate old files removed, new files added' \
692 'compare_diff_raw expect actual'
694 echo "$file5_data" >expect
695 test_expect_success \
697 'git cat-file blob H:h/e/l/lo >actual &&
698 test_cmp expect actual'
704 cat >input <<INPUT_END
705 commit refs/heads/export-boundary
706 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
708 we have a border. its only 40 characters wide.
711 from refs/heads/branch
714 test_expect_success \
715 'I: export-pack-edges' \
716 'git fast-import --export-pack-edges=edges.list <input'
719 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
721 test_expect_success \
722 'I: verify edge list' \
723 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
724 test_cmp expect actual'
730 cat >input <<INPUT_END
732 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
737 from refs/heads/branch
742 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
748 test_expect_success \
749 'J: reset existing branch creates empty commit' \
750 'git fast-import <input'
751 test_expect_success \
752 'J: branch has 1 commit, empty tree' \
753 'test 1 = `git rev-list J | wc -l` &&
754 test 0 = `git ls-tree J | wc -l`'
760 cat >input <<INPUT_END
762 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
767 from refs/heads/branch
770 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
775 from refs/heads/branch^1
778 test_expect_success \
779 'K: reinit branch with from' \
780 'git fast-import <input'
781 test_expect_success \
782 'K: verify K^1 = branch^1' \
783 'test `git rev-parse --verify branch^1` \
784 = `git rev-parse --verify K^1`'
790 cat >input <<INPUT_END
804 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
814 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
824 cat >expect <<EXPECT_END
825 :100644 100644 4268632... 55d3a52... M b.
826 :040000 040000 0ae5cac... 443c768... M b
827 :100644 100644 4268632... 55d3a52... M ba
830 test_expect_success \
831 'L: verify internal tree sorting' \
832 'git fast-import <input &&
833 git diff-tree --abbrev --raw L^ L >output &&
834 test_cmp expect output'
836 cat >input <<INPUT_END
844 committer C O Mitter <committer@example.com> 1112912473 -0700
853 committer C O Mitter <committer@example.com> 1112912473 -0700
867 test_expect_success \
868 'L: nested tree copy does not corrupt deltas' \
869 'git fast-import <input &&
870 git ls-tree L2 g/b/ >tmp &&
871 cat tmp | cut -f 2 >actual &&
872 test_cmp expect actual &&
873 git fsck `git rev-parse L2`'
875 git update-ref -d refs/heads/L2
882 cat >input <<INPUT_END
884 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
889 from refs/heads/branch^0
890 R file2/newf file2/n.e.w.f
895 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
897 test_expect_success \
898 'M: rename file in same subdirectory' \
899 'git fast-import <input &&
900 git diff-tree -M -r M1^ M1 >actual &&
901 compare_diff_raw expect actual'
903 cat >input <<INPUT_END
905 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
910 from refs/heads/branch^0
911 R file2/newf i/am/new/to/you
916 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
918 test_expect_success \
919 'M: rename file to new subdirectory' \
920 'git fast-import <input &&
921 git diff-tree -M -r M2^ M2 >actual &&
922 compare_diff_raw expect actual'
924 cat >input <<INPUT_END
926 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
937 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
939 test_expect_success \
940 'M: rename subdirectory to new subdirectory' \
941 'git fast-import <input &&
942 git diff-tree -M -r M3^ M3 >actual &&
943 compare_diff_raw expect actual'
950 cat >input <<INPUT_END
952 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
957 from refs/heads/branch^0
958 C file2/newf file2/n.e.w.f
963 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
965 test_expect_success \
966 'N: copy file in same subdirectory' \
967 'git fast-import <input &&
968 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
969 compare_diff_raw expect actual'
971 cat >input <<INPUT_END
973 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
978 from refs/heads/branch^0
982 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
984 modify directory copy
987 M 644 inline file3/file5
995 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
996 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
997 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
999 test_expect_success \
1000 'N: copy then modify subdirectory' \
1001 'git fast-import <input &&
1002 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1003 compare_diff_raw expect actual'
1005 cat >input <<INPUT_END
1006 commit refs/heads/N3
1007 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1009 dirty directory copy
1012 from refs/heads/branch^0
1013 M 644 inline file2/file5
1023 test_expect_success \
1024 'N: copy dirty subdirectory' \
1025 'git fast-import <input &&
1026 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
1028 test_expect_success \
1029 'N: copy directory by id' \
1030 'cat >expect <<-\EOF &&
1031 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1032 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1034 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1035 cat >input <<-INPUT_END &&
1036 commit refs/heads/N4
1037 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1042 from refs/heads/branch^0
1043 M 040000 $subdir file3
1045 git fast-import <input &&
1046 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1047 compare_diff_raw expect actual'
1049 test_expect_success PIPE 'N: read and copy directory' '
1051 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1052 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1054 git update-ref -d refs/heads/N4 &&
1060 commit refs/heads/N4
1061 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1063 copy by tree hash, part 2
1066 from refs/heads/branch^0
1069 read mode type tree filename &&
1070 echo "M 040000 $tree file3"
1072 git fast-import --cat-blob-fd=3 3>backflow &&
1073 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1074 compare_diff_raw expect actual
1077 test_expect_success PIPE 'N: empty directory reads as missing' '
1078 cat <<-\EOF >expect &&
1080 :000000 100644 OBJNAME OBJNAME A unrelated
1082 echo "missing src" >expect.response &&
1083 git update-ref -d refs/heads/read-empty &&
1089 commit refs/heads/read-empty
1090 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1092 read "empty" (missing) directory
1095 M 100644 inline src/greeting
1099 C src/greeting dst1/non-greeting
1100 C src/greeting unrelated
1101 # leave behind "empty" src directory
1106 printf "%s\n" "$line" >response &&
1112 git fast-import --cat-blob-fd=3 3>backflow &&
1113 test_cmp expect.response response &&
1114 git rev-list read-empty |
1115 git diff-tree -r --root --stdin |
1116 sed "s/$_x40/OBJNAME/g" >actual &&
1117 test_cmp expect actual
1120 test_expect_success \
1121 'N: copy root directory by tree hash' \
1122 'cat >expect <<-\EOF &&
1123 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1124 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1126 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1127 cat >input <<-INPUT_END &&
1128 commit refs/heads/N6
1129 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1131 copy root directory by tree hash
1134 from refs/heads/branch^0
1137 git fast-import <input &&
1138 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1139 compare_diff_raw expect actual'
1141 test_expect_success \
1142 'N: delete directory by copying' \
1143 'cat >expect <<-\EOF &&
1145 :100644 000000 OBJID OBJID D foo/bar/qux
1147 :000000 100644 OBJID OBJID A foo/bar/baz
1148 :000000 100644 OBJID OBJID A foo/bar/qux
1150 empty_tree=$(git mktree </dev/null) &&
1151 cat >input <<-INPUT_END &&
1152 commit refs/heads/N-delete
1153 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1155 collect data to be deleted
1159 M 100644 inline foo/bar/baz
1163 C "foo/bar/baz" "foo/bar/qux"
1164 C "foo/bar/baz" "foo/bar/quux/1"
1165 C "foo/bar/baz" "foo/bar/quuux"
1166 M 040000 $empty_tree foo/bar/quux
1167 M 040000 $empty_tree foo/bar/quuux
1169 commit refs/heads/N-delete
1170 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1175 M 040000 $empty_tree foo/bar/qux
1177 git fast-import <input &&
1178 git rev-list N-delete |
1179 git diff-tree -r --stdin --root --always |
1180 sed -e "s/$_x40/OBJID/g" >actual &&
1181 test_cmp expect actual'
1183 test_expect_success \
1184 'N: modify copied tree' \
1185 'cat >expect <<-\EOF &&
1186 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1187 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1188 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1190 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1191 cat >input <<-INPUT_END &&
1192 commit refs/heads/N5
1193 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1198 from refs/heads/branch^0
1199 M 040000 $subdir file3
1201 commit refs/heads/N5
1202 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1204 modify directory copy
1207 M 644 inline file3/file5
1212 git fast-import <input &&
1213 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1214 compare_diff_raw expect actual'
1216 test_expect_success \
1217 'N: reject foo/ syntax' \
1218 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1219 test_must_fail git fast-import <<-INPUT_END
1220 commit refs/heads/N5B
1221 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1223 copy with invalid syntax
1226 from refs/heads/branch^0
1227 M 040000 $subdir file3/
1230 test_expect_success \
1231 'N: copy to root by id and modify' \
1232 'echo "hello, world" >expect.foo &&
1233 echo hello >expect.bar &&
1234 git fast-import <<-SETUP_END &&
1235 commit refs/heads/N7
1236 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1242 M 644 inline foo/bar
1248 tree=$(git rev-parse --verify N7:) &&
1249 git fast-import <<-INPUT_END &&
1250 commit refs/heads/N8
1251 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1253 copy to root by id and modify
1257 M 644 inline foo/foo
1262 git show N8:foo/foo >actual.foo &&
1263 git show N8:foo/bar >actual.bar &&
1264 test_cmp expect.foo actual.foo &&
1265 test_cmp expect.bar actual.bar'
1267 test_expect_success \
1268 'N: extract subtree' \
1269 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1270 cat >input <<-INPUT_END &&
1271 commit refs/heads/N9
1272 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1274 extract subtree branch:newdir
1280 git fast-import <input &&
1281 git diff --exit-code branch:newdir N9'
1283 test_expect_success \
1284 'N: modify subtree, extract it, and modify again' \
1285 'echo hello >expect.baz &&
1286 echo hello, world >expect.qux &&
1287 git fast-import <<-SETUP_END &&
1288 commit refs/heads/N10
1289 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1295 M 644 inline foo/bar/baz
1301 tree=$(git rev-parse --verify N10:) &&
1302 git fast-import <<-INPUT_END &&
1303 commit refs/heads/N11
1304 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1306 copy to root by id and modify
1310 M 100644 inline foo/bar/qux
1315 C "bar/qux" "bar/quux"
1317 git show N11:bar/baz >actual.baz &&
1318 git show N11:bar/qux >actual.qux &&
1319 git show N11:bar/quux >actual.quux &&
1320 test_cmp expect.baz actual.baz &&
1321 test_cmp expect.qux actual.qux &&
1322 test_cmp expect.qux actual.quux'
1328 cat >input <<INPUT_END
1330 commit refs/heads/O1
1331 # -- ignore all of this text
1332 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1333 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1335 dirty directory copy
1338 # don't forget the import blank line!
1340 # yes, we started from our usual base of branch^0.
1342 from refs/heads/branch^0
1343 # and we need to reuse file2/file5 from N3 above.
1344 M 644 inline file2/file5
1345 # otherwise the tree will be different
1350 # don't forget to copy file2 to file3
1353 # or to delete file5 from file2.
1359 test_expect_success \
1360 'O: comments are all skipped' \
1361 'git fast-import <input &&
1362 test `git rev-parse N3` = `git rev-parse O1`'
1364 cat >input <<INPUT_END
1365 commit refs/heads/O2
1366 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1368 dirty directory copy
1370 from refs/heads/branch^0
1371 M 644 inline file2/file5
1380 test_expect_success \
1381 'O: blank lines not necessary after data commands' \
1382 'git fast-import <input &&
1383 test `git rev-parse N3` = `git rev-parse O2`'
1385 test_expect_success \
1386 'O: repack before next test' \
1389 cat >input <<INPUT_END
1390 commit refs/heads/O3
1391 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1395 commit refs/heads/O3
1396 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1401 commit refs/heads/O3
1403 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1408 commit refs/heads/O3
1409 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1413 reset refs/tags/O3-2nd
1415 reset refs/tags/O3-3rd
1419 cat >expect <<INPUT_END
1425 test_expect_success \
1426 'O: blank lines not necessary after other commands' \
1427 'git fast-import <input &&
1428 test 8 = `find .git/objects/pack -type f | wc -l` &&
1429 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1430 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1431 test_cmp expect actual'
1433 cat >input <<INPUT_END
1434 commit refs/heads/O4
1435 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1439 commit refs/heads/O4
1440 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1444 progress Two commits down, 2 to go!
1445 commit refs/heads/O4
1446 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1450 progress Three commits down, 1 to go!
1451 commit refs/heads/O4
1452 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1458 test_expect_success \
1459 'O: progress outputs as requested by input' \
1460 'git fast-import <input >actual &&
1461 grep "progress " <input >expect &&
1462 test_cmp expect actual'
1465 ### series P (gitlinks)
1468 cat >input <<INPUT_END
1474 reset refs/heads/sub
1475 commit refs/heads/sub
1477 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1490 commit refs/heads/subuse1
1492 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1495 from refs/heads/master
1496 M 100644 :3 .gitmodules
1505 commit refs/heads/sub
1507 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1513 commit refs/heads/subuse1
1515 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1523 test_expect_success \
1524 'P: supermodule & submodule mix' \
1525 'git fast-import <input &&
1526 git checkout subuse1 &&
1527 rm -rf sub && mkdir sub && (cd sub &&
1529 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1530 git checkout master) &&
1531 git submodule init &&
1532 git submodule update'
1534 SUBLAST=$(git rev-parse --verify sub)
1535 SUBPREV=$(git rev-parse --verify sub^)
1537 cat >input <<INPUT_END
1546 commit refs/heads/subuse2
1548 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1551 from refs/heads/master
1552 M 100644 :1 .gitmodules
1553 M 160000 $SUBPREV sub
1555 commit refs/heads/subuse2
1557 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1561 M 160000 $SUBLAST sub
1565 test_expect_success \
1566 'P: verbatim SHA gitlinks' \
1567 'git branch -D sub &&
1568 git gc && git prune &&
1569 git fast-import <input &&
1570 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1573 cat >input <<INPUT_END
1574 commit refs/heads/subuse3
1576 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1581 from refs/heads/subuse2
1589 test_expect_success 'P: fail on inline gitlink' '
1590 test_must_fail git fast-import <input'
1593 cat >input <<INPUT_END
1600 commit refs/heads/subuse3
1602 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1607 from refs/heads/subuse2
1612 test_expect_success 'P: fail on blob mark in gitlink' '
1613 test_must_fail git fast-import <input'
1616 ### series Q (notes)
1619 note1_data="The first note for the first commit"
1620 note2_data="The first note for the second commit"
1621 note3_data="The first note for the third commit"
1622 note1b_data="The second note for the first commit"
1623 note1c_data="The third note for the first commit"
1624 note2b_data="The second note for the second commit"
1627 cat >input <<INPUT_END
1634 commit refs/heads/notes-test
1636 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1647 commit refs/heads/notes-test
1649 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1656 commit refs/heads/notes-test
1658 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1685 commit refs/notes/foobar
1687 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1699 commit refs/notes/foobar
1701 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1711 commit refs/notes/foobar2
1713 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1723 commit refs/notes/foobar
1725 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1738 test_expect_success \
1740 'git fast-import <input &&
1741 git whatchanged notes-test'
1742 test_expect_success \
1744 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1746 commit1=$(git rev-parse notes-test~2)
1747 commit2=$(git rev-parse notes-test^)
1748 commit3=$(git rev-parse notes-test)
1751 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1752 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1756 test_expect_success \
1757 'Q: verify first commit' \
1758 'git cat-file commit notes-test~2 | sed 1d >actual &&
1759 test_cmp expect actual'
1763 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1764 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1768 test_expect_success \
1769 'Q: verify second commit' \
1770 'git cat-file commit notes-test^ | sed 1d >actual &&
1771 test_cmp expect actual'
1775 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1776 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1780 test_expect_success \
1781 'Q: verify third commit' \
1782 'git cat-file commit notes-test | sed 1d >actual &&
1783 test_cmp expect actual'
1786 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1787 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1791 test_expect_success \
1792 'Q: verify first notes commit' \
1793 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1794 test_cmp expect actual'
1796 cat >expect.unsorted <<EOF
1797 100644 blob $commit1
1798 100644 blob $commit2
1799 100644 blob $commit3
1801 cat expect.unsorted | sort >expect
1802 test_expect_success \
1803 'Q: verify first notes tree' \
1804 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1805 test_cmp expect actual'
1807 echo "$note1_data" >expect
1808 test_expect_success \
1809 'Q: verify first note for first commit' \
1810 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1812 echo "$note2_data" >expect
1813 test_expect_success \
1814 'Q: verify first note for second commit' \
1815 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1817 echo "$note3_data" >expect
1818 test_expect_success \
1819 'Q: verify first note for third commit' \
1820 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1823 parent `git rev-parse --verify refs/notes/foobar~2`
1824 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1825 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1829 test_expect_success \
1830 'Q: verify second notes commit' \
1831 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1832 test_cmp expect actual'
1834 cat >expect.unsorted <<EOF
1835 100644 blob $commit1
1836 100644 blob $commit2
1837 100644 blob $commit3
1839 cat expect.unsorted | sort >expect
1840 test_expect_success \
1841 'Q: verify second notes tree' \
1842 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1843 test_cmp expect actual'
1845 echo "$note1b_data" >expect
1846 test_expect_success \
1847 'Q: verify second note for first commit' \
1848 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1850 echo "$note2_data" >expect
1851 test_expect_success \
1852 'Q: verify first note for second commit' \
1853 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1855 echo "$note3_data" >expect
1856 test_expect_success \
1857 'Q: verify first note for third commit' \
1858 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1861 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1866 test_expect_success \
1867 'Q: verify third notes commit' \
1868 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1869 test_cmp expect actual'
1871 cat >expect.unsorted <<EOF
1872 100644 blob $commit1
1874 cat expect.unsorted | sort >expect
1875 test_expect_success \
1876 'Q: verify third notes tree' \
1877 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1878 test_cmp expect actual'
1880 echo "$note1c_data" >expect
1881 test_expect_success \
1882 'Q: verify third note for first commit' \
1883 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1886 parent `git rev-parse --verify refs/notes/foobar^`
1887 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1888 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1892 test_expect_success \
1893 'Q: verify fourth notes commit' \
1894 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1895 test_cmp expect actual'
1897 cat >expect.unsorted <<EOF
1898 100644 blob $commit2
1900 cat expect.unsorted | sort >expect
1901 test_expect_success \
1902 'Q: verify fourth notes tree' \
1903 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1904 test_cmp expect actual'
1906 echo "$note2b_data" >expect
1907 test_expect_success \
1908 'Q: verify second note for second commit' \
1909 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1912 ### series R (feature and option)
1916 feature no-such-feature-exists
1919 test_expect_success 'R: abort on unsupported feature' '
1920 test_must_fail git fast-import <input
1924 feature date-format=now
1927 test_expect_success 'R: supported feature is accepted' '
1928 git fast-import <input
1935 feature date-format=now
1938 test_expect_success 'R: abort on receiving feature after data command' '
1939 test_must_fail git fast-import <input
1943 feature import-marks=git.marks
1944 feature import-marks=git2.marks
1947 test_expect_success 'R: only one import-marks feature allowed per stream' '
1948 test_must_fail git fast-import <input
1952 feature export-marks=git.marks
1960 test_expect_success \
1961 'R: export-marks feature results in a marks file being created' \
1962 'cat input | git fast-import &&
1965 test_expect_success \
1966 'R: export-marks options can be overriden by commandline options' \
1967 'cat input | git fast-import --export-marks=other.marks &&
1968 grep :1 other.marks'
1970 test_expect_success 'R: catch typo in marks file name' '
1971 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
1972 echo "feature import-marks=nonexistent.marks" |
1973 test_must_fail git fast-import
1976 test_expect_success 'R: import and output marks can be the same file' '
1978 blob=$(echo hi | git hash-object --stdin) &&
1979 cat >expect <<-EOF &&
1983 git fast-import --export-marks=io.marks <<-\EOF &&
1990 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
1997 test_cmp expect io.marks
2000 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2002 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2011 test_expect_success 'R: --import-marks-if-exists' '
2013 blob=$(echo hi | git hash-object --stdin) &&
2014 echo ":1 $blob" >expect &&
2015 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2022 test_cmp expect io.marks
2025 test_expect_success 'R: feature import-marks-if-exists' '
2029 git fast-import --export-marks=io.marks <<-\EOF &&
2030 feature import-marks-if-exists=not_io.marks
2032 test_cmp expect io.marks &&
2034 blob=$(echo hi | git hash-object --stdin) &&
2036 echo ":1 $blob" >io.marks &&
2037 echo ":1 $blob" >expect &&
2038 echo ":2 $blob" >>expect &&
2040 git fast-import --export-marks=io.marks <<-\EOF &&
2041 feature import-marks-if-exists=io.marks
2048 test_cmp expect io.marks &&
2050 echo ":3 $blob" >>expect &&
2052 git fast-import --import-marks=io.marks \
2053 --export-marks=io.marks <<-\EOF &&
2054 feature import-marks-if-exists=not_io.marks
2061 test_cmp expect io.marks &&
2065 git fast-import --import-marks-if-exists=not_io.marks \
2066 --export-marks=io.marks <<-\EOF
2067 feature import-marks-if-exists=io.marks
2069 test_cmp expect io.marks
2073 feature import-marks=marks.out
2074 feature export-marks=marks.new
2077 test_expect_success \
2078 'R: import to output marks works without any content' \
2079 'cat input | git fast-import &&
2080 test_cmp marks.out marks.new'
2083 feature import-marks=nonexistent.marks
2084 feature export-marks=marks.new
2087 test_expect_success \
2088 'R: import marks prefers commandline marks file over the stream' \
2089 'cat input | git fast-import --import-marks=marks.out &&
2090 test_cmp marks.out marks.new'
2094 feature import-marks=nonexistent.marks
2095 feature export-marks=combined.marks
2098 test_expect_success 'R: multiple --import-marks= should be honoured' '
2099 head -n2 marks.out > one.marks &&
2100 tail -n +3 marks.out > two.marks &&
2101 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2102 test_cmp marks.out combined.marks
2106 feature relative-marks
2107 feature import-marks=relative.in
2108 feature export-marks=relative.out
2111 test_expect_success 'R: feature relative-marks should be honoured' '
2112 mkdir -p .git/info/fast-import/ &&
2113 cp marks.new .git/info/fast-import/relative.in &&
2114 git fast-import <input &&
2115 test_cmp marks.new .git/info/fast-import/relative.out
2119 feature relative-marks
2120 feature import-marks=relative.in
2121 feature no-relative-marks
2122 feature export-marks=non-relative.out
2125 test_expect_success 'R: feature no-relative-marks should be honoured' '
2126 git fast-import <input &&
2127 test_cmp marks.new non-relative.out
2130 test_expect_success 'R: feature ls supported' '
2135 test_expect_success 'R: feature cat-blob supported' '
2136 echo "feature cat-blob" |
2140 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2141 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2144 test_expect_success 'R: print old blob' '
2145 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2146 cat >expect <<-EOF &&
2151 echo "cat-blob $blob" |
2152 git fast-import --cat-blob-fd=6 6>actual &&
2153 test_cmp expect actual
2156 test_expect_success 'R: in-stream cat-blob-fd not respected' '
2157 echo hello >greeting &&
2158 blob=$(git hash-object -w greeting) &&
2159 cat >expect <<-EOF &&
2164 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2167 test_cmp expect actual.3 &&
2168 test_cmp empty actual.1 &&
2169 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2170 option cat-blob-fd=3
2173 test_cmp empty actual.3 &&
2174 test_cmp expect actual.1
2177 test_expect_success 'R: print new blob' '
2178 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2179 cat >expect <<-EOF &&
2184 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2192 test_cmp expect actual
2195 test_expect_success 'R: print new blob by sha1' '
2196 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2197 cat >expect <<-EOF &&
2199 a new blob named by sha1
2202 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2205 a new blob named by sha1
2209 test_cmp expect actual
2212 test_expect_success 'setup: big file' '
2214 echo "the quick brown fox jumps over the lazy dog" >big &&
2217 cat big big big big >bigger &&
2218 cat bigger bigger bigger bigger >big ||
2224 test_expect_success 'R: print two blobs to stdout' '
2225 blob1=$(git hash-object big) &&
2226 blob1_len=$(wc -c <big) &&
2227 blob2=$(echo hello | git hash-object --stdin) &&
2229 echo ${blob1} blob $blob1_len &&
2239 cat <<-\END_PART1 &&
2256 git fast-import >actual &&
2257 test_cmp expect actual
2260 test_expect_success PIPE 'R: copy using cat-file' '
2261 expect_id=$(git hash-object big) &&
2262 expect_len=$(wc -c <big) &&
2263 echo $expect_id blob $expect_len >expect.response &&
2266 cat >frontend <<-\FRONTEND_END &&
2272 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2285 read blob_id type size <&3 &&
2286 echo "$blob_id $type $size" >response &&
2287 head_c $size >blob <&3 &&
2291 commit refs/heads/copied
2292 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2294 copy big file as file3
2302 git fast-import --cat-blob-fd=3 3>blobs &&
2303 git show copied:file3 >actual &&
2304 test_cmp expect.response response &&
2308 test_expect_success PIPE 'R: print blob mid-commit' '
2310 echo "A blob from _before_ the commit." >expect &&
2319 A blob from _before_ the commit.
2321 commit refs/heads/temporary
2322 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2329 read blob_id type size <&3 &&
2330 head_c $size >actual <&3 &&
2335 git fast-import --cat-blob-fd=3 3>blobs &&
2336 test_cmp expect actual
2339 test_expect_success PIPE 'R: print staged blob within commit' '
2341 echo "A blob from _within_ the commit." >expect &&
2347 commit refs/heads/within
2348 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2354 A blob from _within_ the commit.
2359 echo "A blob from _within_ the commit." |
2360 git hash-object --stdin
2362 echo "cat-blob $to_get" &&
2364 read blob_id type size <&3 &&
2365 head_c $size >actual <&3 &&
2370 git fast-import --cat-blob-fd=3 3>blobs &&
2371 test_cmp expect actual
2382 test_expect_success 'R: quiet option results in no stats being output' '
2383 cat input | git fast-import 2> output &&
2384 test_cmp empty output
2387 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2388 echo feature done | test_must_fail git fast-import &&
2389 test_must_fail git fast-import --done </dev/null
2392 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2393 git fast-import <<-\EOF &&
2398 git fast-import <<-\EOF
2400 more trailing gibberish
2404 test_expect_success 'R: terminating "done" within commit' '
2405 cat >expect <<-\EOF &&
2407 :000000 100644 OBJID OBJID A hello.c
2408 :000000 100644 OBJID OBJID A hello2.c
2410 git fast-import <<-EOF &&
2411 commit refs/heads/done-ends
2412 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2414 Commit terminated by "done" command
2416 M 100644 inline hello.c
2423 git rev-list done-ends |
2424 git diff-tree -r --stdin --root --always |
2425 sed -e "s/$_x40/OBJID/g" >actual &&
2426 test_cmp expect actual
2430 option git non-existing-option
2433 test_expect_success 'R: die on unknown option' '
2434 test_must_fail git fast-import <input
2437 test_expect_success 'R: unknown commandline options are rejected' '\
2438 test_must_fail git fast-import --non-existing-option < /dev/null
2441 test_expect_success 'R: die on invalid option argument' '
2442 echo "option git active-branches=-5" |
2443 test_must_fail git fast-import &&
2444 echo "option git depth=" |
2445 test_must_fail git fast-import &&
2446 test_must_fail git fast-import --depth="5 elephants" </dev/null
2450 option non-existing-vcs non-existing-option
2453 test_expect_success 'R: ignore non-git options' '
2454 git fast-import <input
2458 ## R: very large blobs
2460 blobsize=$((2*1024*1024 + 53))
2461 test-genrandom bar $blobsize >expect
2462 cat >input <<INPUT_END
2463 commit refs/heads/big-file
2464 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2473 cat >>input <<INPUT_END
2480 test_expect_success \
2481 'R: blob bigger than threshold' \
2482 'test_create_repo R &&
2483 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2484 test_expect_success \
2485 'R: verify created pack' \
2487 for p in R/.git/objects/pack/*.pack;
2489 git verify-pack -v $p >>verify || exit;
2491 test_expect_success \
2492 'R: verify written objects' \
2493 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2494 test_cmp expect actual &&
2495 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2496 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2498 test_expect_success \
2499 'R: blob appears only once' \
2500 'n=$(grep $a verify | wc -l) &&