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
20 file5_data='an inline file.
21 we should see it later.'
31 cat >input <<INPUT_END
48 commit refs/heads/master
50 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
62 An annotated tag without a tagger
67 'A: create pack from stdin' \
68 'git fast-import --export-marks=marks.out <input &&
69 git whatchanged master'
72 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
75 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
76 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
82 'git cat-file commit master | sed 1d >actual &&
83 test_cmp expect actual'
92 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
93 test_cmp expect actual'
95 echo "$file2_data" >expect
98 'git cat-file blob master:file2 >actual && test_cmp expect actual'
100 echo "$file3_data" >expect
101 test_expect_success \
103 'git cat-file blob master:file3 >actual && test_cmp expect actual'
105 printf "$file4_data" >expect
106 test_expect_success \
108 'git cat-file blob master:file4 >actual && test_cmp expect actual'
111 object $(git rev-parse refs/heads/master)
115 An annotated tag without a tagger
117 test_expect_success 'A: verify tag/series-A' '
118 git cat-file tag tags/series-A >actual &&
119 test_cmp expect actual
123 :2 `git rev-parse --verify master:file2`
124 :3 `git rev-parse --verify master:file3`
125 :4 `git rev-parse --verify master:file4`
126 :5 `git rev-parse --verify master^0`
128 test_expect_success \
129 'A: verify marks output' \
130 'test_cmp expect marks.out'
132 test_expect_success \
133 'A: verify marks import' \
135 --import-marks=marks.out \
136 --export-marks=marks.new \
138 test_cmp expect marks.new'
141 cat >input <<INPUT_END
142 commit refs/heads/verify--import-marks
143 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
149 M 755 :2 copy-of-file2
152 test_expect_success \
153 'A: verify marks import does not crash' \
154 'git fast-import --import-marks=marks.out <input &&
155 git whatchanged verify--import-marks'
156 test_expect_success \
158 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
160 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
162 git diff-tree -M -r master verify--import-marks >actual
163 test_expect_success \
165 'compare_diff_raw expect actual &&
166 test `git rev-parse --verify master:file2` \
167 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
170 mt=$(git hash-object --stdin < /dev/null)
175 cat >input.commit <<EOF
176 commit refs/heads/verify--dump-marks
177 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
179 test the sparse array dumping routines with exponentially growing marks
187 while test "$i" -lt 27; do
188 cat >>input.blob <<EOF
199 echo "M 100644 :$l l$i" >>input.commit
200 echo "M 100644 :$m m$i" >>input.commit
201 echo "M 100644 :$n n$i" >>input.commit
203 echo ":$l $mt" >>marks.exp
204 echo ":$m $mt" >>marks.exp
205 echo ":$n $mt" >>marks.exp
207 printf "100644 blob $mt\tl$i\n" >>tree.exp
208 printf "100644 blob $mt\tm$i\n" >>tree.exp
209 printf "100644 blob $mt\tn$i\n" >>tree.exp
218 sort tree.exp > tree.exp_s
220 test_expect_success 'A: export marks with large values' '
221 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
222 git ls-tree refs/heads/verify--dump-marks >tree.out &&
223 test_cmp tree.exp_s tree.out &&
224 test_cmp marks.exp marks.large'
231 cat >input <<INPUT_END
232 commit refs/heads/branch
234 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
239 from refs/heads/master
240 M 755 0000000000000000000000000000000000000001 zero1
243 test_expect_success 'B: fail on invalid blob sha1' '
244 test_must_fail git fast-import <input
246 rm -f .git/objects/pack_* .git/objects/index_*
248 cat >input <<INPUT_END
249 commit .badbranchname
250 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
255 from refs/heads/master
258 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
259 test_must_fail git fast-import <input
261 rm -f .git/objects/pack_* .git/objects/index_*
263 cat >input <<INPUT_END
264 commit bad[branch]name
265 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
270 from refs/heads/master
273 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
274 test_must_fail git fast-import <input
276 rm -f .git/objects/pack_* .git/objects/index_*
278 cat >input <<INPUT_END
280 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
285 from refs/heads/master
288 test_expect_success \
289 'B: accept branch name "TEMP_TAG"' \
290 'git fast-import <input &&
291 test -f .git/TEMP_TAG &&
292 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
299 newf=`echo hi newf | git hash-object -w --stdin`
300 oldf=`git rev-parse --verify master:file2`
302 cat >input <<INPUT_END
303 commit refs/heads/branch
304 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
309 from refs/heads/master
310 M 644 $oldf file2/oldf
311 M 755 $newf file2/newf
315 test_expect_success \
316 'C: incremental import create pack from stdin' \
317 'git fast-import <input &&
318 git whatchanged branch'
319 test_expect_success \
321 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
322 test_expect_success \
323 'C: validate reuse existing blob' \
324 'test $newf = `git rev-parse --verify branch:file2/newf` &&
325 test $oldf = `git rev-parse --verify branch:file2/oldf`'
328 parent `git rev-parse --verify master^0`
329 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
330 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
334 test_expect_success \
336 'git cat-file commit branch | sed 1d >actual &&
337 test_cmp expect actual'
340 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
341 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
342 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
344 git diff-tree -M -r master branch >actual
345 test_expect_success \
346 'C: validate rename result' \
347 'compare_diff_raw expect actual'
354 cat >input <<INPUT_END
355 commit refs/heads/branch
356 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
361 from refs/heads/branch^0
362 M 644 inline newdir/interesting
367 M 755 inline newdir/exec.sh
373 test_expect_success \
374 'D: inline data in commit' \
375 'git fast-import <input &&
376 git whatchanged branch'
377 test_expect_success \
379 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
382 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
383 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
385 git diff-tree -M -r branch^ branch >actual
386 test_expect_success \
387 'D: validate new files added' \
388 'compare_diff_raw expect actual'
390 echo "$file5_data" >expect
391 test_expect_success \
393 'git cat-file blob branch:newdir/interesting >actual &&
394 test_cmp expect actual'
396 echo "$file6_data" >expect
397 test_expect_success \
399 'git cat-file blob branch:newdir/exec.sh >actual &&
400 test_cmp expect actual'
406 cat >input <<INPUT_END
407 commit refs/heads/branch
408 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
409 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
414 from refs/heads/branch^0
417 test_expect_success 'E: rfc2822 date, --date-format=raw' '
418 test_must_fail git fast-import --date-format=raw <input
420 test_expect_success \
421 'E: rfc2822 date, --date-format=rfc2822' \
422 'git fast-import --date-format=rfc2822 <input'
423 test_expect_success \
425 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
428 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
429 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
433 test_expect_success \
435 'git cat-file commit branch | sed 1,2d >actual &&
436 test_cmp expect actual'
442 old_branch=`git rev-parse --verify branch^0`
444 cat >input <<INPUT_END
445 commit refs/heads/branch
446 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
448 losing things already?
451 from refs/heads/branch~1
453 reset refs/heads/other
454 from refs/heads/branch
457 test_expect_success \
458 'F: non-fast-forward update skips' \
459 'if git fast-import <input
461 echo BAD gfi did not fail
464 if test $old_branch = `git rev-parse --verify branch^0`
466 : branch unaffected and failure returned
469 echo BAD gfi changed branch $old_branch
474 test_expect_success \
476 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
479 tree `git rev-parse branch~1^{tree}`
480 parent `git rev-parse branch~1`
481 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
482 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
484 losing things already?
486 test_expect_success \
487 'F: verify other commit' \
488 'git cat-file commit other >actual &&
489 test_cmp expect actual'
495 old_branch=`git rev-parse --verify branch^0`
497 cat >input <<INPUT_END
498 commit refs/heads/branch
499 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
501 losing things already?
504 from refs/heads/branch~1
507 test_expect_success \
508 'G: non-fast-forward update forced' \
509 'git fast-import --force <input'
510 test_expect_success \
512 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
513 test_expect_success \
514 'G: branch changed, but logged' \
515 'test $old_branch != `git rev-parse --verify branch^0` &&
516 test $old_branch = `git rev-parse --verify branch@{1}`'
523 cat >input <<INPUT_END
525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
530 from refs/heads/branch^0
531 M 644 inline i-will-die
533 this file will never exist.
537 M 644 inline h/e/l/lo
543 test_expect_success \
544 'H: deletall, add 1' \
545 'git fast-import <input &&
547 test_expect_success \
549 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
552 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
553 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
554 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
555 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
556 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
558 git diff-tree -M -r H^ H >actual
559 test_expect_success \
560 'H: validate old files removed, new files added' \
561 'compare_diff_raw expect actual'
563 echo "$file5_data" >expect
564 test_expect_success \
566 'git cat-file blob H:h/e/l/lo >actual &&
567 test_cmp expect actual'
573 cat >input <<INPUT_END
574 commit refs/heads/export-boundary
575 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
577 we have a border. its only 40 characters wide.
580 from refs/heads/branch
583 test_expect_success \
584 'I: export-pack-edges' \
585 'git fast-import --export-pack-edges=edges.list <input'
588 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
590 test_expect_success \
591 'I: verify edge list' \
592 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
593 test_cmp expect actual'
599 cat >input <<INPUT_END
601 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
606 from refs/heads/branch
611 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
617 test_expect_success \
618 'J: reset existing branch creates empty commit' \
619 'git fast-import <input'
620 test_expect_success \
621 'J: branch has 1 commit, empty tree' \
622 'test 1 = `git rev-list J | wc -l` &&
623 test 0 = `git ls-tree J | wc -l`'
629 cat >input <<INPUT_END
631 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
636 from refs/heads/branch
639 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
644 from refs/heads/branch^1
647 test_expect_success \
648 'K: reinit branch with from' \
649 'git fast-import <input'
650 test_expect_success \
651 'K: verify K^1 = branch^1' \
652 'test `git rev-parse --verify branch^1` \
653 = `git rev-parse --verify K^1`'
659 cat >input <<INPUT_END
673 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
683 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
693 cat >expect <<EXPECT_END
694 :100644 100644 4268632... 55d3a52... M b.
695 :040000 040000 0ae5cac... 443c768... M b
696 :100644 100644 4268632... 55d3a52... M ba
699 test_expect_success \
700 'L: verify internal tree sorting' \
701 'git fast-import <input &&
702 git diff-tree --abbrev --raw L^ L >output &&
703 test_cmp expect output'
710 cat >input <<INPUT_END
712 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
717 from refs/heads/branch^0
718 R file2/newf file2/n.e.w.f
723 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
725 test_expect_success \
726 'M: rename file in same subdirectory' \
727 'git fast-import <input &&
728 git diff-tree -M -r M1^ M1 >actual &&
729 compare_diff_raw expect actual'
731 cat >input <<INPUT_END
733 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
738 from refs/heads/branch^0
739 R file2/newf i/am/new/to/you
744 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
746 test_expect_success \
747 'M: rename file to new subdirectory' \
748 'git fast-import <input &&
749 git diff-tree -M -r M2^ M2 >actual &&
750 compare_diff_raw expect actual'
752 cat >input <<INPUT_END
754 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
765 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
767 test_expect_success \
768 'M: rename subdirectory to new subdirectory' \
769 'git fast-import <input &&
770 git diff-tree -M -r M3^ M3 >actual &&
771 compare_diff_raw expect actual'
778 cat >input <<INPUT_END
780 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
785 from refs/heads/branch^0
786 C file2/newf file2/n.e.w.f
791 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
793 test_expect_success \
794 'N: copy file in same subdirectory' \
795 'git fast-import <input &&
796 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
797 compare_diff_raw expect actual'
799 cat >input <<INPUT_END
801 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
806 from refs/heads/branch^0
810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
812 modify directory copy
815 M 644 inline file3/file5
823 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
824 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
825 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
827 test_expect_success \
828 'N: copy then modify subdirectory' \
829 'git fast-import <input &&
830 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
831 compare_diff_raw expect actual'
833 cat >input <<INPUT_END
835 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
840 from refs/heads/branch^0
841 M 644 inline file2/file5
851 test_expect_success \
852 'N: copy dirty subdirectory' \
853 'git fast-import <input &&
854 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
856 test_expect_success \
857 'N: copy directory by id' \
858 'cat >expect <<-\EOF &&
859 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
860 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
862 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
863 cat >input <<-INPUT_END &&
865 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
870 from refs/heads/branch^0
871 M 040000 $subdir file3
873 git fast-import <input &&
874 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
875 compare_diff_raw expect actual'
877 test_expect_success \
878 'N: copy root directory by tree hash' \
879 'cat >expect <<-\EOF &&
880 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
881 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
883 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
884 cat >input <<-INPUT_END &&
886 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
888 copy root directory by tree hash
891 from refs/heads/branch^0
894 git fast-import <input &&
895 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
896 compare_diff_raw expect actual'
898 test_expect_success \
899 'N: modify copied tree' \
900 'cat >expect <<-\EOF &&
901 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
902 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
903 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
905 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
906 cat >input <<-INPUT_END &&
908 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
913 from refs/heads/branch^0
914 M 040000 $subdir file3
917 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
919 modify directory copy
922 M 644 inline file3/file5
927 git fast-import <input &&
928 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
929 compare_diff_raw expect actual'
931 test_expect_success \
932 'N: reject foo/ syntax' \
933 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
934 test_must_fail git fast-import <<-INPUT_END
935 commit refs/heads/N5B
936 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
938 copy with invalid syntax
941 from refs/heads/branch^0
942 M 040000 $subdir file3/
945 test_expect_success \
946 'N: copy to root by id and modify' \
947 'echo "hello, world" >expect.foo &&
948 echo hello >expect.bar &&
949 git fast-import <<-SETUP_END &&
951 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
963 tree=$(git rev-parse --verify N7:) &&
964 git fast-import <<-INPUT_END &&
966 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
968 copy to root by id and modify
977 git show N8:foo/foo >actual.foo &&
978 git show N8:foo/bar >actual.bar &&
979 test_cmp expect.foo actual.foo &&
980 test_cmp expect.bar actual.bar'
982 test_expect_success \
983 'N: extract subtree' \
984 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
985 cat >input <<-INPUT_END &&
987 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
989 extract subtree branch:newdir
995 git fast-import <input &&
996 git diff --exit-code branch:newdir N9'
998 test_expect_success \
999 'N: modify subtree, extract it, and modify again' \
1000 'echo hello >expect.baz &&
1001 echo hello, world >expect.qux &&
1002 git fast-import <<-SETUP_END &&
1003 commit refs/heads/N10
1004 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1010 M 644 inline foo/bar/baz
1016 tree=$(git rev-parse --verify N10:) &&
1017 git fast-import <<-INPUT_END &&
1018 commit refs/heads/N11
1019 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1021 copy to root by id and modify
1025 M 100644 inline foo/bar/qux
1030 C "bar/qux" "bar/quux"
1032 git show N11:bar/baz >actual.baz &&
1033 git show N11:bar/qux >actual.qux &&
1034 git show N11:bar/quux >actual.quux &&
1035 test_cmp expect.baz actual.baz &&
1036 test_cmp expect.qux actual.qux &&
1037 test_cmp expect.qux actual.quux'
1043 cat >input <<INPUT_END
1045 commit refs/heads/O1
1046 # -- ignore all of this text
1047 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1048 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1050 dirty directory copy
1053 # don't forget the import blank line!
1055 # yes, we started from our usual base of branch^0.
1057 from refs/heads/branch^0
1058 # and we need to reuse file2/file5 from N3 above.
1059 M 644 inline file2/file5
1060 # otherwise the tree will be different
1065 # don't forget to copy file2 to file3
1068 # or to delete file5 from file2.
1074 test_expect_success \
1075 'O: comments are all skipped' \
1076 'git fast-import <input &&
1077 test `git rev-parse N3` = `git rev-parse O1`'
1079 cat >input <<INPUT_END
1080 commit refs/heads/O2
1081 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1083 dirty directory copy
1085 from refs/heads/branch^0
1086 M 644 inline file2/file5
1095 test_expect_success \
1096 'O: blank lines not necessary after data commands' \
1097 'git fast-import <input &&
1098 test `git rev-parse N3` = `git rev-parse O2`'
1100 test_expect_success \
1101 'O: repack before next test' \
1104 cat >input <<INPUT_END
1105 commit refs/heads/O3
1106 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1110 commit refs/heads/O3
1111 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1116 commit refs/heads/O3
1118 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1123 commit refs/heads/O3
1124 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1128 reset refs/tags/O3-2nd
1130 reset refs/tags/O3-3rd
1134 cat >expect <<INPUT_END
1140 test_expect_success \
1141 'O: blank lines not necessary after other commands' \
1142 'git fast-import <input &&
1143 test 8 = `find .git/objects/pack -type f | wc -l` &&
1144 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1145 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1146 test_cmp expect actual'
1148 cat >input <<INPUT_END
1149 commit refs/heads/O4
1150 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1154 commit refs/heads/O4
1155 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1159 progress Two commits down, 2 to go!
1160 commit refs/heads/O4
1161 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1165 progress Three commits down, 1 to go!
1166 commit refs/heads/O4
1167 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1173 test_expect_success \
1174 'O: progress outputs as requested by input' \
1175 'git fast-import <input >actual &&
1176 grep "progress " <input >expect &&
1177 test_cmp expect actual'
1180 ### series P (gitlinks)
1183 cat >input <<INPUT_END
1189 reset refs/heads/sub
1190 commit refs/heads/sub
1192 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1205 commit refs/heads/subuse1
1207 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1210 from refs/heads/master
1211 M 100644 :3 .gitmodules
1220 commit refs/heads/sub
1222 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1228 commit refs/heads/subuse1
1230 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1238 test_expect_success \
1239 'P: supermodule & submodule mix' \
1240 'git fast-import <input &&
1241 git checkout subuse1 &&
1242 rm -rf sub && mkdir sub && (cd sub &&
1244 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1245 git checkout master) &&
1246 git submodule init &&
1247 git submodule update'
1249 SUBLAST=$(git rev-parse --verify sub)
1250 SUBPREV=$(git rev-parse --verify sub^)
1252 cat >input <<INPUT_END
1261 commit refs/heads/subuse2
1263 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1266 from refs/heads/master
1267 M 100644 :1 .gitmodules
1268 M 160000 $SUBPREV sub
1270 commit refs/heads/subuse2
1272 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1276 M 160000 $SUBLAST sub
1280 test_expect_success \
1281 'P: verbatim SHA gitlinks' \
1282 'git branch -D sub &&
1283 git gc && git prune &&
1284 git fast-import <input &&
1285 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1288 cat >input <<INPUT_END
1289 commit refs/heads/subuse3
1291 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1296 from refs/heads/subuse2
1304 test_expect_success 'P: fail on inline gitlink' '
1305 test_must_fail git fast-import <input'
1308 cat >input <<INPUT_END
1315 commit refs/heads/subuse3
1317 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1322 from refs/heads/subuse2
1327 test_expect_success 'P: fail on blob mark in gitlink' '
1328 test_must_fail git fast-import <input'
1331 ### series Q (notes)
1334 note1_data="The first note for the first commit"
1335 note2_data="The first note for the second commit"
1336 note3_data="The first note for the third commit"
1337 note1b_data="The second note for the first commit"
1338 note1c_data="The third note for the first commit"
1339 note2b_data="The second note for the second commit"
1342 cat >input <<INPUT_END
1349 commit refs/heads/notes-test
1351 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1362 commit refs/heads/notes-test
1364 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1371 commit refs/heads/notes-test
1373 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1400 commit refs/notes/foobar
1402 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1414 commit refs/notes/foobar
1416 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1426 commit refs/notes/foobar2
1428 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1438 commit refs/notes/foobar
1440 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1453 test_expect_success \
1455 'git fast-import <input &&
1456 git whatchanged notes-test'
1457 test_expect_success \
1459 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1461 commit1=$(git rev-parse notes-test~2)
1462 commit2=$(git rev-parse notes-test^)
1463 commit3=$(git rev-parse notes-test)
1466 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1467 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1471 test_expect_success \
1472 'Q: verify first commit' \
1473 'git cat-file commit notes-test~2 | sed 1d >actual &&
1474 test_cmp expect actual'
1478 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1479 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1483 test_expect_success \
1484 'Q: verify second commit' \
1485 'git cat-file commit notes-test^ | sed 1d >actual &&
1486 test_cmp expect actual'
1490 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1491 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1495 test_expect_success \
1496 'Q: verify third commit' \
1497 'git cat-file commit notes-test | sed 1d >actual &&
1498 test_cmp expect actual'
1501 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1502 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1506 test_expect_success \
1507 'Q: verify first notes commit' \
1508 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1509 test_cmp expect actual'
1511 cat >expect.unsorted <<EOF
1512 100644 blob $commit1
1513 100644 blob $commit2
1514 100644 blob $commit3
1516 cat expect.unsorted | sort >expect
1517 test_expect_success \
1518 'Q: verify first notes tree' \
1519 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1520 test_cmp expect actual'
1522 echo "$note1_data" >expect
1523 test_expect_success \
1524 'Q: verify first note for first commit' \
1525 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1527 echo "$note2_data" >expect
1528 test_expect_success \
1529 'Q: verify first note for second commit' \
1530 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1532 echo "$note3_data" >expect
1533 test_expect_success \
1534 'Q: verify first note for third commit' \
1535 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1538 parent `git rev-parse --verify refs/notes/foobar~2`
1539 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1540 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1544 test_expect_success \
1545 'Q: verify second notes commit' \
1546 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1547 test_cmp expect actual'
1549 cat >expect.unsorted <<EOF
1550 100644 blob $commit1
1551 100644 blob $commit2
1552 100644 blob $commit3
1554 cat expect.unsorted | sort >expect
1555 test_expect_success \
1556 'Q: verify second notes tree' \
1557 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1558 test_cmp expect actual'
1560 echo "$note1b_data" >expect
1561 test_expect_success \
1562 'Q: verify second note for first commit' \
1563 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1565 echo "$note2_data" >expect
1566 test_expect_success \
1567 'Q: verify first note for second commit' \
1568 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1570 echo "$note3_data" >expect
1571 test_expect_success \
1572 'Q: verify first note for third commit' \
1573 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1576 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1577 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1581 test_expect_success \
1582 'Q: verify third notes commit' \
1583 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1584 test_cmp expect actual'
1586 cat >expect.unsorted <<EOF
1587 100644 blob $commit1
1589 cat expect.unsorted | sort >expect
1590 test_expect_success \
1591 'Q: verify third notes tree' \
1592 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1593 test_cmp expect actual'
1595 echo "$note1c_data" >expect
1596 test_expect_success \
1597 'Q: verify third note for first commit' \
1598 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1601 parent `git rev-parse --verify refs/notes/foobar^`
1602 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1603 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1607 test_expect_success \
1608 'Q: verify fourth notes commit' \
1609 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1610 test_cmp expect actual'
1612 cat >expect.unsorted <<EOF
1613 100644 blob $commit2
1615 cat expect.unsorted | sort >expect
1616 test_expect_success \
1617 'Q: verify fourth notes tree' \
1618 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1619 test_cmp expect actual'
1621 echo "$note2b_data" >expect
1622 test_expect_success \
1623 'Q: verify second note for second commit' \
1624 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1627 ### series R (feature and option)
1631 feature no-such-feature-exists
1634 test_expect_success 'R: abort on unsupported feature' '
1635 test_must_fail git fast-import <input
1639 feature date-format=now
1642 test_expect_success 'R: supported feature is accepted' '
1643 git fast-import <input
1650 feature date-format=now
1653 test_expect_success 'R: abort on receiving feature after data command' '
1654 test_must_fail git fast-import <input
1658 feature import-marks=git.marks
1659 feature import-marks=git2.marks
1662 test_expect_success 'R: only one import-marks feature allowed per stream' '
1663 test_must_fail git fast-import <input
1667 feature export-marks=git.marks
1675 test_expect_success \
1676 'R: export-marks feature results in a marks file being created' \
1677 'cat input | git fast-import &&
1680 test_expect_success \
1681 'R: export-marks options can be overriden by commandline options' \
1682 'cat input | git fast-import --export-marks=other.marks &&
1683 grep :1 other.marks'
1686 feature import-marks=marks.out
1687 feature export-marks=marks.new
1690 test_expect_success \
1691 'R: import to output marks works without any content' \
1692 'cat input | git fast-import &&
1693 test_cmp marks.out marks.new'
1696 feature import-marks=nonexistant.marks
1697 feature export-marks=marks.new
1700 test_expect_success \
1701 'R: import marks prefers commandline marks file over the stream' \
1702 'cat input | git fast-import --import-marks=marks.out &&
1703 test_cmp marks.out marks.new'
1707 feature import-marks=nonexistant.marks
1708 feature export-marks=combined.marks
1711 test_expect_success 'R: multiple --import-marks= should be honoured' '
1712 head -n2 marks.out > one.marks &&
1713 tail -n +3 marks.out > two.marks &&
1714 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1715 test_cmp marks.out combined.marks
1719 feature relative-marks
1720 feature import-marks=relative.in
1721 feature export-marks=relative.out
1724 test_expect_success 'R: feature relative-marks should be honoured' '
1725 mkdir -p .git/info/fast-import/ &&
1726 cp marks.new .git/info/fast-import/relative.in &&
1727 git fast-import <input &&
1728 test_cmp marks.new .git/info/fast-import/relative.out
1732 feature relative-marks
1733 feature import-marks=relative.in
1734 feature no-relative-marks
1735 feature export-marks=non-relative.out
1738 test_expect_success 'R: feature no-relative-marks should be honoured' '
1739 git fast-import <input &&
1740 test_cmp marks.new non-relative.out
1753 test_expect_success 'R: quiet option results in no stats being output' '
1754 cat input | git fast-import 2> output &&
1755 test_cmp empty output
1759 option git non-existing-option
1762 test_expect_success 'R: die on unknown option' '
1763 test_must_fail git fast-import <input
1766 test_expect_success 'R: unknown commandline options are rejected' '\
1767 test_must_fail git fast-import --non-existing-option < /dev/null
1771 option non-existing-vcs non-existing-option
1774 test_expect_success 'R: ignore non-git options' '
1775 git fast-import <input
1779 ## R: very large blobs
1781 blobsize=$((2*1024*1024 + 53))
1782 test-genrandom bar $blobsize >expect
1783 cat >input <<INPUT_END
1784 commit refs/heads/big-file
1785 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1794 cat >>input <<INPUT_END
1801 test_expect_success \
1802 'R: blob bigger than threshold' \
1803 'test_create_repo R &&
1804 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
1805 test_expect_success \
1806 'R: verify created pack' \
1808 for p in R/.git/objects/pack/*.pack;
1810 git verify-pack -v $p >>verify || exit;
1812 test_expect_success \
1813 'R: verify written objects' \
1814 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
1815 test_cmp expect actual &&
1816 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
1817 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
1819 test_expect_success \
1820 'R: blob appears only once' \
1821 'n=$(grep $a verify | wc -l) &&