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
100 An annotated tag that annotates a blob.
104 test_expect_success \
105 'A: create pack from stdin' \
106 'git fast-import --export-marks=marks.out <input &&
107 git whatchanged master'
108 test_expect_success \
110 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
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'
255 test_expect_success \
257 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
259 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
261 git diff-tree -M -r master verify--import-marks >actual
262 test_expect_success \
264 'compare_diff_raw expect actual &&
265 test `git rev-parse --verify master:file2` \
266 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
269 mt=$(git hash-object --stdin < /dev/null)
274 cat >input.commit <<EOF
275 commit refs/heads/verify--dump-marks
276 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
278 test the sparse array dumping routines with exponentially growing marks
286 while test "$i" -lt 27; do
287 cat >>input.blob <<EOF
298 echo "M 100644 :$l l$i" >>input.commit
299 echo "M 100644 :$m m$i" >>input.commit
300 echo "M 100644 :$n n$i" >>input.commit
302 echo ":$l $mt" >>marks.exp
303 echo ":$m $mt" >>marks.exp
304 echo ":$n $mt" >>marks.exp
306 printf "100644 blob $mt\tl$i\n" >>tree.exp
307 printf "100644 blob $mt\tm$i\n" >>tree.exp
308 printf "100644 blob $mt\tn$i\n" >>tree.exp
317 sort tree.exp > tree.exp_s
319 test_expect_success 'A: export marks with large values' '
320 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
321 git ls-tree refs/heads/verify--dump-marks >tree.out &&
322 test_cmp tree.exp_s tree.out &&
323 test_cmp marks.exp marks.large'
330 cat >input <<INPUT_END
331 commit refs/heads/branch
333 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
338 from refs/heads/master
339 M 755 0000000000000000000000000000000000000001 zero1
342 test_expect_success 'B: fail on invalid blob sha1' '
343 test_must_fail git fast-import <input
345 rm -f .git/objects/pack_* .git/objects/index_*
347 cat >input <<INPUT_END
348 commit .badbranchname
349 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
354 from refs/heads/master
357 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
358 test_must_fail git fast-import <input
360 rm -f .git/objects/pack_* .git/objects/index_*
362 cat >input <<INPUT_END
363 commit bad[branch]name
364 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
369 from refs/heads/master
372 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
373 test_must_fail git fast-import <input
375 rm -f .git/objects/pack_* .git/objects/index_*
377 cat >input <<INPUT_END
379 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
384 from refs/heads/master
387 test_expect_success \
388 'B: accept branch name "TEMP_TAG"' \
389 'git fast-import <input &&
390 test -f .git/TEMP_TAG &&
391 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
394 git gc 2>/dev/null >/dev/null
395 git prune 2>/dev/null >/dev/null
397 cat >input <<INPUT_END
398 commit refs/heads/empty-committer-1
399 committer <> $GIT_COMMITTER_DATE
404 test_expect_success 'B: accept empty committer' '
405 git fast-import <input &&
410 git update-ref -d refs/heads/empty-committer-1 || true
412 git gc 2>/dev/null >/dev/null
413 git prune 2>/dev/null >/dev/null
415 cat >input <<INPUT_END
416 commit refs/heads/empty-committer-2
417 committer <a@b.com> $GIT_COMMITTER_DATE
422 test_expect_success 'B: accept and fixup committer with no name' '
423 git fast-import <input &&
428 git update-ref -d refs/heads/empty-committer-2 || true
430 git gc 2>/dev/null >/dev/null
431 git prune 2>/dev/null >/dev/null
433 cat >input <<INPUT_END
434 commit refs/heads/invalid-committer
435 committer Name email> $GIT_COMMITTER_DATE
440 test_expect_success 'B: fail on invalid committer (1)' '
441 test_must_fail git fast-import <input
443 git update-ref -d refs/heads/invalid-committer || true
445 cat >input <<INPUT_END
446 commit refs/heads/invalid-committer
447 committer Name <e<mail> $GIT_COMMITTER_DATE
452 test_expect_success 'B: fail on invalid committer (2)' '
453 test_must_fail git fast-import <input
455 git update-ref -d refs/heads/invalid-committer || true
457 cat >input <<INPUT_END
458 commit refs/heads/invalid-committer
459 committer Name <email>> $GIT_COMMITTER_DATE
464 test_expect_success 'B: fail on invalid committer (3)' '
465 test_must_fail git fast-import <input
467 git update-ref -d refs/heads/invalid-committer || true
469 cat >input <<INPUT_END
470 commit refs/heads/invalid-committer
471 committer Name <email $GIT_COMMITTER_DATE
476 test_expect_success 'B: fail on invalid committer (4)' '
477 test_must_fail git fast-import <input
479 git update-ref -d refs/heads/invalid-committer || true
481 cat >input <<INPUT_END
482 commit refs/heads/invalid-committer
483 committer Name<email> $GIT_COMMITTER_DATE
488 test_expect_success 'B: fail on invalid committer (5)' '
489 test_must_fail git fast-import <input
491 git update-ref -d refs/heads/invalid-committer || true
497 newf=`echo hi newf | git hash-object -w --stdin`
498 oldf=`git rev-parse --verify master:file2`
500 cat >input <<INPUT_END
501 commit refs/heads/branch
502 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
507 from refs/heads/master
508 M 644 $oldf file2/oldf
509 M 755 $newf file2/newf
513 test_expect_success \
514 'C: incremental import create pack from stdin' \
515 'git fast-import <input &&
516 git whatchanged branch'
517 test_expect_success \
519 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
520 test_expect_success \
521 'C: validate reuse existing blob' \
522 'test $newf = `git rev-parse --verify branch:file2/newf` &&
523 test $oldf = `git rev-parse --verify branch:file2/oldf`'
526 parent `git rev-parse --verify master^0`
527 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
528 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
532 test_expect_success \
534 'git cat-file commit branch | sed 1d >actual &&
535 test_cmp expect actual'
538 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
539 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
540 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
542 git diff-tree -M -r master branch >actual
543 test_expect_success \
544 'C: validate rename result' \
545 'compare_diff_raw expect actual'
552 cat >input <<INPUT_END
553 commit refs/heads/branch
554 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
559 from refs/heads/branch^0
560 M 644 inline newdir/interesting
565 M 755 inline newdir/exec.sh
571 test_expect_success \
572 'D: inline data in commit' \
573 'git fast-import <input &&
574 git whatchanged branch'
575 test_expect_success \
577 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
580 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
581 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
583 git diff-tree -M -r branch^ branch >actual
584 test_expect_success \
585 'D: validate new files added' \
586 'compare_diff_raw expect actual'
588 echo "$file5_data" >expect
589 test_expect_success \
591 'git cat-file blob branch:newdir/interesting >actual &&
592 test_cmp expect actual'
594 echo "$file6_data" >expect
595 test_expect_success \
597 'git cat-file blob branch:newdir/exec.sh >actual &&
598 test_cmp expect actual'
604 cat >input <<INPUT_END
605 commit refs/heads/branch
606 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
607 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
612 from refs/heads/branch^0
615 test_expect_success 'E: rfc2822 date, --date-format=raw' '
616 test_must_fail git fast-import --date-format=raw <input
618 test_expect_success \
619 'E: rfc2822 date, --date-format=rfc2822' \
620 'git fast-import --date-format=rfc2822 <input'
621 test_expect_success \
623 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
626 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
627 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
631 test_expect_success \
633 'git cat-file commit branch | sed 1,2d >actual &&
634 test_cmp expect actual'
640 old_branch=`git rev-parse --verify branch^0`
642 cat >input <<INPUT_END
643 commit refs/heads/branch
644 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
646 losing things already?
649 from refs/heads/branch~1
651 reset refs/heads/other
652 from refs/heads/branch
655 test_expect_success \
656 'F: non-fast-forward update skips' \
657 'if git fast-import <input
659 echo BAD gfi did not fail
662 if test $old_branch = `git rev-parse --verify branch^0`
664 : branch unaffected and failure returned
667 echo BAD gfi changed branch $old_branch
672 test_expect_success \
674 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
677 tree `git rev-parse branch~1^{tree}`
678 parent `git rev-parse branch~1`
679 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
680 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
682 losing things already?
684 test_expect_success \
685 'F: verify other commit' \
686 'git cat-file commit other >actual &&
687 test_cmp expect actual'
693 old_branch=`git rev-parse --verify branch^0`
695 cat >input <<INPUT_END
696 commit refs/heads/branch
697 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
699 losing things already?
702 from refs/heads/branch~1
705 test_expect_success \
706 'G: non-fast-forward update forced' \
707 'git fast-import --force <input'
708 test_expect_success \
710 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
711 test_expect_success \
712 'G: branch changed, but logged' \
713 'test $old_branch != `git rev-parse --verify branch^0` &&
714 test $old_branch = `git rev-parse --verify branch@{1}`'
721 cat >input <<INPUT_END
723 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
728 from refs/heads/branch^0
729 M 644 inline i-will-die
731 this file will never exist.
735 M 644 inline h/e/l/lo
741 test_expect_success \
742 'H: deletall, add 1' \
743 'git fast-import <input &&
745 test_expect_success \
747 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
750 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
751 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
752 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
753 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
754 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
756 git diff-tree -M -r H^ H >actual
757 test_expect_success \
758 'H: validate old files removed, new files added' \
759 'compare_diff_raw expect actual'
761 echo "$file5_data" >expect
762 test_expect_success \
764 'git cat-file blob H:h/e/l/lo >actual &&
765 test_cmp expect actual'
771 cat >input <<INPUT_END
772 commit refs/heads/export-boundary
773 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
775 we have a border. its only 40 characters wide.
778 from refs/heads/branch
781 test_expect_success \
782 'I: export-pack-edges' \
783 'git fast-import --export-pack-edges=edges.list <input'
786 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
788 test_expect_success \
789 'I: verify edge list' \
790 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
791 test_cmp expect actual'
797 cat >input <<INPUT_END
799 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
804 from refs/heads/branch
809 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
815 test_expect_success \
816 'J: reset existing branch creates empty commit' \
817 'git fast-import <input'
818 test_expect_success \
819 'J: branch has 1 commit, empty tree' \
820 'test 1 = `git rev-list J | wc -l` &&
821 test 0 = `git ls-tree J | wc -l`'
823 cat >input <<INPUT_END
829 Tag branch that was reset.
832 test_expect_success \
833 'J: tag must fail on empty branch' \
834 'test_must_fail git fast-import <input'
839 cat >input <<INPUT_END
841 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
846 from refs/heads/branch
849 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
854 from refs/heads/branch^1
857 test_expect_success \
858 'K: reinit branch with from' \
859 'git fast-import <input'
860 test_expect_success \
861 'K: verify K^1 = branch^1' \
862 'test `git rev-parse --verify branch^1` \
863 = `git rev-parse --verify K^1`'
869 cat >input <<INPUT_END
883 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
893 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
903 cat >expect <<EXPECT_END
904 :100644 100644 4268632... 55d3a52... M b.
905 :040000 040000 0ae5cac... 443c768... M b
906 :100644 100644 4268632... 55d3a52... M ba
909 test_expect_success \
910 'L: verify internal tree sorting' \
911 'git fast-import <input &&
912 git diff-tree --abbrev --raw L^ L >output &&
913 test_cmp expect output'
915 cat >input <<INPUT_END
923 committer C O Mitter <committer@example.com> 1112912473 -0700
932 committer C O Mitter <committer@example.com> 1112912473 -0700
946 test_expect_success \
947 'L: nested tree copy does not corrupt deltas' \
948 'git fast-import <input &&
949 git ls-tree L2 g/b/ >tmp &&
950 cat tmp | cut -f 2 >actual &&
951 test_cmp expect actual &&
952 git fsck `git rev-parse L2`'
954 git update-ref -d refs/heads/L2
961 cat >input <<INPUT_END
963 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
968 from refs/heads/branch^0
969 R file2/newf file2/n.e.w.f
974 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
976 test_expect_success \
977 'M: rename file in same subdirectory' \
978 'git fast-import <input &&
979 git diff-tree -M -r M1^ M1 >actual &&
980 compare_diff_raw expect actual'
982 cat >input <<INPUT_END
984 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
989 from refs/heads/branch^0
990 R file2/newf i/am/new/to/you
995 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
997 test_expect_success \
998 'M: rename file to new subdirectory' \
999 'git fast-import <input &&
1000 git diff-tree -M -r M2^ M2 >actual &&
1001 compare_diff_raw expect actual'
1003 cat >input <<INPUT_END
1004 commit refs/heads/M3
1005 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1010 from refs/heads/M2^0
1016 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1018 test_expect_success \
1019 'M: rename subdirectory to new subdirectory' \
1020 'git fast-import <input &&
1021 git diff-tree -M -r M3^ M3 >actual &&
1022 compare_diff_raw expect actual'
1029 cat >input <<INPUT_END
1030 commit refs/heads/N1
1031 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1036 from refs/heads/branch^0
1037 C file2/newf file2/n.e.w.f
1042 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1044 test_expect_success \
1045 'N: copy file in same subdirectory' \
1046 'git fast-import <input &&
1047 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1048 compare_diff_raw expect actual'
1050 cat >input <<INPUT_END
1051 commit refs/heads/N2
1052 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1054 clean directory copy
1057 from refs/heads/branch^0
1060 commit refs/heads/N2
1061 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1063 modify directory copy
1066 M 644 inline file3/file5
1074 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1075 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1076 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1078 test_expect_success \
1079 'N: copy then modify subdirectory' \
1080 'git fast-import <input &&
1081 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1082 compare_diff_raw expect actual'
1084 cat >input <<INPUT_END
1085 commit refs/heads/N3
1086 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1088 dirty directory copy
1091 from refs/heads/branch^0
1092 M 644 inline file2/file5
1102 test_expect_success \
1103 'N: copy dirty subdirectory' \
1104 'git fast-import <input &&
1105 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
1107 test_expect_success \
1108 'N: copy directory by id' \
1109 'cat >expect <<-\EOF &&
1110 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1111 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1113 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1114 cat >input <<-INPUT_END &&
1115 commit refs/heads/N4
1116 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1121 from refs/heads/branch^0
1122 M 040000 $subdir file3
1124 git fast-import <input &&
1125 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1126 compare_diff_raw expect actual'
1128 test_expect_success PIPE 'N: read and copy directory' '
1130 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1131 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1133 git update-ref -d refs/heads/N4 &&
1139 commit refs/heads/N4
1140 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1142 copy by tree hash, part 2
1145 from refs/heads/branch^0
1148 read mode type tree filename &&
1149 echo "M 040000 $tree file3"
1151 git fast-import --cat-blob-fd=3 3>backflow &&
1152 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1153 compare_diff_raw expect actual
1156 test_expect_success PIPE 'N: empty directory reads as missing' '
1157 cat <<-\EOF >expect &&
1159 :000000 100644 OBJNAME OBJNAME A unrelated
1161 echo "missing src" >expect.response &&
1162 git update-ref -d refs/heads/read-empty &&
1168 commit refs/heads/read-empty
1169 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1171 read "empty" (missing) directory
1174 M 100644 inline src/greeting
1178 C src/greeting dst1/non-greeting
1179 C src/greeting unrelated
1180 # leave behind "empty" src directory
1185 printf "%s\n" "$line" >response &&
1191 git fast-import --cat-blob-fd=3 3>backflow &&
1192 test_cmp expect.response response &&
1193 git rev-list read-empty |
1194 git diff-tree -r --root --stdin |
1195 sed "s/$_x40/OBJNAME/g" >actual &&
1196 test_cmp expect actual
1199 test_expect_success \
1200 'N: copy root directory by tree hash' \
1201 'cat >expect <<-\EOF &&
1202 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1203 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1205 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1206 cat >input <<-INPUT_END &&
1207 commit refs/heads/N6
1208 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1210 copy root directory by tree hash
1213 from refs/heads/branch^0
1216 git fast-import <input &&
1217 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1218 compare_diff_raw expect actual'
1220 test_expect_success \
1221 'N: delete directory by copying' \
1222 'cat >expect <<-\EOF &&
1224 :100644 000000 OBJID OBJID D foo/bar/qux
1226 :000000 100644 OBJID OBJID A foo/bar/baz
1227 :000000 100644 OBJID OBJID A foo/bar/qux
1229 empty_tree=$(git mktree </dev/null) &&
1230 cat >input <<-INPUT_END &&
1231 commit refs/heads/N-delete
1232 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1234 collect data to be deleted
1238 M 100644 inline foo/bar/baz
1242 C "foo/bar/baz" "foo/bar/qux"
1243 C "foo/bar/baz" "foo/bar/quux/1"
1244 C "foo/bar/baz" "foo/bar/quuux"
1245 M 040000 $empty_tree foo/bar/quux
1246 M 040000 $empty_tree foo/bar/quuux
1248 commit refs/heads/N-delete
1249 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1254 M 040000 $empty_tree foo/bar/qux
1256 git fast-import <input &&
1257 git rev-list N-delete |
1258 git diff-tree -r --stdin --root --always |
1259 sed -e "s/$_x40/OBJID/g" >actual &&
1260 test_cmp expect actual'
1262 test_expect_success \
1263 'N: modify copied tree' \
1264 'cat >expect <<-\EOF &&
1265 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1266 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1267 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1269 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1270 cat >input <<-INPUT_END &&
1271 commit refs/heads/N5
1272 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1277 from refs/heads/branch^0
1278 M 040000 $subdir file3
1280 commit refs/heads/N5
1281 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1283 modify directory copy
1286 M 644 inline file3/file5
1291 git fast-import <input &&
1292 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1293 compare_diff_raw expect actual'
1295 test_expect_success \
1296 'N: reject foo/ syntax' \
1297 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1298 test_must_fail git fast-import <<-INPUT_END
1299 commit refs/heads/N5B
1300 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1302 copy with invalid syntax
1305 from refs/heads/branch^0
1306 M 040000 $subdir file3/
1309 test_expect_success \
1310 'N: reject foo/ syntax in copy source' \
1311 'test_must_fail git fast-import <<-INPUT_END
1312 commit refs/heads/N5C
1313 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1315 copy with invalid syntax
1318 from refs/heads/branch^0
1322 test_expect_success \
1323 'N: reject foo/ syntax in rename source' \
1324 'test_must_fail git fast-import <<-INPUT_END
1325 commit refs/heads/N5D
1326 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1328 rename with invalid syntax
1331 from refs/heads/branch^0
1335 test_expect_success \
1336 'N: reject foo/ syntax in ls argument' \
1337 'test_must_fail git fast-import <<-INPUT_END
1338 commit refs/heads/N5E
1339 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1341 copy with invalid syntax
1344 from refs/heads/branch^0
1348 test_expect_success \
1349 'N: copy to root by id and modify' \
1350 'echo "hello, world" >expect.foo &&
1351 echo hello >expect.bar &&
1352 git fast-import <<-SETUP_END &&
1353 commit refs/heads/N7
1354 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1360 M 644 inline foo/bar
1366 tree=$(git rev-parse --verify N7:) &&
1367 git fast-import <<-INPUT_END &&
1368 commit refs/heads/N8
1369 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1371 copy to root by id and modify
1375 M 644 inline foo/foo
1380 git show N8:foo/foo >actual.foo &&
1381 git show N8:foo/bar >actual.bar &&
1382 test_cmp expect.foo actual.foo &&
1383 test_cmp expect.bar actual.bar'
1385 test_expect_success \
1386 'N: extract subtree' \
1387 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1388 cat >input <<-INPUT_END &&
1389 commit refs/heads/N9
1390 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1392 extract subtree branch:newdir
1398 git fast-import <input &&
1399 git diff --exit-code branch:newdir N9'
1401 test_expect_success \
1402 'N: modify subtree, extract it, and modify again' \
1403 'echo hello >expect.baz &&
1404 echo hello, world >expect.qux &&
1405 git fast-import <<-SETUP_END &&
1406 commit refs/heads/N10
1407 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1413 M 644 inline foo/bar/baz
1419 tree=$(git rev-parse --verify N10:) &&
1420 git fast-import <<-INPUT_END &&
1421 commit refs/heads/N11
1422 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1424 copy to root by id and modify
1428 M 100644 inline foo/bar/qux
1433 C "bar/qux" "bar/quux"
1435 git show N11:bar/baz >actual.baz &&
1436 git show N11:bar/qux >actual.qux &&
1437 git show N11:bar/quux >actual.quux &&
1438 test_cmp expect.baz actual.baz &&
1439 test_cmp expect.qux actual.qux &&
1440 test_cmp expect.qux actual.quux'
1446 cat >input <<INPUT_END
1448 commit refs/heads/O1
1449 # -- ignore all of this text
1450 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1451 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1453 dirty directory copy
1456 # don't forget the import blank line!
1458 # yes, we started from our usual base of branch^0.
1460 from refs/heads/branch^0
1461 # and we need to reuse file2/file5 from N3 above.
1462 M 644 inline file2/file5
1463 # otherwise the tree will be different
1468 # don't forget to copy file2 to file3
1471 # or to delete file5 from file2.
1477 test_expect_success \
1478 'O: comments are all skipped' \
1479 'git fast-import <input &&
1480 test `git rev-parse N3` = `git rev-parse O1`'
1482 cat >input <<INPUT_END
1483 commit refs/heads/O2
1484 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1486 dirty directory copy
1488 from refs/heads/branch^0
1489 M 644 inline file2/file5
1498 test_expect_success \
1499 'O: blank lines not necessary after data commands' \
1500 'git fast-import <input &&
1501 test `git rev-parse N3` = `git rev-parse O2`'
1503 test_expect_success \
1504 'O: repack before next test' \
1507 cat >input <<INPUT_END
1508 commit refs/heads/O3
1509 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1513 commit refs/heads/O3
1514 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1519 commit refs/heads/O3
1521 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1526 commit refs/heads/O3
1527 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1531 reset refs/tags/O3-2nd
1533 reset refs/tags/O3-3rd
1537 cat >expect <<INPUT_END
1543 test_expect_success \
1544 'O: blank lines not necessary after other commands' \
1545 'git fast-import <input &&
1546 test 8 = `find .git/objects/pack -type f | wc -l` &&
1547 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1548 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1549 test_cmp expect actual'
1551 cat >input <<INPUT_END
1552 commit refs/heads/O4
1553 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1557 commit refs/heads/O4
1558 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1562 progress Two commits down, 2 to go!
1563 commit refs/heads/O4
1564 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1568 progress Three commits down, 1 to go!
1569 commit refs/heads/O4
1570 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1576 test_expect_success \
1577 'O: progress outputs as requested by input' \
1578 'git fast-import <input >actual &&
1579 grep "progress " <input >expect &&
1580 test_cmp expect actual'
1583 ### series P (gitlinks)
1586 cat >input <<INPUT_END
1592 reset refs/heads/sub
1593 commit refs/heads/sub
1595 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1608 commit refs/heads/subuse1
1610 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1613 from refs/heads/master
1614 M 100644 :3 .gitmodules
1623 commit refs/heads/sub
1625 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1631 commit refs/heads/subuse1
1633 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1641 test_expect_success \
1642 'P: supermodule & submodule mix' \
1643 'git fast-import <input &&
1644 git checkout subuse1 &&
1645 rm -rf sub && mkdir sub && (cd sub &&
1647 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1648 git checkout master) &&
1649 git submodule init &&
1650 git submodule update'
1652 SUBLAST=$(git rev-parse --verify sub)
1653 SUBPREV=$(git rev-parse --verify sub^)
1655 cat >input <<INPUT_END
1664 commit refs/heads/subuse2
1666 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1669 from refs/heads/master
1670 M 100644 :1 .gitmodules
1671 M 160000 $SUBPREV sub
1673 commit refs/heads/subuse2
1675 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1679 M 160000 $SUBLAST sub
1683 test_expect_success \
1684 'P: verbatim SHA gitlinks' \
1685 'git branch -D sub &&
1686 git gc && git prune &&
1687 git fast-import <input &&
1688 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1691 cat >input <<INPUT_END
1692 commit refs/heads/subuse3
1694 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1699 from refs/heads/subuse2
1707 test_expect_success 'P: fail on inline gitlink' '
1708 test_must_fail git fast-import <input'
1711 cat >input <<INPUT_END
1718 commit refs/heads/subuse3
1720 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1725 from refs/heads/subuse2
1730 test_expect_success 'P: fail on blob mark in gitlink' '
1731 test_must_fail git fast-import <input'
1734 ### series Q (notes)
1737 note1_data="The first note for the first commit"
1738 note2_data="The first note for the second commit"
1739 note3_data="The first note for the third commit"
1740 note1b_data="The second note for the first commit"
1741 note1c_data="The third note for the first commit"
1742 note2b_data="The second note for the second commit"
1745 cat >input <<INPUT_END
1752 commit refs/heads/notes-test
1754 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1765 commit refs/heads/notes-test
1767 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1774 commit refs/heads/notes-test
1776 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1803 commit refs/notes/foobar
1805 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1817 commit refs/notes/foobar
1819 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1829 commit refs/notes/foobar2
1831 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1841 commit refs/notes/foobar
1843 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1856 test_expect_success \
1858 'git fast-import <input &&
1859 git whatchanged notes-test'
1860 test_expect_success \
1862 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1864 commit1=$(git rev-parse notes-test~2)
1865 commit2=$(git rev-parse notes-test^)
1866 commit3=$(git rev-parse notes-test)
1869 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1870 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1874 test_expect_success \
1875 'Q: verify first commit' \
1876 'git cat-file commit notes-test~2 | sed 1d >actual &&
1877 test_cmp expect actual'
1881 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1882 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1886 test_expect_success \
1887 'Q: verify second commit' \
1888 'git cat-file commit notes-test^ | sed 1d >actual &&
1889 test_cmp expect actual'
1893 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1894 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1898 test_expect_success \
1899 'Q: verify third commit' \
1900 'git cat-file commit notes-test | sed 1d >actual &&
1901 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 first notes commit' \
1911 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1912 test_cmp expect actual'
1914 cat >expect.unsorted <<EOF
1915 100644 blob $commit1
1916 100644 blob $commit2
1917 100644 blob $commit3
1919 cat expect.unsorted | sort >expect
1920 test_expect_success \
1921 'Q: verify first notes tree' \
1922 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1923 test_cmp expect actual'
1925 echo "$note1_data" >expect
1926 test_expect_success \
1927 'Q: verify first note for first commit' \
1928 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1930 echo "$note2_data" >expect
1931 test_expect_success \
1932 'Q: verify first note for second commit' \
1933 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1935 echo "$note3_data" >expect
1936 test_expect_success \
1937 'Q: verify first note for third commit' \
1938 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1941 parent `git rev-parse --verify refs/notes/foobar~2`
1942 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1943 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1947 test_expect_success \
1948 'Q: verify second notes commit' \
1949 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1950 test_cmp expect actual'
1952 cat >expect.unsorted <<EOF
1953 100644 blob $commit1
1954 100644 blob $commit2
1955 100644 blob $commit3
1957 cat expect.unsorted | sort >expect
1958 test_expect_success \
1959 'Q: verify second notes tree' \
1960 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1961 test_cmp expect actual'
1963 echo "$note1b_data" >expect
1964 test_expect_success \
1965 'Q: verify second note for first commit' \
1966 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1968 echo "$note2_data" >expect
1969 test_expect_success \
1970 'Q: verify first note for second commit' \
1971 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1973 echo "$note3_data" >expect
1974 test_expect_success \
1975 'Q: verify first note for third commit' \
1976 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1979 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1980 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1984 test_expect_success \
1985 'Q: verify third notes commit' \
1986 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1987 test_cmp expect actual'
1989 cat >expect.unsorted <<EOF
1990 100644 blob $commit1
1992 cat expect.unsorted | sort >expect
1993 test_expect_success \
1994 'Q: verify third notes tree' \
1995 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1996 test_cmp expect actual'
1998 echo "$note1c_data" >expect
1999 test_expect_success \
2000 'Q: verify third note for first commit' \
2001 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
2004 parent `git rev-parse --verify refs/notes/foobar^`
2005 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2006 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2010 test_expect_success \
2011 'Q: verify fourth notes commit' \
2012 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
2013 test_cmp expect actual'
2015 cat >expect.unsorted <<EOF
2016 100644 blob $commit2
2018 cat expect.unsorted | sort >expect
2019 test_expect_success \
2020 'Q: verify fourth notes tree' \
2021 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2022 test_cmp expect actual'
2024 echo "$note2b_data" >expect
2025 test_expect_success \
2026 'Q: verify second note for second commit' \
2027 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
2032 commit refs/heads/note-Q0
2033 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2035 Note for an empty branch.
2038 N inline refs/heads/Q0
2043 test_expect_success \
2044 'Q: deny note on empty branch' \
2045 'test_must_fail git fast-import <input'
2047 ### series R (feature and option)
2051 feature no-such-feature-exists
2054 test_expect_success 'R: abort on unsupported feature' '
2055 test_must_fail git fast-import <input
2059 feature date-format=now
2062 test_expect_success 'R: supported feature is accepted' '
2063 git fast-import <input
2070 feature date-format=now
2073 test_expect_success 'R: abort on receiving feature after data command' '
2074 test_must_fail git fast-import <input
2078 feature import-marks=git.marks
2079 feature import-marks=git2.marks
2082 test_expect_success 'R: only one import-marks feature allowed per stream' '
2083 test_must_fail git fast-import <input
2087 feature export-marks=git.marks
2095 test_expect_success \
2096 'R: export-marks feature results in a marks file being created' \
2097 'cat input | git fast-import &&
2100 test_expect_success \
2101 'R: export-marks options can be overriden by commandline options' \
2102 'cat input | git fast-import --export-marks=other.marks &&
2103 grep :1 other.marks'
2105 test_expect_success 'R: catch typo in marks file name' '
2106 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2107 echo "feature import-marks=nonexistent.marks" |
2108 test_must_fail git fast-import
2111 test_expect_success 'R: import and output marks can be the same file' '
2113 blob=$(echo hi | git hash-object --stdin) &&
2114 cat >expect <<-EOF &&
2118 git fast-import --export-marks=io.marks <<-\EOF &&
2125 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2132 test_cmp expect io.marks
2135 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2137 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2146 test_expect_success 'R: --import-marks-if-exists' '
2148 blob=$(echo hi | git hash-object --stdin) &&
2149 echo ":1 $blob" >expect &&
2150 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2157 test_cmp expect io.marks
2160 test_expect_success 'R: feature import-marks-if-exists' '
2164 git fast-import --export-marks=io.marks <<-\EOF &&
2165 feature import-marks-if-exists=not_io.marks
2167 test_cmp expect io.marks &&
2169 blob=$(echo hi | git hash-object --stdin) &&
2171 echo ":1 $blob" >io.marks &&
2172 echo ":1 $blob" >expect &&
2173 echo ":2 $blob" >>expect &&
2175 git fast-import --export-marks=io.marks <<-\EOF &&
2176 feature import-marks-if-exists=io.marks
2183 test_cmp expect io.marks &&
2185 echo ":3 $blob" >>expect &&
2187 git fast-import --import-marks=io.marks \
2188 --export-marks=io.marks <<-\EOF &&
2189 feature import-marks-if-exists=not_io.marks
2196 test_cmp expect io.marks &&
2200 git fast-import --import-marks-if-exists=not_io.marks \
2201 --export-marks=io.marks <<-\EOF
2202 feature import-marks-if-exists=io.marks
2204 test_cmp expect io.marks
2208 feature import-marks=marks.out
2209 feature export-marks=marks.new
2212 test_expect_success \
2213 'R: import to output marks works without any content' \
2214 'cat input | git fast-import &&
2215 test_cmp marks.out marks.new'
2218 feature import-marks=nonexistent.marks
2219 feature export-marks=marks.new
2222 test_expect_success \
2223 'R: import marks prefers commandline marks file over the stream' \
2224 'cat input | git fast-import --import-marks=marks.out &&
2225 test_cmp marks.out marks.new'
2229 feature import-marks=nonexistent.marks
2230 feature export-marks=combined.marks
2233 test_expect_success 'R: multiple --import-marks= should be honoured' '
2234 head -n2 marks.out > one.marks &&
2235 tail -n +3 marks.out > two.marks &&
2236 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2237 test_cmp marks.out combined.marks
2241 feature relative-marks
2242 feature import-marks=relative.in
2243 feature export-marks=relative.out
2246 test_expect_success 'R: feature relative-marks should be honoured' '
2247 mkdir -p .git/info/fast-import/ &&
2248 cp marks.new .git/info/fast-import/relative.in &&
2249 git fast-import <input &&
2250 test_cmp marks.new .git/info/fast-import/relative.out
2254 feature relative-marks
2255 feature import-marks=relative.in
2256 feature no-relative-marks
2257 feature export-marks=non-relative.out
2260 test_expect_success 'R: feature no-relative-marks should be honoured' '
2261 git fast-import <input &&
2262 test_cmp marks.new non-relative.out
2265 test_expect_success 'R: feature ls supported' '
2270 test_expect_success 'R: feature cat-blob supported' '
2271 echo "feature cat-blob" |
2275 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2276 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2279 test_expect_success NOT_MINGW 'R: print old blob' '
2280 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2281 cat >expect <<-EOF &&
2286 echo "cat-blob $blob" |
2287 git fast-import --cat-blob-fd=6 6>actual &&
2288 test_cmp expect actual
2291 test_expect_success NOT_MINGW 'R: in-stream cat-blob-fd not respected' '
2292 echo hello >greeting &&
2293 blob=$(git hash-object -w greeting) &&
2294 cat >expect <<-EOF &&
2299 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2302 test_cmp expect actual.3 &&
2303 test_cmp empty actual.1 &&
2304 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2305 option cat-blob-fd=3
2308 test_cmp empty actual.3 &&
2309 test_cmp expect actual.1
2312 test_expect_success NOT_MINGW 'R: print new blob' '
2313 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2314 cat >expect <<-EOF &&
2319 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2327 test_cmp expect actual
2330 test_expect_success NOT_MINGW 'R: print new blob by sha1' '
2331 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2332 cat >expect <<-EOF &&
2334 a new blob named by sha1
2337 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2340 a new blob named by sha1
2344 test_cmp expect actual
2347 test_expect_success 'setup: big file' '
2349 echo "the quick brown fox jumps over the lazy dog" >big &&
2352 cat big big big big >bigger &&
2353 cat bigger bigger bigger bigger >big ||
2359 test_expect_success 'R: print two blobs to stdout' '
2360 blob1=$(git hash-object big) &&
2361 blob1_len=$(wc -c <big) &&
2362 blob2=$(echo hello | git hash-object --stdin) &&
2364 echo ${blob1} blob $blob1_len &&
2374 cat <<-\END_PART1 &&
2391 git fast-import >actual &&
2392 test_cmp expect actual
2395 test_expect_success PIPE 'R: copy using cat-file' '
2396 expect_id=$(git hash-object big) &&
2397 expect_len=$(wc -c <big) &&
2398 echo $expect_id blob $expect_len >expect.response &&
2401 cat >frontend <<-\FRONTEND_END &&
2407 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2420 read blob_id type size <&3 &&
2421 echo "$blob_id $type $size" >response &&
2422 head_c $size >blob <&3 &&
2426 commit refs/heads/copied
2427 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2429 copy big file as file3
2437 git fast-import --cat-blob-fd=3 3>blobs &&
2438 git show copied:file3 >actual &&
2439 test_cmp expect.response response &&
2443 test_expect_success PIPE 'R: print blob mid-commit' '
2445 echo "A blob from _before_ the commit." >expect &&
2454 A blob from _before_ the commit.
2456 commit refs/heads/temporary
2457 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2464 read blob_id type size <&3 &&
2465 head_c $size >actual <&3 &&
2470 git fast-import --cat-blob-fd=3 3>blobs &&
2471 test_cmp expect actual
2474 test_expect_success PIPE 'R: print staged blob within commit' '
2476 echo "A blob from _within_ the commit." >expect &&
2482 commit refs/heads/within
2483 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2489 A blob from _within_ the commit.
2494 echo "A blob from _within_ the commit." |
2495 git hash-object --stdin
2497 echo "cat-blob $to_get" &&
2499 read blob_id type size <&3 &&
2500 head_c $size >actual <&3 &&
2505 git fast-import --cat-blob-fd=3 3>blobs &&
2506 test_cmp expect actual
2517 test_expect_success 'R: quiet option results in no stats being output' '
2518 cat input | git fast-import 2> output &&
2519 test_cmp empty output
2522 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2523 echo feature done | test_must_fail git fast-import &&
2524 test_must_fail git fast-import --done </dev/null
2527 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2528 git fast-import <<-\EOF &&
2533 git fast-import <<-\EOF
2535 more trailing gibberish
2539 test_expect_success 'R: terminating "done" within commit' '
2540 cat >expect <<-\EOF &&
2542 :000000 100644 OBJID OBJID A hello.c
2543 :000000 100644 OBJID OBJID A hello2.c
2545 git fast-import <<-EOF &&
2546 commit refs/heads/done-ends
2547 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2549 Commit terminated by "done" command
2551 M 100644 inline hello.c
2558 git rev-list done-ends |
2559 git diff-tree -r --stdin --root --always |
2560 sed -e "s/$_x40/OBJID/g" >actual &&
2561 test_cmp expect actual
2565 option git non-existing-option
2568 test_expect_success 'R: die on unknown option' '
2569 test_must_fail git fast-import <input
2572 test_expect_success 'R: unknown commandline options are rejected' '\
2573 test_must_fail git fast-import --non-existing-option < /dev/null
2576 test_expect_success 'R: die on invalid option argument' '
2577 echo "option git active-branches=-5" |
2578 test_must_fail git fast-import &&
2579 echo "option git depth=" |
2580 test_must_fail git fast-import &&
2581 test_must_fail git fast-import --depth="5 elephants" </dev/null
2585 option non-existing-vcs non-existing-option
2588 test_expect_success 'R: ignore non-git options' '
2589 git fast-import <input
2593 ## R: very large blobs
2595 blobsize=$((2*1024*1024 + 53))
2596 test-genrandom bar $blobsize >expect
2597 cat >input <<INPUT_END
2598 commit refs/heads/big-file
2599 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2608 cat >>input <<INPUT_END
2615 test_expect_success \
2616 'R: blob bigger than threshold' \
2617 'test_create_repo R &&
2618 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2619 test_expect_success \
2620 'R: verify created pack' \
2622 for p in R/.git/objects/pack/*.pack;
2624 git verify-pack -v $p >>verify || exit;
2626 test_expect_success \
2627 'R: verify written objects' \
2628 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2629 test_cmp expect actual &&
2630 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2631 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2633 test_expect_success \
2634 'R: blob appears only once' \
2635 'n=$(grep $a verify | wc -l) &&