3 # Copyright (c) 2007 Shawn Pearce
6 test_description
='test git fast-import utility'
8 .
"$TEST_DIRECTORY"/diff-lib.sh
;# test-lib chdir's into trash
10 # Print $1 bytes from stdin to stdout.
12 # This could be written as "head -c $1", but IRIX "head" does not
13 # support the -c option.
19 my $nread = sysread(STDIN, $s, $len);
20 die "cannot read: $!" unless defined($nread);
37 file5_data
='an inline file.
38 we should see it later.'
45 test_expect_success
'setup: have pipes?' '
59 test_expect_success
'empty stream succeeds' '
60 git fast-import </dev/null
63 cat >input
<<INPUT_END
80 commit refs/heads/master
82 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
94 An annotated tag without a tagger
99 'A: create pack from stdin' \
100 'git fast-import --export-marks=marks.out <input &&
101 git whatchanged master'
102 test_expect_success \
104 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
107 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
108 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
112 test_expect_success \
114 'git cat-file commit master | sed 1d >actual &&
115 test_cmp expect actual'
122 test_expect_success \
124 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
125 test_cmp expect actual'
127 echo "$file2_data" >expect
128 test_expect_success \
130 'git cat-file blob master:file2 >actual && test_cmp expect actual'
132 echo "$file3_data" >expect
133 test_expect_success \
135 'git cat-file blob master:file3 >actual && test_cmp expect actual'
137 printf "$file4_data" >expect
138 test_expect_success \
140 'git cat-file blob master:file4 >actual && test_cmp expect actual'
143 object $(git rev-parse refs/heads/master)
147 An annotated tag without a tagger
149 test_expect_success
'A: verify tag/series-A' '
150 git cat-file tag tags/series-A >actual &&
151 test_cmp expect actual
155 :2 `git rev-parse --verify master:file2`
156 :3 `git rev-parse --verify master:file3`
157 :4 `git rev-parse --verify master:file4`
158 :5 `git rev-parse --verify master^0`
160 test_expect_success \
161 'A: verify marks output' \
162 'test_cmp expect marks.out'
164 test_expect_success \
165 'A: verify marks import' \
167 --import-marks=marks.out \
168 --export-marks=marks.new \
170 test_cmp expect marks.new'
173 cat >input
<<INPUT_END
174 commit refs/heads/verify--import-marks
175 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
181 M 755 :2 copy-of-file2
184 test_expect_success \
185 'A: verify marks import does not crash' \
186 'git fast-import --import-marks=marks.out <input &&
187 git whatchanged verify--import-marks'
188 test_expect_success \
190 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
192 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
194 git diff-tree
-M -r master verify--import-marks
>actual
195 test_expect_success \
197 'compare_diff_raw expect actual &&
198 test `git rev-parse --verify master:file2` \
199 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
202 mt
=$
(git hash-object
--stdin < /dev
/null
)
207 cat >input.commit
<<EOF
208 commit refs/heads/verify--dump-marks
209 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
211 test the sparse array dumping routines with exponentially growing marks
219 while test "$i" -lt 27; do
220 cat >>input.blob
<<EOF
231 echo "M 100644 :$l l$i" >>input.commit
232 echo "M 100644 :$m m$i" >>input.commit
233 echo "M 100644 :$n n$i" >>input.commit
235 echo ":$l $mt" >>marks.exp
236 echo ":$m $mt" >>marks.exp
237 echo ":$n $mt" >>marks.exp
239 printf "100644 blob $mt\tl$i\n" >>tree.exp
240 printf "100644 blob $mt\tm$i\n" >>tree.exp
241 printf "100644 blob $mt\tn$i\n" >>tree.exp
250 sort tree.exp
> tree.exp_s
252 test_expect_success
'A: export marks with large values' '
253 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
254 git ls-tree refs/heads/verify--dump-marks >tree.out &&
255 test_cmp tree.exp_s tree.out &&
256 test_cmp marks.exp marks.large'
263 cat >input
<<INPUT_END
264 commit refs/heads/branch
266 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
271 from refs/heads/master
272 M 755 0000000000000000000000000000000000000001 zero1
275 test_expect_success
'B: fail on invalid blob sha1' '
276 test_must_fail git fast-import <input
278 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
280 cat >input
<<INPUT_END
281 commit .badbranchname
282 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
287 from refs/heads/master
290 test_expect_success
'B: fail on invalid branch name ".badbranchname"' '
291 test_must_fail git fast-import <input
293 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
295 cat >input
<<INPUT_END
296 commit bad[branch]name
297 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
302 from refs/heads/master
305 test_expect_success
'B: fail on invalid branch name "bad[branch]name"' '
306 test_must_fail git fast-import <input
308 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
310 cat >input
<<INPUT_END
312 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
317 from refs/heads/master
320 test_expect_success \
321 'B: accept branch name "TEMP_TAG"' \
322 'git fast-import <input &&
323 test -f .git/TEMP_TAG &&
324 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
331 newf
=`echo hi newf | git hash-object -w --stdin`
332 oldf
=`git rev-parse --verify master:file2`
334 cat >input
<<INPUT_END
335 commit refs/heads/branch
336 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
341 from refs/heads/master
342 M 644 $oldf file2/oldf
343 M 755 $newf file2/newf
347 test_expect_success \
348 'C: incremental import create pack from stdin' \
349 'git fast-import <input &&
350 git whatchanged branch'
351 test_expect_success \
353 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
354 test_expect_success \
355 'C: validate reuse existing blob' \
356 'test $newf = `git rev-parse --verify branch:file2/newf` &&
357 test $oldf = `git rev-parse --verify branch:file2/oldf`'
360 parent `git rev-parse --verify master^0`
361 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
362 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
366 test_expect_success \
368 'git cat-file commit branch | sed 1d >actual &&
369 test_cmp expect actual'
372 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
373 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
374 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
376 git diff-tree
-M -r master branch
>actual
377 test_expect_success \
378 'C: validate rename result' \
379 'compare_diff_raw expect actual'
386 cat >input
<<INPUT_END
387 commit refs/heads/branch
388 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
393 from refs/heads/branch^0
394 M 644 inline newdir/interesting
399 M 755 inline newdir/exec.sh
405 test_expect_success \
406 'D: inline data in commit' \
407 'git fast-import <input &&
408 git whatchanged branch'
409 test_expect_success \
411 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
414 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
415 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
417 git diff-tree
-M -r branch^ branch
>actual
418 test_expect_success \
419 'D: validate new files added' \
420 'compare_diff_raw expect actual'
422 echo "$file5_data" >expect
423 test_expect_success \
425 'git cat-file blob branch:newdir/interesting >actual &&
426 test_cmp expect actual'
428 echo "$file6_data" >expect
429 test_expect_success \
431 'git cat-file blob branch:newdir/exec.sh >actual &&
432 test_cmp expect actual'
438 cat >input
<<INPUT_END
439 commit refs/heads/branch
440 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
441 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
446 from refs/heads/branch^0
449 test_expect_success
'E: rfc2822 date, --date-format=raw' '
450 test_must_fail git fast-import --date-format=raw <input
452 test_expect_success \
453 'E: rfc2822 date, --date-format=rfc2822' \
454 'git fast-import --date-format=rfc2822 <input'
455 test_expect_success \
457 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
460 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
461 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
465 test_expect_success \
467 'git cat-file commit branch | sed 1,2d >actual &&
468 test_cmp expect actual'
474 old_branch
=`git rev-parse --verify branch^0`
476 cat >input
<<INPUT_END
477 commit refs/heads/branch
478 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
480 losing things already?
483 from refs/heads/branch~1
485 reset refs/heads/other
486 from refs/heads/branch
489 test_expect_success \
490 'F: non-fast-forward update skips' \
491 'if git fast-import <input
493 echo BAD gfi did not fail
496 if test $old_branch = `git rev-parse --verify branch^0`
498 : branch unaffected and failure returned
501 echo BAD gfi changed branch $old_branch
506 test_expect_success \
508 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
511 tree `git rev-parse branch~1^{tree}`
512 parent `git rev-parse branch~1`
513 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
514 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
516 losing things already?
518 test_expect_success \
519 'F: verify other commit' \
520 'git cat-file commit other >actual &&
521 test_cmp expect actual'
527 old_branch
=`git rev-parse --verify branch^0`
529 cat >input
<<INPUT_END
530 commit refs/heads/branch
531 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
533 losing things already?
536 from refs/heads/branch~1
539 test_expect_success \
540 'G: non-fast-forward update forced' \
541 'git fast-import --force <input'
542 test_expect_success \
544 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
545 test_expect_success \
546 'G: branch changed, but logged' \
547 'test $old_branch != `git rev-parse --verify branch^0` &&
548 test $old_branch = `git rev-parse --verify branch@{1}`'
555 cat >input
<<INPUT_END
557 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
562 from refs/heads/branch^0
563 M 644 inline i-will-die
565 this file will never exist.
569 M 644 inline h/e/l/lo
575 test_expect_success \
576 'H: deletall, add 1' \
577 'git fast-import <input &&
579 test_expect_success \
581 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
584 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
585 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
586 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
587 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
588 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
590 git diff-tree
-M -r H^ H
>actual
591 test_expect_success \
592 'H: validate old files removed, new files added' \
593 'compare_diff_raw expect actual'
595 echo "$file5_data" >expect
596 test_expect_success \
598 'git cat-file blob H:h/e/l/lo >actual &&
599 test_cmp expect actual'
605 cat >input
<<INPUT_END
606 commit refs/heads/export-boundary
607 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
609 we have a border. its only 40 characters wide.
612 from refs/heads/branch
615 test_expect_success \
616 'I: export-pack-edges' \
617 'git fast-import --export-pack-edges=edges.list <input'
620 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
622 test_expect_success \
623 'I: verify edge list' \
624 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
625 test_cmp expect actual'
631 cat >input
<<INPUT_END
633 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
638 from refs/heads/branch
643 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
649 test_expect_success \
650 'J: reset existing branch creates empty commit' \
651 'git fast-import <input'
652 test_expect_success \
653 'J: branch has 1 commit, empty tree' \
654 'test 1 = `git rev-list J | wc -l` &&
655 test 0 = `git ls-tree J | wc -l`'
661 cat >input
<<INPUT_END
663 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
668 from refs/heads/branch
671 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
676 from refs/heads/branch^1
679 test_expect_success \
680 'K: reinit branch with from' \
681 'git fast-import <input'
682 test_expect_success \
683 'K: verify K^1 = branch^1' \
684 'test `git rev-parse --verify branch^1` \
685 = `git rev-parse --verify K^1`'
691 cat >input
<<INPUT_END
705 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
715 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
725 cat >expect
<<EXPECT_END
726 :100644 100644 4268632... 55d3a52... M b.
727 :040000 040000 0ae5cac... 443c768... M b
728 :100644 100644 4268632... 55d3a52... M ba
731 test_expect_success \
732 'L: verify internal tree sorting' \
733 'git fast-import <input &&
734 git diff-tree --abbrev --raw L^ L >output &&
735 test_cmp expect output'
742 cat >input
<<INPUT_END
744 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
749 from refs/heads/branch^0
750 R file2/newf file2/n.e.w.f
755 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
757 test_expect_success \
758 'M: rename file in same subdirectory' \
759 'git fast-import <input &&
760 git diff-tree -M -r M1^ M1 >actual &&
761 compare_diff_raw expect actual'
763 cat >input
<<INPUT_END
765 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
770 from refs/heads/branch^0
771 R file2/newf i/am/new/to/you
776 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
778 test_expect_success \
779 'M: rename file to new subdirectory' \
780 'git fast-import <input &&
781 git diff-tree -M -r M2^ M2 >actual &&
782 compare_diff_raw expect actual'
784 cat >input
<<INPUT_END
786 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
797 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
799 test_expect_success \
800 'M: rename subdirectory to new subdirectory' \
801 'git fast-import <input &&
802 git diff-tree -M -r M3^ M3 >actual &&
803 compare_diff_raw expect actual'
810 cat >input
<<INPUT_END
812 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
817 from refs/heads/branch^0
818 C file2/newf file2/n.e.w.f
823 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
825 test_expect_success \
826 'N: copy file in same subdirectory' \
827 'git fast-import <input &&
828 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
829 compare_diff_raw expect actual'
831 cat >input
<<INPUT_END
833 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
838 from refs/heads/branch^0
842 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
844 modify directory copy
847 M 644 inline file3/file5
855 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
856 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
857 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
859 test_expect_success \
860 'N: copy then modify subdirectory' \
861 'git fast-import <input &&
862 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
863 compare_diff_raw expect actual'
865 cat >input
<<INPUT_END
867 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
872 from refs/heads/branch^0
873 M 644 inline file2/file5
883 test_expect_success \
884 'N: copy dirty subdirectory' \
885 'git fast-import <input &&
886 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
888 test_expect_success \
889 'N: copy directory by id' \
890 'cat >expect <<-\EOF &&
891 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
892 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
894 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
895 cat >input <<-INPUT_END &&
897 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
902 from refs/heads/branch^0
903 M 040000 $subdir file3
905 git fast-import <input &&
906 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
907 compare_diff_raw expect actual'
909 test_expect_success PIPE
'N: read and copy directory' '
911 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
912 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
914 git update-ref -d refs/heads/N4 &&
921 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
923 copy by tree hash, part 2
926 from refs/heads/branch^0
929 read mode type tree filename &&
930 echo "M 040000 $tree file3"
932 git fast-import --cat-blob-fd=3 3>backflow &&
933 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
934 compare_diff_raw expect actual
937 test_expect_success PIPE
'N: empty directory reads as missing' '
938 cat <<-\EOF >expect &&
940 :000000 100644 OBJNAME OBJNAME A unrelated
942 echo "missing src" >expect.response &&
943 git update-ref -d refs/heads/read-empty &&
949 commit refs/heads/read-empty
950 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
952 read "empty" (missing) directory
955 M 100644 inline src/greeting
959 C src/greeting dst1/non-greeting
960 C src/greeting unrelated
961 # leave behind "empty" src directory
966 printf "%s\n" "$line" >response &&
972 git fast-import --cat-blob-fd=3 3>backflow &&
973 test_cmp expect.response response &&
974 git rev-list read-empty |
975 git diff-tree -r --root --stdin |
976 sed "s/$_x40/OBJNAME/g" >actual &&
977 test_cmp expect actual
980 test_expect_success \
981 'N: copy root directory by tree hash' \
982 'cat >expect <<-\EOF &&
983 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
984 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
986 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
987 cat >input <<-INPUT_END &&
989 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
991 copy root directory by tree hash
994 from refs/heads/branch^0
997 git fast-import <input &&
998 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
999 compare_diff_raw expect actual'
1001 test_expect_success \
1002 'N: delete directory by copying' \
1003 'cat >expect <<-\EOF &&
1005 :100644 000000 OBJID OBJID D foo/bar/qux
1007 :000000 100644 OBJID OBJID A foo/bar/baz
1008 :000000 100644 OBJID OBJID A foo/bar/qux
1010 empty_tree=$(git mktree </dev/null) &&
1011 cat >input <<-INPUT_END &&
1012 commit refs/heads/N-delete
1013 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1015 collect data to be deleted
1019 M 100644 inline foo/bar/baz
1023 C "foo/bar/baz" "foo/bar/qux"
1024 C "foo/bar/baz" "foo/bar/quux/1"
1025 C "foo/bar/baz" "foo/bar/quuux"
1026 M 040000 $empty_tree foo/bar/quux
1027 M 040000 $empty_tree foo/bar/quuux
1029 commit refs/heads/N-delete
1030 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1035 M 040000 $empty_tree foo/bar/qux
1037 git fast-import <input &&
1038 git rev-list N-delete |
1039 git diff-tree -r --stdin --root --always |
1040 sed -e "s/$_x40/OBJID/g" >actual &&
1041 test_cmp expect actual'
1043 test_expect_success \
1044 'N: modify copied tree' \
1045 'cat >expect <<-\EOF &&
1046 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1047 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1048 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1050 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1051 cat >input <<-INPUT_END &&
1052 commit refs/heads/N5
1053 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1058 from refs/heads/branch^0
1059 M 040000 $subdir file3
1061 commit refs/heads/N5
1062 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1064 modify directory copy
1067 M 644 inline file3/file5
1072 git fast-import <input &&
1073 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1074 compare_diff_raw expect actual'
1076 test_expect_success \
1077 'N: reject foo/ syntax' \
1078 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1079 test_must_fail git fast-import <<-INPUT_END
1080 commit refs/heads/N5B
1081 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1083 copy with invalid syntax
1086 from refs/heads/branch^0
1087 M 040000 $subdir file3/
1090 test_expect_success \
1091 'N: reject foo/ syntax in copy source' \
1092 'test_must_fail git fast-import <<-INPUT_END
1093 commit refs/heads/N5C
1094 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1096 copy with invalid syntax
1099 from refs/heads/branch^0
1103 test_expect_success \
1104 'N: reject foo/ syntax in rename source' \
1105 'test_must_fail git fast-import <<-INPUT_END
1106 commit refs/heads/N5D
1107 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1109 rename with invalid syntax
1112 from refs/heads/branch^0
1116 test_expect_success \
1117 'N: reject foo/ syntax in ls argument' \
1118 'test_must_fail git fast-import <<-INPUT_END
1119 commit refs/heads/N5E
1120 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1122 copy with invalid syntax
1125 from refs/heads/branch^0
1129 test_expect_success \
1130 'N: copy to root by id and modify' \
1131 'echo "hello, world" >expect.foo &&
1132 echo hello >expect.bar &&
1133 git fast-import <<-SETUP_END &&
1134 commit refs/heads/N7
1135 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1141 M 644 inline foo/bar
1147 tree=$(git rev-parse --verify N7:) &&
1148 git fast-import <<-INPUT_END &&
1149 commit refs/heads/N8
1150 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1152 copy to root by id and modify
1156 M 644 inline foo/foo
1161 git show N8:foo/foo >actual.foo &&
1162 git show N8:foo/bar >actual.bar &&
1163 test_cmp expect.foo actual.foo &&
1164 test_cmp expect.bar actual.bar'
1166 test_expect_success \
1167 'N: extract subtree' \
1168 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1169 cat >input <<-INPUT_END &&
1170 commit refs/heads/N9
1171 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1173 extract subtree branch:newdir
1179 git fast-import <input &&
1180 git diff --exit-code branch:newdir N9'
1182 test_expect_success \
1183 'N: modify subtree, extract it, and modify again' \
1184 'echo hello >expect.baz &&
1185 echo hello, world >expect.qux &&
1186 git fast-import <<-SETUP_END &&
1187 commit refs/heads/N10
1188 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1194 M 644 inline foo/bar/baz
1200 tree=$(git rev-parse --verify N10:) &&
1201 git fast-import <<-INPUT_END &&
1202 commit refs/heads/N11
1203 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1205 copy to root by id and modify
1209 M 100644 inline foo/bar/qux
1214 C "bar/qux" "bar/quux"
1216 git show N11:bar/baz >actual.baz &&
1217 git show N11:bar/qux >actual.qux &&
1218 git show N11:bar/quux >actual.quux &&
1219 test_cmp expect.baz actual.baz &&
1220 test_cmp expect.qux actual.qux &&
1221 test_cmp expect.qux actual.quux'
1227 cat >input
<<INPUT_END
1229 commit refs/heads/O1
1230 # -- ignore all of this text
1231 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1232 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1234 dirty directory copy
1237 # don't forget the import blank line!
1239 # yes, we started from our usual base of branch^0.
1241 from refs/heads/branch^0
1242 # and we need to reuse file2/file5 from N3 above.
1243 M 644 inline file2/file5
1244 # otherwise the tree will be different
1249 # don't forget to copy file2 to file3
1252 # or to delete file5 from file2.
1258 test_expect_success \
1259 'O: comments are all skipped' \
1260 'git fast-import <input &&
1261 test `git rev-parse N3` = `git rev-parse O1`'
1263 cat >input
<<INPUT_END
1264 commit refs/heads/O2
1265 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1267 dirty directory copy
1269 from refs/heads/branch^0
1270 M 644 inline file2/file5
1279 test_expect_success \
1280 'O: blank lines not necessary after data commands' \
1281 'git fast-import <input &&
1282 test `git rev-parse N3` = `git rev-parse O2`'
1284 test_expect_success \
1285 'O: repack before next test' \
1288 cat >input
<<INPUT_END
1289 commit refs/heads/O3
1290 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1294 commit refs/heads/O3
1295 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1300 commit refs/heads/O3
1302 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1307 commit refs/heads/O3
1308 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1312 reset refs/tags/O3-2nd
1314 reset refs/tags/O3-3rd
1318 cat >expect
<<INPUT_END
1324 test_expect_success \
1325 'O: blank lines not necessary after other commands' \
1326 'git fast-import <input &&
1327 test 8 = `find .git/objects/pack -type f | wc -l` &&
1328 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1329 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1330 test_cmp expect actual'
1332 cat >input
<<INPUT_END
1333 commit refs/heads/O4
1334 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1338 commit refs/heads/O4
1339 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1343 progress Two commits down, 2 to go!
1344 commit refs/heads/O4
1345 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1349 progress Three commits down, 1 to go!
1350 commit refs/heads/O4
1351 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1357 test_expect_success \
1358 'O: progress outputs as requested by input' \
1359 'git fast-import <input >actual &&
1360 grep "progress " <input >expect &&
1361 test_cmp expect actual'
1364 ### series P (gitlinks)
1367 cat >input
<<INPUT_END
1373 reset refs/heads/sub
1374 commit refs/heads/sub
1376 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1389 commit refs/heads/subuse1
1391 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1394 from refs/heads/master
1395 M 100644 :3 .gitmodules
1404 commit refs/heads/sub
1406 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1412 commit refs/heads/subuse1
1414 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1422 test_expect_success \
1423 'P: supermodule & submodule mix' \
1424 'git fast-import <input &&
1425 git checkout subuse1 &&
1426 rm -rf sub && mkdir sub && (cd sub &&
1428 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1429 git checkout master) &&
1430 git submodule init &&
1431 git submodule update'
1433 SUBLAST
=$
(git rev-parse
--verify sub
)
1434 SUBPREV
=$
(git rev-parse
--verify sub^
)
1436 cat >input
<<INPUT_END
1445 commit refs/heads/subuse2
1447 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1450 from refs/heads/master
1451 M 100644 :1 .gitmodules
1452 M 160000 $SUBPREV sub
1454 commit refs/heads/subuse2
1456 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1460 M 160000 $SUBLAST sub
1464 test_expect_success \
1465 'P: verbatim SHA gitlinks' \
1466 'git branch -D sub &&
1467 git gc && git prune &&
1468 git fast-import <input &&
1469 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1472 cat >input
<<INPUT_END
1473 commit refs/heads/subuse3
1475 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1480 from refs/heads/subuse2
1488 test_expect_success
'P: fail on inline gitlink' '
1489 test_must_fail git fast-import <input'
1492 cat >input
<<INPUT_END
1499 commit refs/heads/subuse3
1501 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1506 from refs/heads/subuse2
1511 test_expect_success
'P: fail on blob mark in gitlink' '
1512 test_must_fail git fast-import <input'
1515 ### series Q (notes)
1518 note1_data
="The first note for the first commit"
1519 note2_data
="The first note for the second commit"
1520 note3_data
="The first note for the third commit"
1521 note1b_data
="The second note for the first commit"
1522 note1c_data
="The third note for the first commit"
1523 note2b_data
="The second note for the second commit"
1526 cat >input
<<INPUT_END
1533 commit refs/heads/notes-test
1535 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1546 commit refs/heads/notes-test
1548 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1555 commit refs/heads/notes-test
1557 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1584 commit refs/notes/foobar
1586 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1598 commit refs/notes/foobar
1600 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1610 commit refs/notes/foobar2
1612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1622 commit refs/notes/foobar
1624 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1637 test_expect_success \
1639 'git fast-import <input &&
1640 git whatchanged notes-test'
1641 test_expect_success \
1643 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1645 commit1
=$
(git rev-parse notes-test~
2)
1646 commit2
=$
(git rev-parse notes-test^
)
1647 commit3
=$
(git rev-parse notes-test
)
1650 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1651 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1655 test_expect_success \
1656 'Q: verify first commit' \
1657 'git cat-file commit notes-test~2 | sed 1d >actual &&
1658 test_cmp expect actual'
1662 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1663 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1667 test_expect_success \
1668 'Q: verify second commit' \
1669 'git cat-file commit notes-test^ | sed 1d >actual &&
1670 test_cmp expect actual'
1674 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1675 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1679 test_expect_success \
1680 'Q: verify third commit' \
1681 'git cat-file commit notes-test | sed 1d >actual &&
1682 test_cmp expect actual'
1685 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1686 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1690 test_expect_success \
1691 'Q: verify first notes commit' \
1692 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1693 test_cmp expect actual'
1695 cat >expect.unsorted
<<EOF
1696 100644 blob $commit1
1697 100644 blob $commit2
1698 100644 blob $commit3
1700 cat expect.unsorted |
sort >expect
1701 test_expect_success \
1702 'Q: verify first notes tree' \
1703 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1704 test_cmp expect actual'
1706 echo "$note1_data" >expect
1707 test_expect_success \
1708 'Q: verify first note for first commit' \
1709 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1711 echo "$note2_data" >expect
1712 test_expect_success \
1713 'Q: verify first note for second commit' \
1714 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1716 echo "$note3_data" >expect
1717 test_expect_success \
1718 'Q: verify first note for third commit' \
1719 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1722 parent `git rev-parse --verify refs/notes/foobar~2`
1723 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1724 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1728 test_expect_success \
1729 'Q: verify second notes commit' \
1730 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1731 test_cmp expect actual'
1733 cat >expect.unsorted
<<EOF
1734 100644 blob $commit1
1735 100644 blob $commit2
1736 100644 blob $commit3
1738 cat expect.unsorted |
sort >expect
1739 test_expect_success \
1740 'Q: verify second notes tree' \
1741 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1742 test_cmp expect actual'
1744 echo "$note1b_data" >expect
1745 test_expect_success \
1746 'Q: verify second note for first commit' \
1747 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1749 echo "$note2_data" >expect
1750 test_expect_success \
1751 'Q: verify first note for second commit' \
1752 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1754 echo "$note3_data" >expect
1755 test_expect_success \
1756 'Q: verify first note for third commit' \
1757 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1760 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1761 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1765 test_expect_success \
1766 'Q: verify third notes commit' \
1767 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1768 test_cmp expect actual'
1770 cat >expect.unsorted
<<EOF
1771 100644 blob $commit1
1773 cat expect.unsorted |
sort >expect
1774 test_expect_success \
1775 'Q: verify third notes tree' \
1776 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1777 test_cmp expect actual'
1779 echo "$note1c_data" >expect
1780 test_expect_success \
1781 'Q: verify third note for first commit' \
1782 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1785 parent `git rev-parse --verify refs/notes/foobar^`
1786 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1787 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1791 test_expect_success \
1792 'Q: verify fourth notes commit' \
1793 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1794 test_cmp expect actual'
1796 cat >expect.unsorted
<<EOF
1797 100644 blob $commit2
1799 cat expect.unsorted |
sort >expect
1800 test_expect_success \
1801 'Q: verify fourth notes tree' \
1802 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1803 test_cmp expect actual'
1805 echo "$note2b_data" >expect
1806 test_expect_success \
1807 'Q: verify second note for second commit' \
1808 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1811 ### series R (feature and option)
1815 feature no-such-feature-exists
1818 test_expect_success
'R: abort on unsupported feature' '
1819 test_must_fail git fast-import <input
1823 feature date-format=now
1826 test_expect_success
'R: supported feature is accepted' '
1827 git fast-import <input
1834 feature date-format=now
1837 test_expect_success
'R: abort on receiving feature after data command' '
1838 test_must_fail git fast-import <input
1842 feature import-marks=git.marks
1843 feature import-marks=git2.marks
1846 test_expect_success
'R: only one import-marks feature allowed per stream' '
1847 test_must_fail git fast-import <input
1851 feature export-marks=git.marks
1859 test_expect_success \
1860 'R: export-marks feature results in a marks file being created' \
1861 'cat input | git fast-import &&
1864 test_expect_success \
1865 'R: export-marks options can be overriden by commandline options' \
1866 'cat input | git fast-import --export-marks=other.marks &&
1867 grep :1 other.marks'
1869 test_expect_success
'R: catch typo in marks file name' '
1870 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
1871 echo "feature import-marks=nonexistent.marks" |
1872 test_must_fail git fast-import
1875 test_expect_success
'R: import and output marks can be the same file' '
1877 blob=$(echo hi | git hash-object --stdin) &&
1878 cat >expect <<-EOF &&
1882 git fast-import --export-marks=io.marks <<-\EOF &&
1889 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
1896 test_cmp expect io.marks
1899 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
1901 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
1910 test_expect_success
'R: --import-marks-if-exists' '
1912 blob=$(echo hi | git hash-object --stdin) &&
1913 echo ":1 $blob" >expect &&
1914 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
1921 test_cmp expect io.marks
1925 feature import-marks=marks.out
1926 feature export-marks=marks.new
1929 test_expect_success \
1930 'R: import to output marks works without any content' \
1931 'cat input | git fast-import &&
1932 test_cmp marks.out marks.new'
1935 feature import-marks=nonexistant.marks
1936 feature export-marks=marks.new
1939 test_expect_success \
1940 'R: import marks prefers commandline marks file over the stream' \
1941 'cat input | git fast-import --import-marks=marks.out &&
1942 test_cmp marks.out marks.new'
1946 feature import-marks=nonexistant.marks
1947 feature export-marks=combined.marks
1950 test_expect_success
'R: multiple --import-marks= should be honoured' '
1951 head -n2 marks.out > one.marks &&
1952 tail -n +3 marks.out > two.marks &&
1953 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1954 test_cmp marks.out combined.marks
1958 feature relative-marks
1959 feature import-marks=relative.in
1960 feature export-marks=relative.out
1963 test_expect_success
'R: feature relative-marks should be honoured' '
1964 mkdir -p .git/info/fast-import/ &&
1965 cp marks.new .git/info/fast-import/relative.in &&
1966 git fast-import <input &&
1967 test_cmp marks.new .git/info/fast-import/relative.out
1971 feature relative-marks
1972 feature import-marks=relative.in
1973 feature no-relative-marks
1974 feature export-marks=non-relative.out
1977 test_expect_success
'R: feature no-relative-marks should be honoured' '
1978 git fast-import <input &&
1979 test_cmp marks.new non-relative.out
1982 test_expect_success
'R: feature ls supported' '
1987 test_expect_success
'R: feature cat-blob supported' '
1988 echo "feature cat-blob" |
1992 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
1993 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
1996 test_expect_success
'R: print old blob' '
1997 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
1998 cat >expect <<-EOF &&
2003 echo "cat-blob $blob" |
2004 git fast-import --cat-blob-fd=6 6>actual &&
2005 test_cmp expect actual
2008 test_expect_success
'R: in-stream cat-blob-fd not respected' '
2009 echo hello >greeting &&
2010 blob=$(git hash-object -w greeting) &&
2011 cat >expect <<-EOF &&
2016 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2019 test_cmp expect actual.3 &&
2020 test_cmp empty actual.1 &&
2021 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2022 option cat-blob-fd=3
2025 test_cmp empty actual.3 &&
2026 test_cmp expect actual.1
2029 test_expect_success
'R: print new blob' '
2030 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2031 cat >expect <<-EOF &&
2036 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2044 test_cmp expect actual
2047 test_expect_success
'R: print new blob by sha1' '
2048 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2049 cat >expect <<-EOF &&
2051 a new blob named by sha1
2054 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2057 a new blob named by sha1
2061 test_cmp expect actual
2064 test_expect_success
'setup: big file' '
2066 echo "the quick brown fox jumps over the lazy dog" >big &&
2069 cat big big big big >bigger &&
2070 cat bigger bigger bigger bigger >big ||
2076 test_expect_success
'R: print two blobs to stdout' '
2077 blob1=$(git hash-object big) &&
2078 blob1_len=$(wc -c <big) &&
2079 blob2=$(echo hello | git hash-object --stdin) &&
2081 echo ${blob1} blob $blob1_len &&
2091 cat <<-\END_PART1 &&
2108 git fast-import >actual &&
2109 test_cmp expect actual
2112 test_expect_success PIPE
'R: copy using cat-file' '
2113 expect_id=$(git hash-object big) &&
2114 expect_len=$(wc -c <big) &&
2115 echo $expect_id blob $expect_len >expect.response &&
2118 cat >frontend <<-\FRONTEND_END &&
2124 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2137 read blob_id type size <&3 &&
2138 echo "$blob_id $type $size" >response &&
2139 head_c $size >blob <&3 &&
2143 commit refs/heads/copied
2144 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2146 copy big file as file3
2154 git fast-import --cat-blob-fd=3 3>blobs &&
2155 git show copied:file3 >actual &&
2156 test_cmp expect.response response &&
2160 test_expect_success PIPE
'R: print blob mid-commit' '
2162 echo "A blob from _before_ the commit." >expect &&
2171 A blob from _before_ the commit.
2173 commit refs/heads/temporary
2174 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2181 read blob_id type size <&3 &&
2182 head_c $size >actual <&3 &&
2187 git fast-import --cat-blob-fd=3 3>blobs &&
2188 test_cmp expect actual
2191 test_expect_success PIPE
'R: print staged blob within commit' '
2193 echo "A blob from _within_ the commit." >expect &&
2199 commit refs/heads/within
2200 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2206 A blob from _within_ the commit.
2211 echo "A blob from _within_ the commit." |
2212 git hash-object --stdin
2214 echo "cat-blob $to_get" &&
2216 read blob_id type size <&3 &&
2217 head_c $size >actual <&3 &&
2222 git fast-import --cat-blob-fd=3 3>blobs &&
2223 test_cmp expect actual
2234 test_expect_success
'R: quiet option results in no stats being output' '
2235 cat input | git fast-import 2> output &&
2236 test_cmp empty output
2240 option git non-existing-option
2243 test_expect_success
'R: die on unknown option' '
2244 test_must_fail git fast-import <input
2247 test_expect_success
'R: unknown commandline options are rejected' '\
2248 test_must_fail git fast-import --non-existing-option < /dev/null
2251 test_expect_success
'R: die on invalid option argument' '
2252 echo "option git active-branches=-5" |
2253 test_must_fail git fast-import &&
2254 echo "option git depth=" |
2255 test_must_fail git fast-import &&
2256 test_must_fail git fast-import --depth="5 elephants" </dev/null
2260 option non-existing-vcs non-existing-option
2263 test_expect_success
'R: ignore non-git options' '
2264 git fast-import <input
2268 ## R: very large blobs
2270 blobsize
=$
((2*1024*1024 + 53))
2271 test-genrandom bar
$blobsize >expect
2272 cat >input
<<INPUT_END
2273 commit refs/heads/big-file
2274 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2283 cat >>input
<<INPUT_END
2290 test_expect_success \
2291 'R: blob bigger than threshold' \
2292 'test_create_repo R &&
2293 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2294 test_expect_success \
2295 'R: verify created pack' \
2297 for p in R/.git/objects/pack/*.pack;
2299 git verify-pack -v $p >>verify || exit;
2301 test_expect_success \
2302 'R: verify written objects' \
2303 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2304 test_cmp expect actual &&
2305 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2306 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2308 test_expect_success \
2309 'R: blob appears only once' \
2310 'n=$(grep $a verify | wc -l) &&