3 # Copyright (c) 2007 Shawn Pearce
6 test_description
='test git fast-import utility'
8 .
"$TEST_DIRECTORY"/diff-lib.sh
;# test-lib chdir's into trash
10 # Print $1 bytes from stdin to stdout.
12 # This could be written as "head -c $1", but IRIX "head" does not
13 # support the -c option.
19 my $nread = sysread(STDIN, $s, $len);
20 die "cannot read: $!" unless defined($nread);
37 file5_data
='an inline file.
38 we should see it later.'
45 test_expect_success
'setup: have pipes?' '
59 test_expect_success
'empty stream succeeds' '
60 git fast-import </dev/null
63 cat >input
<<INPUT_END
80 commit refs/heads/master
82 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
94 An annotated tag without a tagger
99 'A: create pack from stdin' \
100 'git fast-import --export-marks=marks.out <input &&
101 git whatchanged master'
102 test_expect_success \
104 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
107 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
108 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
112 test_expect_success \
114 'git cat-file commit master | sed 1d >actual &&
115 test_cmp expect actual'
122 test_expect_success \
124 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
125 test_cmp expect actual'
127 echo "$file2_data" >expect
128 test_expect_success \
130 'git cat-file blob master:file2 >actual && test_cmp expect actual'
132 echo "$file3_data" >expect
133 test_expect_success \
135 'git cat-file blob master:file3 >actual && test_cmp expect actual'
137 printf "$file4_data" >expect
138 test_expect_success \
140 'git cat-file blob master:file4 >actual && test_cmp expect actual'
143 object $(git rev-parse refs/heads/master)
147 An annotated tag without a tagger
149 test_expect_success
'A: verify tag/series-A' '
150 git cat-file tag tags/series-A >actual &&
151 test_cmp expect actual
155 :2 `git rev-parse --verify master:file2`
156 :3 `git rev-parse --verify master:file3`
157 :4 `git rev-parse --verify master:file4`
158 :5 `git rev-parse --verify master^0`
160 test_expect_success \
161 'A: verify marks output' \
162 'test_cmp expect marks.out'
164 test_expect_success \
165 'A: verify marks import' \
167 --import-marks=marks.out \
168 --export-marks=marks.new \
170 test_cmp expect marks.new'
173 cat >input
<<INPUT_END
174 commit refs/heads/verify--import-marks
175 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
181 M 755 :2 copy-of-file2
184 test_expect_success \
185 'A: verify marks import does not crash' \
186 'git fast-import --import-marks=marks.out <input &&
187 git whatchanged verify--import-marks'
188 test_expect_success \
190 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
192 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
194 git diff-tree
-M -r master verify--import-marks
>actual
195 test_expect_success \
197 'compare_diff_raw expect actual &&
198 test `git rev-parse --verify master:file2` \
199 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
202 mt
=$
(git hash-object
--stdin < /dev
/null
)
207 cat >input.commit
<<EOF
208 commit refs/heads/verify--dump-marks
209 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
211 test the sparse array dumping routines with exponentially growing marks
219 while test "$i" -lt 27; do
220 cat >>input.blob
<<EOF
231 echo "M 100644 :$l l$i" >>input.commit
232 echo "M 100644 :$m m$i" >>input.commit
233 echo "M 100644 :$n n$i" >>input.commit
235 echo ":$l $mt" >>marks.exp
236 echo ":$m $mt" >>marks.exp
237 echo ":$n $mt" >>marks.exp
239 printf "100644 blob $mt\tl$i\n" >>tree.exp
240 printf "100644 blob $mt\tm$i\n" >>tree.exp
241 printf "100644 blob $mt\tn$i\n" >>tree.exp
250 sort tree.exp
> tree.exp_s
252 test_expect_success
'A: export marks with large values' '
253 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
254 git ls-tree refs/heads/verify--dump-marks >tree.out &&
255 test_cmp tree.exp_s tree.out &&
256 test_cmp marks.exp marks.large'
263 cat >input
<<INPUT_END
264 commit refs/heads/branch
266 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
271 from refs/heads/master
272 M 755 0000000000000000000000000000000000000001 zero1
275 test_expect_success
'B: fail on invalid blob sha1' '
276 test_must_fail git fast-import <input
278 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
280 cat >input
<<INPUT_END
281 commit .badbranchname
282 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
287 from refs/heads/master
290 test_expect_success
'B: fail on invalid branch name ".badbranchname"' '
291 test_must_fail git fast-import <input
293 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
295 cat >input
<<INPUT_END
296 commit bad[branch]name
297 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
302 from refs/heads/master
305 test_expect_success
'B: fail on invalid branch name "bad[branch]name"' '
306 test_must_fail git fast-import <input
308 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
310 cat >input
<<INPUT_END
312 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
317 from refs/heads/master
320 test_expect_success \
321 'B: accept branch name "TEMP_TAG"' \
322 'git fast-import <input &&
323 test -f .git/TEMP_TAG &&
324 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
327 git gc
2>/dev
/null
>/dev
/null
328 git prune
2>/dev
/null
>/dev
/null
330 cat >input
<<INPUT_END
331 commit refs/heads/empty-committer-1
332 committer <> $GIT_COMMITTER_DATE
337 test_expect_success
'B: accept empty committer' '
338 git fast-import <input &&
343 git update-ref
-d refs
/heads
/empty-committer-1 || true
345 git gc
2>/dev
/null
>/dev
/null
346 git prune
2>/dev
/null
>/dev
/null
348 cat >input
<<INPUT_END
349 commit refs/heads/empty-committer-2
350 committer <a@b.com> $GIT_COMMITTER_DATE
355 test_expect_failure
'B: accept and fixup committer with no name' '
356 git fast-import <input &&
361 git update-ref
-d refs
/heads
/empty-committer-2 || true
363 git gc
2>/dev
/null
>/dev
/null
364 git prune
2>/dev
/null
>/dev
/null
366 cat >input
<<INPUT_END
367 commit refs/heads/invalid-committer
368 committer Name email> $GIT_COMMITTER_DATE
373 test_expect_failure
'B: fail on invalid committer (1)' '
374 test_must_fail git fast-import <input
376 git update-ref
-d refs
/heads
/invalid-committer || true
378 cat >input
<<INPUT_END
379 commit refs/heads/invalid-committer
380 committer Name <e<mail> $GIT_COMMITTER_DATE
385 test_expect_failure
'B: fail on invalid committer (2)' '
386 test_must_fail git fast-import <input
388 git update-ref
-d refs
/heads
/invalid-committer || true
390 cat >input
<<INPUT_END
391 commit refs/heads/invalid-committer
392 committer Name <email>> $GIT_COMMITTER_DATE
397 test_expect_failure
'B: fail on invalid committer (3)' '
398 test_must_fail git fast-import <input
400 git update-ref
-d refs
/heads
/invalid-committer || true
402 cat >input
<<INPUT_END
403 commit refs/heads/invalid-committer
404 committer Name <email $GIT_COMMITTER_DATE
409 test_expect_failure
'B: fail on invalid committer (4)' '
410 test_must_fail git fast-import <input
412 git update-ref
-d refs
/heads
/invalid-committer || true
414 cat >input
<<INPUT_END
415 commit refs/heads/invalid-committer
416 committer Name<email> $GIT_COMMITTER_DATE
421 test_expect_failure
'B: fail on invalid committer (5)' '
422 test_must_fail git fast-import <input
424 git update-ref
-d refs
/heads
/invalid-committer || true
430 newf
=`echo hi newf | git hash-object -w --stdin`
431 oldf
=`git rev-parse --verify master:file2`
433 cat >input
<<INPUT_END
434 commit refs/heads/branch
435 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
440 from refs/heads/master
441 M 644 $oldf file2/oldf
442 M 755 $newf file2/newf
446 test_expect_success \
447 'C: incremental import create pack from stdin' \
448 'git fast-import <input &&
449 git whatchanged branch'
450 test_expect_success \
452 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
453 test_expect_success \
454 'C: validate reuse existing blob' \
455 'test $newf = `git rev-parse --verify branch:file2/newf` &&
456 test $oldf = `git rev-parse --verify branch:file2/oldf`'
459 parent `git rev-parse --verify master^0`
460 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
461 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
465 test_expect_success \
467 'git cat-file commit branch | sed 1d >actual &&
468 test_cmp expect actual'
471 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
472 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
473 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
475 git diff-tree
-M -r master branch
>actual
476 test_expect_success \
477 'C: validate rename result' \
478 'compare_diff_raw expect actual'
485 cat >input
<<INPUT_END
486 commit refs/heads/branch
487 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
492 from refs/heads/branch^0
493 M 644 inline newdir/interesting
498 M 755 inline newdir/exec.sh
504 test_expect_success \
505 'D: inline data in commit' \
506 'git fast-import <input &&
507 git whatchanged branch'
508 test_expect_success \
510 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
513 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
514 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
516 git diff-tree
-M -r branch^ branch
>actual
517 test_expect_success \
518 'D: validate new files added' \
519 'compare_diff_raw expect actual'
521 echo "$file5_data" >expect
522 test_expect_success \
524 'git cat-file blob branch:newdir/interesting >actual &&
525 test_cmp expect actual'
527 echo "$file6_data" >expect
528 test_expect_success \
530 'git cat-file blob branch:newdir/exec.sh >actual &&
531 test_cmp expect actual'
537 cat >input
<<INPUT_END
538 commit refs/heads/branch
539 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
540 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
545 from refs/heads/branch^0
548 test_expect_success
'E: rfc2822 date, --date-format=raw' '
549 test_must_fail git fast-import --date-format=raw <input
551 test_expect_success \
552 'E: rfc2822 date, --date-format=rfc2822' \
553 'git fast-import --date-format=rfc2822 <input'
554 test_expect_success \
556 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
559 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
560 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
564 test_expect_success \
566 'git cat-file commit branch | sed 1,2d >actual &&
567 test_cmp expect actual'
573 old_branch
=`git rev-parse --verify branch^0`
575 cat >input
<<INPUT_END
576 commit refs/heads/branch
577 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
579 losing things already?
582 from refs/heads/branch~1
584 reset refs/heads/other
585 from refs/heads/branch
588 test_expect_success \
589 'F: non-fast-forward update skips' \
590 'if git fast-import <input
592 echo BAD gfi did not fail
595 if test $old_branch = `git rev-parse --verify branch^0`
597 : branch unaffected and failure returned
600 echo BAD gfi changed branch $old_branch
605 test_expect_success \
607 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
610 tree `git rev-parse branch~1^{tree}`
611 parent `git rev-parse branch~1`
612 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
613 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
615 losing things already?
617 test_expect_success \
618 'F: verify other commit' \
619 'git cat-file commit other >actual &&
620 test_cmp expect actual'
626 old_branch
=`git rev-parse --verify branch^0`
628 cat >input
<<INPUT_END
629 commit refs/heads/branch
630 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
632 losing things already?
635 from refs/heads/branch~1
638 test_expect_success \
639 'G: non-fast-forward update forced' \
640 'git fast-import --force <input'
641 test_expect_success \
643 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
644 test_expect_success \
645 'G: branch changed, but logged' \
646 'test $old_branch != `git rev-parse --verify branch^0` &&
647 test $old_branch = `git rev-parse --verify branch@{1}`'
654 cat >input
<<INPUT_END
656 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
661 from refs/heads/branch^0
662 M 644 inline i-will-die
664 this file will never exist.
668 M 644 inline h/e/l/lo
674 test_expect_success \
675 'H: deletall, add 1' \
676 'git fast-import <input &&
678 test_expect_success \
680 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
683 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
684 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
685 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
686 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
687 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
689 git diff-tree
-M -r H^ H
>actual
690 test_expect_success \
691 'H: validate old files removed, new files added' \
692 'compare_diff_raw expect actual'
694 echo "$file5_data" >expect
695 test_expect_success \
697 'git cat-file blob H:h/e/l/lo >actual &&
698 test_cmp expect actual'
704 cat >input
<<INPUT_END
705 commit refs/heads/export-boundary
706 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
708 we have a border. its only 40 characters wide.
711 from refs/heads/branch
714 test_expect_success \
715 'I: export-pack-edges' \
716 'git fast-import --export-pack-edges=edges.list <input'
719 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
721 test_expect_success \
722 'I: verify edge list' \
723 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
724 test_cmp expect actual'
730 cat >input
<<INPUT_END
732 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
737 from refs/heads/branch
742 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
748 test_expect_success \
749 'J: reset existing branch creates empty commit' \
750 'git fast-import <input'
751 test_expect_success \
752 'J: branch has 1 commit, empty tree' \
753 'test 1 = `git rev-list J | wc -l` &&
754 test 0 = `git ls-tree J | wc -l`'
760 cat >input
<<INPUT_END
762 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
767 from refs/heads/branch
770 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
775 from refs/heads/branch^1
778 test_expect_success \
779 'K: reinit branch with from' \
780 'git fast-import <input'
781 test_expect_success \
782 'K: verify K^1 = branch^1' \
783 'test `git rev-parse --verify branch^1` \
784 = `git rev-parse --verify K^1`'
790 cat >input
<<INPUT_END
804 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
814 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
824 cat >expect
<<EXPECT_END
825 :100644 100644 4268632... 55d3a52... M b.
826 :040000 040000 0ae5cac... 443c768... M b
827 :100644 100644 4268632... 55d3a52... M ba
830 test_expect_success \
831 'L: verify internal tree sorting' \
832 'git fast-import <input &&
833 git diff-tree --abbrev --raw L^ L >output &&
834 test_cmp expect output'
841 cat >input
<<INPUT_END
843 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
848 from refs/heads/branch^0
849 R file2/newf file2/n.e.w.f
854 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
856 test_expect_success \
857 'M: rename file in same subdirectory' \
858 'git fast-import <input &&
859 git diff-tree -M -r M1^ M1 >actual &&
860 compare_diff_raw expect actual'
862 cat >input
<<INPUT_END
864 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
869 from refs/heads/branch^0
870 R file2/newf i/am/new/to/you
875 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
877 test_expect_success \
878 'M: rename file to new subdirectory' \
879 'git fast-import <input &&
880 git diff-tree -M -r M2^ M2 >actual &&
881 compare_diff_raw expect actual'
883 cat >input
<<INPUT_END
885 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
896 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
898 test_expect_success \
899 'M: rename subdirectory to new subdirectory' \
900 'git fast-import <input &&
901 git diff-tree -M -r M3^ M3 >actual &&
902 compare_diff_raw expect actual'
909 cat >input
<<INPUT_END
911 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
916 from refs/heads/branch^0
917 C file2/newf file2/n.e.w.f
922 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
924 test_expect_success \
925 'N: copy file in same subdirectory' \
926 'git fast-import <input &&
927 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
928 compare_diff_raw expect actual'
930 cat >input
<<INPUT_END
932 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
937 from refs/heads/branch^0
941 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
943 modify directory copy
946 M 644 inline file3/file5
954 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
955 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
956 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
958 test_expect_success \
959 'N: copy then modify subdirectory' \
960 'git fast-import <input &&
961 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
962 compare_diff_raw expect actual'
964 cat >input
<<INPUT_END
966 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
971 from refs/heads/branch^0
972 M 644 inline file2/file5
982 test_expect_success \
983 'N: copy dirty subdirectory' \
984 'git fast-import <input &&
985 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
987 test_expect_success \
988 'N: copy directory by id' \
989 'cat >expect <<-\EOF &&
990 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
991 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
993 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
994 cat >input <<-INPUT_END &&
996 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1001 from refs/heads/branch^0
1002 M 040000 $subdir file3
1004 git fast-import <input &&
1005 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1006 compare_diff_raw expect actual'
1008 test_expect_success PIPE
'N: read and copy directory' '
1010 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1011 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1013 git update-ref -d refs/heads/N4 &&
1019 commit refs/heads/N4
1020 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1022 copy by tree hash, part 2
1025 from refs/heads/branch^0
1028 read mode type tree filename &&
1029 echo "M 040000 $tree file3"
1031 git fast-import --cat-blob-fd=3 3>backflow &&
1032 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1033 compare_diff_raw expect actual
1036 test_expect_success PIPE
'N: empty directory reads as missing' '
1037 cat <<-\EOF >expect &&
1039 :000000 100644 OBJNAME OBJNAME A unrelated
1041 echo "missing src" >expect.response &&
1042 git update-ref -d refs/heads/read-empty &&
1048 commit refs/heads/read-empty
1049 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1051 read "empty" (missing) directory
1054 M 100644 inline src/greeting
1058 C src/greeting dst1/non-greeting
1059 C src/greeting unrelated
1060 # leave behind "empty" src directory
1065 printf "%s\n" "$line" >response &&
1071 git fast-import --cat-blob-fd=3 3>backflow &&
1072 test_cmp expect.response response &&
1073 git rev-list read-empty |
1074 git diff-tree -r --root --stdin |
1075 sed "s/$_x40/OBJNAME/g" >actual &&
1076 test_cmp expect actual
1079 test_expect_success \
1080 'N: copy root directory by tree hash' \
1081 'cat >expect <<-\EOF &&
1082 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1083 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1085 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1086 cat >input <<-INPUT_END &&
1087 commit refs/heads/N6
1088 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1090 copy root directory by tree hash
1093 from refs/heads/branch^0
1096 git fast-import <input &&
1097 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1098 compare_diff_raw expect actual'
1100 test_expect_success \
1101 'N: delete directory by copying' \
1102 'cat >expect <<-\EOF &&
1104 :100644 000000 OBJID OBJID D foo/bar/qux
1106 :000000 100644 OBJID OBJID A foo/bar/baz
1107 :000000 100644 OBJID OBJID A foo/bar/qux
1109 empty_tree=$(git mktree </dev/null) &&
1110 cat >input <<-INPUT_END &&
1111 commit refs/heads/N-delete
1112 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1114 collect data to be deleted
1118 M 100644 inline foo/bar/baz
1122 C "foo/bar/baz" "foo/bar/qux"
1123 C "foo/bar/baz" "foo/bar/quux/1"
1124 C "foo/bar/baz" "foo/bar/quuux"
1125 M 040000 $empty_tree foo/bar/quux
1126 M 040000 $empty_tree foo/bar/quuux
1128 commit refs/heads/N-delete
1129 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1134 M 040000 $empty_tree foo/bar/qux
1136 git fast-import <input &&
1137 git rev-list N-delete |
1138 git diff-tree -r --stdin --root --always |
1139 sed -e "s/$_x40/OBJID/g" >actual &&
1140 test_cmp expect actual'
1142 test_expect_success \
1143 'N: modify copied tree' \
1144 'cat >expect <<-\EOF &&
1145 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1146 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1147 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1149 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1150 cat >input <<-INPUT_END &&
1151 commit refs/heads/N5
1152 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1157 from refs/heads/branch^0
1158 M 040000 $subdir file3
1160 commit refs/heads/N5
1161 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1163 modify directory copy
1166 M 644 inline file3/file5
1171 git fast-import <input &&
1172 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1173 compare_diff_raw expect actual'
1175 test_expect_success \
1176 'N: reject foo/ syntax' \
1177 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1178 test_must_fail git fast-import <<-INPUT_END
1179 commit refs/heads/N5B
1180 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1182 copy with invalid syntax
1185 from refs/heads/branch^0
1186 M 040000 $subdir file3/
1189 test_expect_success \
1190 'N: copy to root by id and modify' \
1191 'echo "hello, world" >expect.foo &&
1192 echo hello >expect.bar &&
1193 git fast-import <<-SETUP_END &&
1194 commit refs/heads/N7
1195 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1201 M 644 inline foo/bar
1207 tree=$(git rev-parse --verify N7:) &&
1208 git fast-import <<-INPUT_END &&
1209 commit refs/heads/N8
1210 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1212 copy to root by id and modify
1216 M 644 inline foo/foo
1221 git show N8:foo/foo >actual.foo &&
1222 git show N8:foo/bar >actual.bar &&
1223 test_cmp expect.foo actual.foo &&
1224 test_cmp expect.bar actual.bar'
1226 test_expect_success \
1227 'N: extract subtree' \
1228 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1229 cat >input <<-INPUT_END &&
1230 commit refs/heads/N9
1231 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1233 extract subtree branch:newdir
1239 git fast-import <input &&
1240 git diff --exit-code branch:newdir N9'
1242 test_expect_success \
1243 'N: modify subtree, extract it, and modify again' \
1244 'echo hello >expect.baz &&
1245 echo hello, world >expect.qux &&
1246 git fast-import <<-SETUP_END &&
1247 commit refs/heads/N10
1248 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1254 M 644 inline foo/bar/baz
1260 tree=$(git rev-parse --verify N10:) &&
1261 git fast-import <<-INPUT_END &&
1262 commit refs/heads/N11
1263 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1265 copy to root by id and modify
1269 M 100644 inline foo/bar/qux
1274 C "bar/qux" "bar/quux"
1276 git show N11:bar/baz >actual.baz &&
1277 git show N11:bar/qux >actual.qux &&
1278 git show N11:bar/quux >actual.quux &&
1279 test_cmp expect.baz actual.baz &&
1280 test_cmp expect.qux actual.qux &&
1281 test_cmp expect.qux actual.quux'
1287 cat >input
<<INPUT_END
1289 commit refs/heads/O1
1290 # -- ignore all of this text
1291 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1292 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1294 dirty directory copy
1297 # don't forget the import blank line!
1299 # yes, we started from our usual base of branch^0.
1301 from refs/heads/branch^0
1302 # and we need to reuse file2/file5 from N3 above.
1303 M 644 inline file2/file5
1304 # otherwise the tree will be different
1309 # don't forget to copy file2 to file3
1312 # or to delete file5 from file2.
1318 test_expect_success \
1319 'O: comments are all skipped' \
1320 'git fast-import <input &&
1321 test `git rev-parse N3` = `git rev-parse O1`'
1323 cat >input
<<INPUT_END
1324 commit refs/heads/O2
1325 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1327 dirty directory copy
1329 from refs/heads/branch^0
1330 M 644 inline file2/file5
1339 test_expect_success \
1340 'O: blank lines not necessary after data commands' \
1341 'git fast-import <input &&
1342 test `git rev-parse N3` = `git rev-parse O2`'
1344 test_expect_success \
1345 'O: repack before next test' \
1348 cat >input
<<INPUT_END
1349 commit refs/heads/O3
1350 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1354 commit refs/heads/O3
1355 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1360 commit refs/heads/O3
1362 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1367 commit refs/heads/O3
1368 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1372 reset refs/tags/O3-2nd
1374 reset refs/tags/O3-3rd
1378 cat >expect
<<INPUT_END
1384 test_expect_success \
1385 'O: blank lines not necessary after other commands' \
1386 'git fast-import <input &&
1387 test 8 = `find .git/objects/pack -type f | wc -l` &&
1388 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1389 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1390 test_cmp expect actual'
1392 cat >input
<<INPUT_END
1393 commit refs/heads/O4
1394 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1398 commit refs/heads/O4
1399 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1403 progress Two commits down, 2 to go!
1404 commit refs/heads/O4
1405 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1409 progress Three commits down, 1 to go!
1410 commit refs/heads/O4
1411 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1417 test_expect_success \
1418 'O: progress outputs as requested by input' \
1419 'git fast-import <input >actual &&
1420 grep "progress " <input >expect &&
1421 test_cmp expect actual'
1424 ### series P (gitlinks)
1427 cat >input
<<INPUT_END
1433 reset refs/heads/sub
1434 commit refs/heads/sub
1436 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1449 commit refs/heads/subuse1
1451 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1454 from refs/heads/master
1455 M 100644 :3 .gitmodules
1464 commit refs/heads/sub
1466 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1472 commit refs/heads/subuse1
1474 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1482 test_expect_success \
1483 'P: supermodule & submodule mix' \
1484 'git fast-import <input &&
1485 git checkout subuse1 &&
1486 rm -rf sub && mkdir sub && (cd sub &&
1488 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1489 git checkout master) &&
1490 git submodule init &&
1491 git submodule update'
1493 SUBLAST
=$
(git rev-parse
--verify sub
)
1494 SUBPREV
=$
(git rev-parse
--verify sub^
)
1496 cat >input
<<INPUT_END
1505 commit refs/heads/subuse2
1507 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1510 from refs/heads/master
1511 M 100644 :1 .gitmodules
1512 M 160000 $SUBPREV sub
1514 commit refs/heads/subuse2
1516 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1520 M 160000 $SUBLAST sub
1524 test_expect_success \
1525 'P: verbatim SHA gitlinks' \
1526 'git branch -D sub &&
1527 git gc && git prune &&
1528 git fast-import <input &&
1529 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1532 cat >input
<<INPUT_END
1533 commit refs/heads/subuse3
1535 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1540 from refs/heads/subuse2
1548 test_expect_success
'P: fail on inline gitlink' '
1549 test_must_fail git fast-import <input'
1552 cat >input
<<INPUT_END
1559 commit refs/heads/subuse3
1561 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1566 from refs/heads/subuse2
1571 test_expect_success
'P: fail on blob mark in gitlink' '
1572 test_must_fail git fast-import <input'
1575 ### series Q (notes)
1578 note1_data
="The first note for the first commit"
1579 note2_data
="The first note for the second commit"
1580 note3_data
="The first note for the third commit"
1581 note1b_data
="The second note for the first commit"
1582 note1c_data
="The third note for the first commit"
1583 note2b_data
="The second note for the second commit"
1586 cat >input
<<INPUT_END
1593 commit refs/heads/notes-test
1595 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1606 commit refs/heads/notes-test
1608 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1615 commit refs/heads/notes-test
1617 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1644 commit refs/notes/foobar
1646 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1658 commit refs/notes/foobar
1660 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1670 commit refs/notes/foobar2
1672 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1682 commit refs/notes/foobar
1684 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1697 test_expect_success \
1699 'git fast-import <input &&
1700 git whatchanged notes-test'
1701 test_expect_success \
1703 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1705 commit1
=$
(git rev-parse notes-test~
2)
1706 commit2
=$
(git rev-parse notes-test^
)
1707 commit3
=$
(git rev-parse notes-test
)
1710 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1711 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1715 test_expect_success \
1716 'Q: verify first commit' \
1717 'git cat-file commit notes-test~2 | sed 1d >actual &&
1718 test_cmp expect actual'
1722 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1723 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1727 test_expect_success \
1728 'Q: verify second commit' \
1729 'git cat-file commit notes-test^ | sed 1d >actual &&
1730 test_cmp expect actual'
1734 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1735 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1739 test_expect_success \
1740 'Q: verify third commit' \
1741 'git cat-file commit notes-test | sed 1d >actual &&
1742 test_cmp expect actual'
1745 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1746 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1750 test_expect_success \
1751 'Q: verify first notes commit' \
1752 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1753 test_cmp expect actual'
1755 cat >expect.unsorted
<<EOF
1756 100644 blob $commit1
1757 100644 blob $commit2
1758 100644 blob $commit3
1760 cat expect.unsorted |
sort >expect
1761 test_expect_success \
1762 'Q: verify first notes tree' \
1763 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1764 test_cmp expect actual'
1766 echo "$note1_data" >expect
1767 test_expect_success \
1768 'Q: verify first note for first commit' \
1769 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1771 echo "$note2_data" >expect
1772 test_expect_success \
1773 'Q: verify first note for second commit' \
1774 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1776 echo "$note3_data" >expect
1777 test_expect_success \
1778 'Q: verify first note for third commit' \
1779 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1782 parent `git rev-parse --verify refs/notes/foobar~2`
1783 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1784 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1788 test_expect_success \
1789 'Q: verify second notes commit' \
1790 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1791 test_cmp expect actual'
1793 cat >expect.unsorted
<<EOF
1794 100644 blob $commit1
1795 100644 blob $commit2
1796 100644 blob $commit3
1798 cat expect.unsorted |
sort >expect
1799 test_expect_success \
1800 'Q: verify second notes tree' \
1801 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1802 test_cmp expect actual'
1804 echo "$note1b_data" >expect
1805 test_expect_success \
1806 'Q: verify second note for first commit' \
1807 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1809 echo "$note2_data" >expect
1810 test_expect_success \
1811 'Q: verify first note for second commit' \
1812 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1814 echo "$note3_data" >expect
1815 test_expect_success \
1816 'Q: verify first note for third commit' \
1817 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1820 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1821 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1825 test_expect_success \
1826 'Q: verify third notes commit' \
1827 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1828 test_cmp expect actual'
1830 cat >expect.unsorted
<<EOF
1831 100644 blob $commit1
1833 cat expect.unsorted |
sort >expect
1834 test_expect_success \
1835 'Q: verify third notes tree' \
1836 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1837 test_cmp expect actual'
1839 echo "$note1c_data" >expect
1840 test_expect_success \
1841 'Q: verify third note for first commit' \
1842 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1845 parent `git rev-parse --verify refs/notes/foobar^`
1846 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1847 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1851 test_expect_success \
1852 'Q: verify fourth notes commit' \
1853 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1854 test_cmp expect actual'
1856 cat >expect.unsorted
<<EOF
1857 100644 blob $commit2
1859 cat expect.unsorted |
sort >expect
1860 test_expect_success \
1861 'Q: verify fourth notes tree' \
1862 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1863 test_cmp expect actual'
1865 echo "$note2b_data" >expect
1866 test_expect_success \
1867 'Q: verify second note for second commit' \
1868 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1871 ### series R (feature and option)
1875 feature no-such-feature-exists
1878 test_expect_success
'R: abort on unsupported feature' '
1879 test_must_fail git fast-import <input
1883 feature date-format=now
1886 test_expect_success
'R: supported feature is accepted' '
1887 git fast-import <input
1894 feature date-format=now
1897 test_expect_success
'R: abort on receiving feature after data command' '
1898 test_must_fail git fast-import <input
1902 feature import-marks=git.marks
1903 feature import-marks=git2.marks
1906 test_expect_success
'R: only one import-marks feature allowed per stream' '
1907 test_must_fail git fast-import <input
1911 feature export-marks=git.marks
1919 test_expect_success \
1920 'R: export-marks feature results in a marks file being created' \
1921 'cat input | git fast-import &&
1924 test_expect_success \
1925 'R: export-marks options can be overriden by commandline options' \
1926 'cat input | git fast-import --export-marks=other.marks &&
1927 grep :1 other.marks'
1929 test_expect_success
'R: catch typo in marks file name' '
1930 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
1931 echo "feature import-marks=nonexistent.marks" |
1932 test_must_fail git fast-import
1935 test_expect_success
'R: import and output marks can be the same file' '
1937 blob=$(echo hi | git hash-object --stdin) &&
1938 cat >expect <<-EOF &&
1942 git fast-import --export-marks=io.marks <<-\EOF &&
1949 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
1956 test_cmp expect io.marks
1959 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
1961 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
1970 test_expect_success
'R: --import-marks-if-exists' '
1972 blob=$(echo hi | git hash-object --stdin) &&
1973 echo ":1 $blob" >expect &&
1974 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
1981 test_cmp expect io.marks
1985 feature import-marks=marks.out
1986 feature export-marks=marks.new
1989 test_expect_success \
1990 'R: import to output marks works without any content' \
1991 'cat input | git fast-import &&
1992 test_cmp marks.out marks.new'
1995 feature import-marks=nonexistent.marks
1996 feature export-marks=marks.new
1999 test_expect_success \
2000 'R: import marks prefers commandline marks file over the stream' \
2001 'cat input | git fast-import --import-marks=marks.out &&
2002 test_cmp marks.out marks.new'
2006 feature import-marks=nonexistent.marks
2007 feature export-marks=combined.marks
2010 test_expect_success
'R: multiple --import-marks= should be honoured' '
2011 head -n2 marks.out > one.marks &&
2012 tail -n +3 marks.out > two.marks &&
2013 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2014 test_cmp marks.out combined.marks
2018 feature relative-marks
2019 feature import-marks=relative.in
2020 feature export-marks=relative.out
2023 test_expect_success
'R: feature relative-marks should be honoured' '
2024 mkdir -p .git/info/fast-import/ &&
2025 cp marks.new .git/info/fast-import/relative.in &&
2026 git fast-import <input &&
2027 test_cmp marks.new .git/info/fast-import/relative.out
2031 feature relative-marks
2032 feature import-marks=relative.in
2033 feature no-relative-marks
2034 feature export-marks=non-relative.out
2037 test_expect_success
'R: feature no-relative-marks should be honoured' '
2038 git fast-import <input &&
2039 test_cmp marks.new non-relative.out
2042 test_expect_success
'R: feature ls supported' '
2047 test_expect_success
'R: feature cat-blob supported' '
2048 echo "feature cat-blob" |
2052 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
2053 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2056 test_expect_success
'R: print old blob' '
2057 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2058 cat >expect <<-EOF &&
2063 echo "cat-blob $blob" |
2064 git fast-import --cat-blob-fd=6 6>actual &&
2065 test_cmp expect actual
2068 test_expect_success
'R: in-stream cat-blob-fd not respected' '
2069 echo hello >greeting &&
2070 blob=$(git hash-object -w greeting) &&
2071 cat >expect <<-EOF &&
2076 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2079 test_cmp expect actual.3 &&
2080 test_cmp empty actual.1 &&
2081 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2082 option cat-blob-fd=3
2085 test_cmp empty actual.3 &&
2086 test_cmp expect actual.1
2089 test_expect_success
'R: print new blob' '
2090 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2091 cat >expect <<-EOF &&
2096 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2104 test_cmp expect actual
2107 test_expect_success
'R: print new blob by sha1' '
2108 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2109 cat >expect <<-EOF &&
2111 a new blob named by sha1
2114 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2117 a new blob named by sha1
2121 test_cmp expect actual
2124 test_expect_success
'setup: big file' '
2126 echo "the quick brown fox jumps over the lazy dog" >big &&
2129 cat big big big big >bigger &&
2130 cat bigger bigger bigger bigger >big ||
2136 test_expect_success
'R: print two blobs to stdout' '
2137 blob1=$(git hash-object big) &&
2138 blob1_len=$(wc -c <big) &&
2139 blob2=$(echo hello | git hash-object --stdin) &&
2141 echo ${blob1} blob $blob1_len &&
2151 cat <<-\END_PART1 &&
2168 git fast-import >actual &&
2169 test_cmp expect actual
2172 test_expect_success PIPE
'R: copy using cat-file' '
2173 expect_id=$(git hash-object big) &&
2174 expect_len=$(wc -c <big) &&
2175 echo $expect_id blob $expect_len >expect.response &&
2178 cat >frontend <<-\FRONTEND_END &&
2184 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2197 read blob_id type size <&3 &&
2198 echo "$blob_id $type $size" >response &&
2199 head_c $size >blob <&3 &&
2203 commit refs/heads/copied
2204 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2206 copy big file as file3
2214 git fast-import --cat-blob-fd=3 3>blobs &&
2215 git show copied:file3 >actual &&
2216 test_cmp expect.response response &&
2220 test_expect_success PIPE
'R: print blob mid-commit' '
2222 echo "A blob from _before_ the commit." >expect &&
2231 A blob from _before_ the commit.
2233 commit refs/heads/temporary
2234 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2241 read blob_id type size <&3 &&
2242 head_c $size >actual <&3 &&
2247 git fast-import --cat-blob-fd=3 3>blobs &&
2248 test_cmp expect actual
2251 test_expect_success PIPE
'R: print staged blob within commit' '
2253 echo "A blob from _within_ the commit." >expect &&
2259 commit refs/heads/within
2260 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2266 A blob from _within_ the commit.
2271 echo "A blob from _within_ the commit." |
2272 git hash-object --stdin
2274 echo "cat-blob $to_get" &&
2276 read blob_id type size <&3 &&
2277 head_c $size >actual <&3 &&
2282 git fast-import --cat-blob-fd=3 3>blobs &&
2283 test_cmp expect actual
2294 test_expect_success
'R: quiet option results in no stats being output' '
2295 cat input | git fast-import 2> output &&
2296 test_cmp empty output
2300 option git non-existing-option
2303 test_expect_success
'R: die on unknown option' '
2304 test_must_fail git fast-import <input
2307 test_expect_success
'R: unknown commandline options are rejected' '\
2308 test_must_fail git fast-import --non-existing-option < /dev/null
2311 test_expect_success
'R: die on invalid option argument' '
2312 echo "option git active-branches=-5" |
2313 test_must_fail git fast-import &&
2314 echo "option git depth=" |
2315 test_must_fail git fast-import &&
2316 test_must_fail git fast-import --depth="5 elephants" </dev/null
2320 option non-existing-vcs non-existing-option
2323 test_expect_success
'R: ignore non-git options' '
2324 git fast-import <input
2328 ## R: very large blobs
2330 blobsize
=$
((2*1024*1024 + 53))
2331 test-genrandom bar
$blobsize >expect
2332 cat >input
<<INPUT_END
2333 commit refs/heads/big-file
2334 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2343 cat >>input
<<INPUT_END
2350 test_expect_success \
2351 'R: blob bigger than threshold' \
2352 'test_create_repo R &&
2353 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2354 test_expect_success \
2355 'R: verify created pack' \
2357 for p in R/.git/objects/pack/*.pack;
2359 git verify-pack -v $p >>verify || exit;
2361 test_expect_success \
2362 'R: verify written objects' \
2363 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2364 test_cmp expect actual &&
2365 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2366 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2368 test_expect_success \
2369 'R: blob appears only once' \
2370 'n=$(grep $a verify | wc -l) &&