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.'
34 test_expect_success 'empty stream succeeds' '
35 git fast-import </dev/null
38 cat >input <<INPUT_END
55 commit refs/heads/master
57 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
69 An annotated tag without a tagger
74 'A: create pack from stdin' \
75 'git fast-import --export-marks=marks.out <input &&
76 git whatchanged master'
79 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
82 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
83 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
89 'git cat-file commit master | sed 1d >actual &&
90 test_cmp expect actual'
99 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
100 test_cmp expect actual'
102 echo "$file2_data" >expect
103 test_expect_success \
105 'git cat-file blob master:file2 >actual && test_cmp expect actual'
107 echo "$file3_data" >expect
108 test_expect_success \
110 'git cat-file blob master:file3 >actual && test_cmp expect actual'
112 printf "$file4_data" >expect
113 test_expect_success \
115 'git cat-file blob master:file4 >actual && test_cmp expect actual'
118 object $(git rev-parse refs/heads/master)
122 An annotated tag without a tagger
124 test_expect_success 'A: verify tag/series-A' '
125 git cat-file tag tags/series-A >actual &&
126 test_cmp expect actual
130 :2 `git rev-parse --verify master:file2`
131 :3 `git rev-parse --verify master:file3`
132 :4 `git rev-parse --verify master:file4`
133 :5 `git rev-parse --verify master^0`
135 test_expect_success \
136 'A: verify marks output' \
137 'test_cmp expect marks.out'
139 test_expect_success \
140 'A: verify marks import' \
142 --import-marks=marks.out \
143 --export-marks=marks.new \
145 test_cmp expect marks.new'
148 cat >input <<INPUT_END
149 commit refs/heads/verify--import-marks
150 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
156 M 755 :2 copy-of-file2
159 test_expect_success \
160 'A: verify marks import does not crash' \
161 'git fast-import --import-marks=marks.out <input &&
162 git whatchanged verify--import-marks'
163 test_expect_success \
165 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
167 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
169 git diff-tree -M -r master verify--import-marks >actual
170 test_expect_success \
172 'compare_diff_raw expect actual &&
173 test `git rev-parse --verify master:file2` \
174 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
177 mt=$(git hash-object --stdin < /dev/null)
182 cat >input.commit <<EOF
183 commit refs/heads/verify--dump-marks
184 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
186 test the sparse array dumping routines with exponentially growing marks
194 while test "$i" -lt 27; do
195 cat >>input.blob <<EOF
206 echo "M 100644 :$l l$i" >>input.commit
207 echo "M 100644 :$m m$i" >>input.commit
208 echo "M 100644 :$n n$i" >>input.commit
210 echo ":$l $mt" >>marks.exp
211 echo ":$m $mt" >>marks.exp
212 echo ":$n $mt" >>marks.exp
214 printf "100644 blob $mt\tl$i\n" >>tree.exp
215 printf "100644 blob $mt\tm$i\n" >>tree.exp
216 printf "100644 blob $mt\tn$i\n" >>tree.exp
225 sort tree.exp > tree.exp_s
227 test_expect_success 'A: export marks with large values' '
228 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
229 git ls-tree refs/heads/verify--dump-marks >tree.out &&
230 test_cmp tree.exp_s tree.out &&
231 test_cmp marks.exp marks.large'
238 cat >input <<INPUT_END
239 commit refs/heads/branch
241 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
246 from refs/heads/master
247 M 755 0000000000000000000000000000000000000001 zero1
250 test_expect_success 'B: fail on invalid blob sha1' '
251 test_must_fail git fast-import <input
253 rm -f .git/objects/pack_* .git/objects/index_*
255 cat >input <<INPUT_END
256 commit .badbranchname
257 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
262 from refs/heads/master
265 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
266 test_must_fail git fast-import <input
268 rm -f .git/objects/pack_* .git/objects/index_*
270 cat >input <<INPUT_END
271 commit bad[branch]name
272 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
277 from refs/heads/master
280 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
281 test_must_fail git fast-import <input
283 rm -f .git/objects/pack_* .git/objects/index_*
285 cat >input <<INPUT_END
287 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
292 from refs/heads/master
295 test_expect_success \
296 'B: accept branch name "TEMP_TAG"' \
297 'git fast-import <input &&
298 test -f .git/TEMP_TAG &&
299 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
306 newf=`echo hi newf | git hash-object -w --stdin`
307 oldf=`git rev-parse --verify master:file2`
309 cat >input <<INPUT_END
310 commit refs/heads/branch
311 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
316 from refs/heads/master
317 M 644 $oldf file2/oldf
318 M 755 $newf file2/newf
322 test_expect_success \
323 'C: incremental import create pack from stdin' \
324 'git fast-import <input &&
325 git whatchanged branch'
326 test_expect_success \
328 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
329 test_expect_success \
330 'C: validate reuse existing blob' \
331 'test $newf = `git rev-parse --verify branch:file2/newf` &&
332 test $oldf = `git rev-parse --verify branch:file2/oldf`'
335 parent `git rev-parse --verify master^0`
336 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
337 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
341 test_expect_success \
343 'git cat-file commit branch | sed 1d >actual &&
344 test_cmp expect actual'
347 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
348 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
349 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
351 git diff-tree -M -r master branch >actual
352 test_expect_success \
353 'C: validate rename result' \
354 'compare_diff_raw expect actual'
361 cat >input <<INPUT_END
362 commit refs/heads/branch
363 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
368 from refs/heads/branch^0
369 M 644 inline newdir/interesting
374 M 755 inline newdir/exec.sh
380 test_expect_success \
381 'D: inline data in commit' \
382 'git fast-import <input &&
383 git whatchanged branch'
384 test_expect_success \
386 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
389 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
390 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
392 git diff-tree -M -r branch^ branch >actual
393 test_expect_success \
394 'D: validate new files added' \
395 'compare_diff_raw expect actual'
397 echo "$file5_data" >expect
398 test_expect_success \
400 'git cat-file blob branch:newdir/interesting >actual &&
401 test_cmp expect actual'
403 echo "$file6_data" >expect
404 test_expect_success \
406 'git cat-file blob branch:newdir/exec.sh >actual &&
407 test_cmp expect actual'
413 cat >input <<INPUT_END
414 commit refs/heads/branch
415 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
416 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
421 from refs/heads/branch^0
424 test_expect_success 'E: rfc2822 date, --date-format=raw' '
425 test_must_fail git fast-import --date-format=raw <input
427 test_expect_success \
428 'E: rfc2822 date, --date-format=rfc2822' \
429 'git fast-import --date-format=rfc2822 <input'
430 test_expect_success \
432 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
435 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
436 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
440 test_expect_success \
442 'git cat-file commit branch | sed 1,2d >actual &&
443 test_cmp expect actual'
449 old_branch=`git rev-parse --verify branch^0`
451 cat >input <<INPUT_END
452 commit refs/heads/branch
453 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
455 losing things already?
458 from refs/heads/branch~1
460 reset refs/heads/other
461 from refs/heads/branch
464 test_expect_success \
465 'F: non-fast-forward update skips' \
466 'if git fast-import <input
468 echo BAD gfi did not fail
471 if test $old_branch = `git rev-parse --verify branch^0`
473 : branch unaffected and failure returned
476 echo BAD gfi changed branch $old_branch
481 test_expect_success \
483 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
486 tree `git rev-parse branch~1^{tree}`
487 parent `git rev-parse branch~1`
488 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
489 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
491 losing things already?
493 test_expect_success \
494 'F: verify other commit' \
495 'git cat-file commit other >actual &&
496 test_cmp expect actual'
502 old_branch=`git rev-parse --verify branch^0`
504 cat >input <<INPUT_END
505 commit refs/heads/branch
506 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
508 losing things already?
511 from refs/heads/branch~1
514 test_expect_success \
515 'G: non-fast-forward update forced' \
516 'git fast-import --force <input'
517 test_expect_success \
519 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
520 test_expect_success \
521 'G: branch changed, but logged' \
522 'test $old_branch != `git rev-parse --verify branch^0` &&
523 test $old_branch = `git rev-parse --verify branch@{1}`'
530 cat >input <<INPUT_END
532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
537 from refs/heads/branch^0
538 M 644 inline i-will-die
540 this file will never exist.
544 M 644 inline h/e/l/lo
550 test_expect_success \
551 'H: deletall, add 1' \
552 'git fast-import <input &&
554 test_expect_success \
556 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
559 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
560 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
561 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
562 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
563 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
565 git diff-tree -M -r H^ H >actual
566 test_expect_success \
567 'H: validate old files removed, new files added' \
568 'compare_diff_raw expect actual'
570 echo "$file5_data" >expect
571 test_expect_success \
573 'git cat-file blob H:h/e/l/lo >actual &&
574 test_cmp expect actual'
580 cat >input <<INPUT_END
581 commit refs/heads/export-boundary
582 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
584 we have a border. its only 40 characters wide.
587 from refs/heads/branch
590 test_expect_success \
591 'I: export-pack-edges' \
592 'git fast-import --export-pack-edges=edges.list <input'
595 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
597 test_expect_success \
598 'I: verify edge list' \
599 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
600 test_cmp expect actual'
606 cat >input <<INPUT_END
608 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
613 from refs/heads/branch
618 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
624 test_expect_success \
625 'J: reset existing branch creates empty commit' \
626 'git fast-import <input'
627 test_expect_success \
628 'J: branch has 1 commit, empty tree' \
629 'test 1 = `git rev-list J | wc -l` &&
630 test 0 = `git ls-tree J | wc -l`'
636 cat >input <<INPUT_END
638 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
643 from refs/heads/branch
646 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
651 from refs/heads/branch^1
654 test_expect_success \
655 'K: reinit branch with from' \
656 'git fast-import <input'
657 test_expect_success \
658 'K: verify K^1 = branch^1' \
659 'test `git rev-parse --verify branch^1` \
660 = `git rev-parse --verify K^1`'
666 cat >input <<INPUT_END
680 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
690 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
700 cat >expect <<EXPECT_END
701 :100644 100644 4268632... 55d3a52... M b.
702 :040000 040000 0ae5cac... 443c768... M b
703 :100644 100644 4268632... 55d3a52... M ba
706 test_expect_success \
707 'L: verify internal tree sorting' \
708 'git fast-import <input &&
709 git diff-tree --abbrev --raw L^ L >output &&
710 test_cmp expect output'
717 cat >input <<INPUT_END
719 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
724 from refs/heads/branch^0
725 R file2/newf file2/n.e.w.f
730 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
732 test_expect_success \
733 'M: rename file in same subdirectory' \
734 'git fast-import <input &&
735 git diff-tree -M -r M1^ M1 >actual &&
736 compare_diff_raw expect actual'
738 cat >input <<INPUT_END
740 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
745 from refs/heads/branch^0
746 R file2/newf i/am/new/to/you
751 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
753 test_expect_success \
754 'M: rename file to new subdirectory' \
755 'git fast-import <input &&
756 git diff-tree -M -r M2^ M2 >actual &&
757 compare_diff_raw expect actual'
759 cat >input <<INPUT_END
761 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
772 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
774 test_expect_success \
775 'M: rename subdirectory to new subdirectory' \
776 'git fast-import <input &&
777 git diff-tree -M -r M3^ M3 >actual &&
778 compare_diff_raw expect actual'
785 cat >input <<INPUT_END
787 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
792 from refs/heads/branch^0
793 C file2/newf file2/n.e.w.f
798 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
800 test_expect_success \
801 'N: copy file in same subdirectory' \
802 'git fast-import <input &&
803 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
804 compare_diff_raw expect actual'
806 cat >input <<INPUT_END
808 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
813 from refs/heads/branch^0
817 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
819 modify directory copy
822 M 644 inline file3/file5
830 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
831 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
832 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
834 test_expect_success \
835 'N: copy then modify subdirectory' \
836 'git fast-import <input &&
837 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
838 compare_diff_raw expect actual'
840 cat >input <<INPUT_END
842 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
847 from refs/heads/branch^0
848 M 644 inline file2/file5
858 test_expect_success \
859 'N: copy dirty subdirectory' \
860 'git fast-import <input &&
861 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
863 test_expect_success \
864 'N: copy directory by id' \
865 'cat >expect <<-\EOF &&
866 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
867 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
869 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
870 cat >input <<-INPUT_END &&
872 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
877 from refs/heads/branch^0
878 M 040000 $subdir file3
880 git fast-import <input &&
881 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
882 compare_diff_raw expect actual'
884 test_expect_success \
885 'N: copy root directory by tree hash' \
886 'cat >expect <<-\EOF &&
887 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
888 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
890 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
891 cat >input <<-INPUT_END &&
893 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
895 copy root directory by tree hash
898 from refs/heads/branch^0
901 git fast-import <input &&
902 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
903 compare_diff_raw expect actual'
905 test_expect_success \
906 'N: modify copied tree' \
907 'cat >expect <<-\EOF &&
908 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
909 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
910 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
912 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
913 cat >input <<-INPUT_END &&
915 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
920 from refs/heads/branch^0
921 M 040000 $subdir file3
924 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
926 modify directory copy
929 M 644 inline file3/file5
934 git fast-import <input &&
935 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
936 compare_diff_raw expect actual'
938 test_expect_success \
939 'N: reject foo/ syntax' \
940 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
941 test_must_fail git fast-import <<-INPUT_END
942 commit refs/heads/N5B
943 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
945 copy with invalid syntax
948 from refs/heads/branch^0
949 M 040000 $subdir file3/
952 test_expect_success \
953 'N: copy to root by id and modify' \
954 'echo "hello, world" >expect.foo &&
955 echo hello >expect.bar &&
956 git fast-import <<-SETUP_END &&
958 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
970 tree=$(git rev-parse --verify N7:) &&
971 git fast-import <<-INPUT_END &&
973 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
975 copy to root by id and modify
984 git show N8:foo/foo >actual.foo &&
985 git show N8:foo/bar >actual.bar &&
986 test_cmp expect.foo actual.foo &&
987 test_cmp expect.bar actual.bar'
989 test_expect_success \
990 'N: extract subtree' \
991 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
992 cat >input <<-INPUT_END &&
994 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
996 extract subtree branch:newdir
1002 git fast-import <input &&
1003 git diff --exit-code branch:newdir N9'
1005 test_expect_success \
1006 'N: modify subtree, extract it, and modify again' \
1007 'echo hello >expect.baz &&
1008 echo hello, world >expect.qux &&
1009 git fast-import <<-SETUP_END &&
1010 commit refs/heads/N10
1011 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1017 M 644 inline foo/bar/baz
1023 tree=$(git rev-parse --verify N10:) &&
1024 git fast-import <<-INPUT_END &&
1025 commit refs/heads/N11
1026 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1028 copy to root by id and modify
1032 M 100644 inline foo/bar/qux
1037 C "bar/qux" "bar/quux"
1039 git show N11:bar/baz >actual.baz &&
1040 git show N11:bar/qux >actual.qux &&
1041 git show N11:bar/quux >actual.quux &&
1042 test_cmp expect.baz actual.baz &&
1043 test_cmp expect.qux actual.qux &&
1044 test_cmp expect.qux actual.quux'
1050 cat >input <<INPUT_END
1052 commit refs/heads/O1
1053 # -- ignore all of this text
1054 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1055 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1057 dirty directory copy
1060 # don't forget the import blank line!
1062 # yes, we started from our usual base of branch^0.
1064 from refs/heads/branch^0
1065 # and we need to reuse file2/file5 from N3 above.
1066 M 644 inline file2/file5
1067 # otherwise the tree will be different
1072 # don't forget to copy file2 to file3
1075 # or to delete file5 from file2.
1081 test_expect_success \
1082 'O: comments are all skipped' \
1083 'git fast-import <input &&
1084 test `git rev-parse N3` = `git rev-parse O1`'
1086 cat >input <<INPUT_END
1087 commit refs/heads/O2
1088 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1090 dirty directory copy
1092 from refs/heads/branch^0
1093 M 644 inline file2/file5
1102 test_expect_success \
1103 'O: blank lines not necessary after data commands' \
1104 'git fast-import <input &&
1105 test `git rev-parse N3` = `git rev-parse O2`'
1107 test_expect_success \
1108 'O: repack before next test' \
1111 cat >input <<INPUT_END
1112 commit refs/heads/O3
1113 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1117 commit refs/heads/O3
1118 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1123 commit refs/heads/O3
1125 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1130 commit refs/heads/O3
1131 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1135 reset refs/tags/O3-2nd
1137 reset refs/tags/O3-3rd
1141 cat >expect <<INPUT_END
1147 test_expect_success \
1148 'O: blank lines not necessary after other commands' \
1149 'git fast-import <input &&
1150 test 8 = `find .git/objects/pack -type f | wc -l` &&
1151 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1152 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1153 test_cmp expect actual'
1155 cat >input <<INPUT_END
1156 commit refs/heads/O4
1157 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1161 commit refs/heads/O4
1162 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1166 progress Two commits down, 2 to go!
1167 commit refs/heads/O4
1168 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1172 progress Three commits down, 1 to go!
1173 commit refs/heads/O4
1174 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1180 test_expect_success \
1181 'O: progress outputs as requested by input' \
1182 'git fast-import <input >actual &&
1183 grep "progress " <input >expect &&
1184 test_cmp expect actual'
1187 ### series P (gitlinks)
1190 cat >input <<INPUT_END
1196 reset refs/heads/sub
1197 commit refs/heads/sub
1199 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1212 commit refs/heads/subuse1
1214 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1217 from refs/heads/master
1218 M 100644 :3 .gitmodules
1227 commit refs/heads/sub
1229 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1235 commit refs/heads/subuse1
1237 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1245 test_expect_success \
1246 'P: supermodule & submodule mix' \
1247 'git fast-import <input &&
1248 git checkout subuse1 &&
1249 rm -rf sub && mkdir sub && (cd sub &&
1251 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1252 git checkout master) &&
1253 git submodule init &&
1254 git submodule update'
1256 SUBLAST=$(git rev-parse --verify sub)
1257 SUBPREV=$(git rev-parse --verify sub^)
1259 cat >input <<INPUT_END
1268 commit refs/heads/subuse2
1270 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1273 from refs/heads/master
1274 M 100644 :1 .gitmodules
1275 M 160000 $SUBPREV sub
1277 commit refs/heads/subuse2
1279 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1283 M 160000 $SUBLAST sub
1287 test_expect_success \
1288 'P: verbatim SHA gitlinks' \
1289 'git branch -D sub &&
1290 git gc && git prune &&
1291 git fast-import <input &&
1292 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1295 cat >input <<INPUT_END
1296 commit refs/heads/subuse3
1298 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1303 from refs/heads/subuse2
1311 test_expect_success 'P: fail on inline gitlink' '
1312 test_must_fail git fast-import <input'
1315 cat >input <<INPUT_END
1322 commit refs/heads/subuse3
1324 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1329 from refs/heads/subuse2
1334 test_expect_success 'P: fail on blob mark in gitlink' '
1335 test_must_fail git fast-import <input'
1338 ### series Q (notes)
1341 note1_data="The first note for the first commit"
1342 note2_data="The first note for the second commit"
1343 note3_data="The first note for the third commit"
1344 note1b_data="The second note for the first commit"
1345 note1c_data="The third note for the first commit"
1346 note2b_data="The second note for the second commit"
1349 cat >input <<INPUT_END
1356 commit refs/heads/notes-test
1358 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1369 commit refs/heads/notes-test
1371 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1378 commit refs/heads/notes-test
1380 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1407 commit refs/notes/foobar
1409 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1421 commit refs/notes/foobar
1423 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1433 commit refs/notes/foobar2
1435 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1445 commit refs/notes/foobar
1447 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1460 test_expect_success \
1462 'git fast-import <input &&
1463 git whatchanged notes-test'
1464 test_expect_success \
1466 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1468 commit1=$(git rev-parse notes-test~2)
1469 commit2=$(git rev-parse notes-test^)
1470 commit3=$(git rev-parse notes-test)
1473 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1474 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1478 test_expect_success \
1479 'Q: verify first commit' \
1480 'git cat-file commit notes-test~2 | sed 1d >actual &&
1481 test_cmp expect actual'
1485 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1486 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1490 test_expect_success \
1491 'Q: verify second commit' \
1492 'git cat-file commit notes-test^ | sed 1d >actual &&
1493 test_cmp expect actual'
1497 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1498 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1502 test_expect_success \
1503 'Q: verify third commit' \
1504 'git cat-file commit notes-test | sed 1d >actual &&
1505 test_cmp expect actual'
1508 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1509 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1513 test_expect_success \
1514 'Q: verify first notes commit' \
1515 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1516 test_cmp expect actual'
1518 cat >expect.unsorted <<EOF
1519 100644 blob $commit1
1520 100644 blob $commit2
1521 100644 blob $commit3
1523 cat expect.unsorted | sort >expect
1524 test_expect_success \
1525 'Q: verify first notes tree' \
1526 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1527 test_cmp expect actual'
1529 echo "$note1_data" >expect
1530 test_expect_success \
1531 'Q: verify first note for first commit' \
1532 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1534 echo "$note2_data" >expect
1535 test_expect_success \
1536 'Q: verify first note for second commit' \
1537 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1539 echo "$note3_data" >expect
1540 test_expect_success \
1541 'Q: verify first note for third commit' \
1542 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1545 parent `git rev-parse --verify refs/notes/foobar~2`
1546 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1547 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1551 test_expect_success \
1552 'Q: verify second notes commit' \
1553 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1554 test_cmp expect actual'
1556 cat >expect.unsorted <<EOF
1557 100644 blob $commit1
1558 100644 blob $commit2
1559 100644 blob $commit3
1561 cat expect.unsorted | sort >expect
1562 test_expect_success \
1563 'Q: verify second notes tree' \
1564 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1565 test_cmp expect actual'
1567 echo "$note1b_data" >expect
1568 test_expect_success \
1569 'Q: verify second note for first commit' \
1570 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1572 echo "$note2_data" >expect
1573 test_expect_success \
1574 'Q: verify first note for second commit' \
1575 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1577 echo "$note3_data" >expect
1578 test_expect_success \
1579 'Q: verify first note for third commit' \
1580 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1583 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1584 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1588 test_expect_success \
1589 'Q: verify third notes commit' \
1590 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1591 test_cmp expect actual'
1593 cat >expect.unsorted <<EOF
1594 100644 blob $commit1
1596 cat expect.unsorted | sort >expect
1597 test_expect_success \
1598 'Q: verify third notes tree' \
1599 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1600 test_cmp expect actual'
1602 echo "$note1c_data" >expect
1603 test_expect_success \
1604 'Q: verify third note for first commit' \
1605 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1608 parent `git rev-parse --verify refs/notes/foobar^`
1609 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1610 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1614 test_expect_success \
1615 'Q: verify fourth notes commit' \
1616 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1617 test_cmp expect actual'
1619 cat >expect.unsorted <<EOF
1620 100644 blob $commit2
1622 cat expect.unsorted | sort >expect
1623 test_expect_success \
1624 'Q: verify fourth notes tree' \
1625 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1626 test_cmp expect actual'
1628 echo "$note2b_data" >expect
1629 test_expect_success \
1630 'Q: verify second note for second commit' \
1631 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1634 ### series R (feature and option)
1638 feature no-such-feature-exists
1641 test_expect_success 'R: abort on unsupported feature' '
1642 test_must_fail git fast-import <input
1646 feature date-format=now
1649 test_expect_success 'R: supported feature is accepted' '
1650 git fast-import <input
1657 feature date-format=now
1660 test_expect_success 'R: abort on receiving feature after data command' '
1661 test_must_fail git fast-import <input
1665 feature import-marks=git.marks
1666 feature import-marks=git2.marks
1669 test_expect_success 'R: only one import-marks feature allowed per stream' '
1670 test_must_fail git fast-import <input
1674 feature export-marks=git.marks
1682 test_expect_success \
1683 'R: export-marks feature results in a marks file being created' \
1684 'cat input | git fast-import &&
1687 test_expect_success \
1688 'R: export-marks options can be overriden by commandline options' \
1689 'cat input | git fast-import --export-marks=other.marks &&
1690 grep :1 other.marks'
1693 feature import-marks=marks.out
1694 feature export-marks=marks.new
1697 test_expect_success \
1698 'R: import to output marks works without any content' \
1699 'cat input | git fast-import &&
1700 test_cmp marks.out marks.new'
1703 feature import-marks=nonexistant.marks
1704 feature export-marks=marks.new
1707 test_expect_success \
1708 'R: import marks prefers commandline marks file over the stream' \
1709 'cat input | git fast-import --import-marks=marks.out &&
1710 test_cmp marks.out marks.new'
1714 feature import-marks=nonexistant.marks
1715 feature export-marks=combined.marks
1718 test_expect_success 'R: multiple --import-marks= should be honoured' '
1719 head -n2 marks.out > one.marks &&
1720 tail -n +3 marks.out > two.marks &&
1721 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1722 test_cmp marks.out combined.marks
1726 feature relative-marks
1727 feature import-marks=relative.in
1728 feature export-marks=relative.out
1731 test_expect_success 'R: feature relative-marks should be honoured' '
1732 mkdir -p .git/info/fast-import/ &&
1733 cp marks.new .git/info/fast-import/relative.in &&
1734 git fast-import <input &&
1735 test_cmp marks.new .git/info/fast-import/relative.out
1739 feature relative-marks
1740 feature import-marks=relative.in
1741 feature no-relative-marks
1742 feature export-marks=non-relative.out
1745 test_expect_success 'R: feature no-relative-marks should be honoured' '
1746 git fast-import <input &&
1747 test_cmp marks.new non-relative.out
1750 test_expect_success 'R: feature cat-blob supported' '
1751 echo "feature cat-blob" |
1755 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
1756 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
1759 test_expect_success 'R: print old blob' '
1760 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
1761 cat >expect <<-EOF &&
1766 echo "cat-blob $blob" |
1767 git fast-import --cat-blob-fd=6 6>actual &&
1768 test_cmp expect actual
1771 test_expect_success 'R: in-stream cat-blob-fd not respected' '
1772 echo hello >greeting &&
1773 blob=$(git hash-object -w greeting) &&
1774 cat >expect <<-EOF &&
1779 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
1782 test_cmp expect actual.3 &&
1783 test_cmp empty actual.1 &&
1784 git fast-import 3>actual.3 >actual.1 <<-EOF &&
1785 option cat-blob-fd=3
1788 test_cmp empty actual.3 &&
1789 test_cmp expect actual.1
1792 test_expect_success 'R: print new blob' '
1793 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
1794 cat >expect <<-EOF &&
1799 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
1807 test_cmp expect actual
1810 test_expect_success 'R: print new blob by sha1' '
1811 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
1812 cat >expect <<-EOF &&
1814 a new blob named by sha1
1817 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
1820 a new blob named by sha1
1824 test_cmp expect actual
1827 test_expect_success 'setup: big file' '
1829 echo "the quick brown fox jumps over the lazy dog" >big &&
1832 cat big big big big >bigger &&
1833 cat bigger bigger bigger bigger >big ||
1839 test_expect_success 'R: print two blobs to stdout' '
1840 blob1=$(git hash-object big) &&
1841 blob1_len=$(wc -c <big) &&
1842 blob2=$(echo hello | git hash-object --stdin) &&
1844 echo ${blob1} blob $blob1_len &&
1854 cat <<-\END_PART1 &&
1871 git fast-import >actual &&
1872 test_cmp expect actual
1875 test_expect_success 'setup: have pipes?' '
1879 test_set_prereq PIPE
1883 test_expect_success PIPE 'R: copy using cat-file' '
1884 expect_id=$(git hash-object big) &&
1885 expect_len=$(wc -c <big) &&
1886 echo $expect_id blob $expect_len >expect.response &&
1889 cat >frontend <<-\FRONTEND_END &&
1903 read blob_id type size <&3 &&
1904 echo "$blob_id $type $size" >response &&
1905 dd of=blob bs=$size count=1 <&3 &&
1909 commit refs/heads/copied
1910 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1912 copy big file as file3
1925 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
1926 sh frontend 3<blobs |
1927 git fast-import --cat-blob-fd=3 3>blobs
1929 git show copied:file3 >actual &&
1930 test_cmp expect.response response &&
1934 test_expect_success PIPE 'R: print blob mid-commit' '
1936 echo "A blob from _before_ the commit." >expect &&
1945 A blob from _before_ the commit.
1947 commit refs/heads/temporary
1948 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1955 read blob_id type size <&3 &&
1956 dd of=actual bs=$size count=1 <&3 &&
1961 git fast-import --cat-blob-fd=3 3>blobs &&
1962 test_cmp expect actual
1965 test_expect_success PIPE 'R: print staged blob within commit' '
1967 echo "A blob from _within_ the commit." >expect &&
1973 commit refs/heads/within
1974 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1980 A blob from _within_ the commit.
1985 echo "A blob from _within_ the commit." |
1986 git hash-object --stdin
1988 echo "cat-blob $to_get" &&
1990 read blob_id type size <&3 &&
1991 dd of=actual bs=$size count=1 <&3 &&
1996 git fast-import --cat-blob-fd=3 3>blobs &&
1997 test_cmp expect actual
2008 test_expect_success 'R: quiet option results in no stats being output' '
2009 cat input | git fast-import 2> output &&
2010 test_cmp empty output
2014 option git non-existing-option
2017 test_expect_success 'R: die on unknown option' '
2018 test_must_fail git fast-import <input
2021 test_expect_success 'R: unknown commandline options are rejected' '\
2022 test_must_fail git fast-import --non-existing-option < /dev/null
2025 test_expect_success 'R: die on invalid option argument' '
2026 echo "option git active-branches=-5" |
2027 test_must_fail git fast-import &&
2028 echo "option git depth=" |
2029 test_must_fail git fast-import &&
2030 test_must_fail git fast-import --depth="5 elephants" </dev/null
2034 option non-existing-vcs non-existing-option
2037 test_expect_success 'R: ignore non-git options' '
2038 git fast-import <input
2042 ## R: very large blobs
2044 blobsize=$((2*1024*1024 + 53))
2045 test-genrandom bar $blobsize >expect
2046 cat >input <<INPUT_END
2047 commit refs/heads/big-file
2048 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2057 cat >>input <<INPUT_END
2064 test_expect_success \
2065 'R: blob bigger than threshold' \
2066 'test_create_repo R &&
2067 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2068 test_expect_success \
2069 'R: verify created pack' \
2071 for p in R/.git/objects/pack/*.pack;
2073 git verify-pack -v $p >>verify || exit;
2075 test_expect_success \
2076 'R: verify written objects' \
2077 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2078 test_cmp expect actual &&
2079 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2080 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2082 test_expect_success \
2083 'R: blob appears only once' \
2084 'n=$(grep $a verify | wc -l) &&