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);
28 for p
in .git
/objects
/pack
/*.pack
30 git verify-pack
"$@" "$p" ||
return
44 file5_data
='an inline file.
45 we should see it later.'
58 test_expect_success
'empty stream succeeds' '
59 git fast-import </dev/null
62 cat >input
<<INPUT_END
79 commit refs/heads/master
81 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
93 An annotated tag without a tagger
99 An annotated tag that annotates a blob.
103 test_expect_success \
104 'A: create pack from stdin' \
105 'git fast-import --export-marks=marks.out <input &&
106 git whatchanged master'
108 test_expect_success
'A: verify pack' '
113 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
114 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
118 test_expect_success \
120 'git cat-file commit master | sed 1d >actual &&
121 test_cmp expect actual'
128 test_expect_success \
130 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
131 test_cmp expect actual'
133 echo "$file2_data" >expect
134 test_expect_success \
136 'git cat-file blob master:file2 >actual && test_cmp expect actual'
138 echo "$file3_data" >expect
139 test_expect_success \
141 'git cat-file blob master:file3 >actual && test_cmp expect actual'
143 printf "$file4_data" >expect
144 test_expect_success \
146 'git cat-file blob master:file4 >actual && test_cmp expect actual'
149 object $(git rev-parse refs/heads/master)
153 An annotated tag without a tagger
155 test_expect_success
'A: verify tag/series-A' '
156 git cat-file tag tags/series-A >actual &&
157 test_cmp expect actual
161 object $(git rev-parse refs/heads/master:file3)
165 An annotated tag that annotates a blob.
167 test_expect_success
'A: verify tag/series-A-blob' '
168 git cat-file tag tags/series-A-blob >actual &&
169 test_cmp expect actual
173 :2 `git rev-parse --verify master:file2`
174 :3 `git rev-parse --verify master:file3`
175 :4 `git rev-parse --verify master:file4`
176 :5 `git rev-parse --verify master^0`
178 test_expect_success \
179 'A: verify marks output' \
180 'test_cmp expect marks.out'
182 test_expect_success \
183 'A: verify marks import' \
185 --import-marks=marks.out \
186 --export-marks=marks.new \
188 test_cmp expect marks.new'
191 new_blob
=$
(echo testing | git hash-object
--stdin)
192 cat >input
<<INPUT_END
194 from $(git rev-parse refs/heads/master:file3)
205 commit refs/heads/new_blob
209 #pretend we got sha1 from fast-import
220 object $(git rev-parse refs/heads/master:file3)
232 test_expect_success \
233 'A: tag blob by sha1' \
234 'git fast-import <input &&
235 git cat-file tag tags/series-A-blob-2 >actual &&
236 git cat-file tag tags/series-A-blob-3 >>actual &&
237 test_cmp expect actual'
240 cat >input
<<INPUT_END
241 commit refs/heads/verify--import-marks
242 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
248 M 755 :2 copy-of-file2
251 test_expect_success \
252 'A: verify marks import does not crash' \
253 'git fast-import --import-marks=marks.out <input &&
254 git whatchanged verify--import-marks'
256 test_expect_success
'A: verify pack' '
261 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
263 git diff-tree
-M -r master verify--import-marks
>actual
264 test_expect_success \
266 'compare_diff_raw expect actual &&
267 test `git rev-parse --verify master:file2` \
268 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
271 mt
=$
(git hash-object
--stdin < /dev
/null
)
276 cat >input.commit
<<EOF
277 commit refs/heads/verify--dump-marks
278 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
280 test the sparse array dumping routines with exponentially growing marks
288 while test "$i" -lt 27; do
289 cat >>input.blob
<<EOF
300 echo "M 100644 :$l l$i" >>input.commit
301 echo "M 100644 :$m m$i" >>input.commit
302 echo "M 100644 :$n n$i" >>input.commit
304 echo ":$l $mt" >>marks.exp
305 echo ":$m $mt" >>marks.exp
306 echo ":$n $mt" >>marks.exp
308 printf "100644 blob $mt\tl$i\n" >>tree.exp
309 printf "100644 blob $mt\tm$i\n" >>tree.exp
310 printf "100644 blob $mt\tn$i\n" >>tree.exp
319 sort tree.exp
> tree.exp_s
321 test_expect_success
'A: export marks with large values' '
322 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
323 git ls-tree refs/heads/verify--dump-marks >tree.out &&
324 test_cmp tree.exp_s tree.out &&
325 test_cmp marks.exp marks.large'
332 cat >input
<<INPUT_END
333 commit refs/heads/branch
335 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
340 from refs/heads/master
341 M 755 0000000000000000000000000000000000000001 zero1
344 test_expect_success
'B: fail on invalid blob sha1' '
345 test_must_fail git fast-import <input
347 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
349 cat >input
<<INPUT_END
350 commit .badbranchname
351 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
356 from refs/heads/master
359 test_expect_success
'B: fail on invalid branch name ".badbranchname"' '
360 test_must_fail git fast-import <input
362 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
364 cat >input
<<INPUT_END
365 commit bad[branch]name
366 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
371 from refs/heads/master
374 test_expect_success
'B: fail on invalid branch name "bad[branch]name"' '
375 test_must_fail git fast-import <input
377 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
379 cat >input
<<INPUT_END
381 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
386 from refs/heads/master
389 test_expect_success \
390 'B: accept branch name "TEMP_TAG"' \
391 'git fast-import <input &&
392 test -f .git/TEMP_TAG &&
393 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
396 git gc
2>/dev
/null
>/dev
/null
397 git prune
2>/dev
/null
>/dev
/null
399 cat >input
<<INPUT_END
400 commit refs/heads/empty-committer-1
401 committer <> $GIT_COMMITTER_DATE
406 test_expect_success
'B: accept empty committer' '
407 git fast-import <input &&
412 git update-ref
-d refs
/heads
/empty-committer-1 || true
414 git gc
2>/dev
/null
>/dev
/null
415 git prune
2>/dev
/null
>/dev
/null
417 cat >input
<<INPUT_END
418 commit refs/heads/empty-committer-2
419 committer <a@b.com> $GIT_COMMITTER_DATE
424 test_expect_success
'B: accept and fixup committer with no name' '
425 git fast-import <input &&
430 git update-ref
-d refs
/heads
/empty-committer-2 || true
432 git gc
2>/dev
/null
>/dev
/null
433 git prune
2>/dev
/null
>/dev
/null
435 cat >input
<<INPUT_END
436 commit refs/heads/invalid-committer
437 committer Name email> $GIT_COMMITTER_DATE
442 test_expect_success
'B: fail on invalid committer (1)' '
443 test_must_fail git fast-import <input
445 git update-ref
-d refs
/heads
/invalid-committer || true
447 cat >input
<<INPUT_END
448 commit refs/heads/invalid-committer
449 committer Name <e<mail> $GIT_COMMITTER_DATE
454 test_expect_success
'B: fail on invalid committer (2)' '
455 test_must_fail git fast-import <input
457 git update-ref
-d refs
/heads
/invalid-committer || true
459 cat >input
<<INPUT_END
460 commit refs/heads/invalid-committer
461 committer Name <email>> $GIT_COMMITTER_DATE
466 test_expect_success
'B: fail on invalid committer (3)' '
467 test_must_fail git fast-import <input
469 git update-ref
-d refs
/heads
/invalid-committer || true
471 cat >input
<<INPUT_END
472 commit refs/heads/invalid-committer
473 committer Name <email $GIT_COMMITTER_DATE
478 test_expect_success
'B: fail on invalid committer (4)' '
479 test_must_fail git fast-import <input
481 git update-ref
-d refs
/heads
/invalid-committer || true
483 cat >input
<<INPUT_END
484 commit refs/heads/invalid-committer
485 committer Name<email> $GIT_COMMITTER_DATE
490 test_expect_success
'B: fail on invalid committer (5)' '
491 test_must_fail git fast-import <input
493 git update-ref
-d refs
/heads
/invalid-committer || true
499 newf
=`echo hi newf | git hash-object -w --stdin`
500 oldf
=`git rev-parse --verify master:file2`
502 cat >input
<<INPUT_END
503 commit refs/heads/branch
504 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
509 from refs/heads/master
510 M 644 $oldf file2/oldf
511 M 755 $newf file2/newf
515 test_expect_success \
516 'C: incremental import create pack from stdin' \
517 'git fast-import <input &&
518 git whatchanged branch'
520 test_expect_success
'C: verify pack' '
524 test_expect_success \
525 'C: validate reuse existing blob' \
526 'test $newf = `git rev-parse --verify branch:file2/newf` &&
527 test $oldf = `git rev-parse --verify branch:file2/oldf`'
530 parent `git rev-parse --verify master^0`
531 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
536 test_expect_success \
538 'git cat-file commit branch | sed 1d >actual &&
539 test_cmp expect actual'
542 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
543 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
544 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
546 git diff-tree
-M -r master branch
>actual
547 test_expect_success \
548 'C: validate rename result' \
549 'compare_diff_raw expect actual'
556 cat >input
<<INPUT_END
557 commit refs/heads/branch
558 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
563 from refs/heads/branch^0
564 M 644 inline newdir/interesting
569 M 755 inline newdir/exec.sh
575 test_expect_success \
576 'D: inline data in commit' \
577 'git fast-import <input &&
578 git whatchanged branch'
580 test_expect_success
'D: verify pack' '
585 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
586 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
588 git diff-tree
-M -r branch^ branch
>actual
589 test_expect_success \
590 'D: validate new files added' \
591 'compare_diff_raw expect actual'
593 echo "$file5_data" >expect
594 test_expect_success \
596 'git cat-file blob branch:newdir/interesting >actual &&
597 test_cmp expect actual'
599 echo "$file6_data" >expect
600 test_expect_success \
602 'git cat-file blob branch:newdir/exec.sh >actual &&
603 test_cmp expect actual'
609 cat >input
<<INPUT_END
610 commit refs/heads/branch
611 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
617 from refs/heads/branch^0
620 test_expect_success
'E: rfc2822 date, --date-format=raw' '
621 test_must_fail git fast-import --date-format=raw <input
623 test_expect_success \
624 'E: rfc2822 date, --date-format=rfc2822' \
625 'git fast-import --date-format=rfc2822 <input'
627 test_expect_success
'E: verify pack' '
632 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
633 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
637 test_expect_success \
639 'git cat-file commit branch | sed 1,2d >actual &&
640 test_cmp expect actual'
646 old_branch
=`git rev-parse --verify branch^0`
648 cat >input
<<INPUT_END
649 commit refs/heads/branch
650 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
652 losing things already?
655 from refs/heads/branch~1
657 reset refs/heads/other
658 from refs/heads/branch
661 test_expect_success \
662 'F: non-fast-forward update skips' \
663 'if git fast-import <input
665 echo BAD gfi did not fail
668 if test $old_branch = `git rev-parse --verify branch^0`
670 : branch unaffected and failure returned
673 echo BAD gfi changed branch $old_branch
679 test_expect_success
'F: verify pack' '
684 tree `git rev-parse branch~1^{tree}`
685 parent `git rev-parse branch~1`
686 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
687 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
689 losing things already?
691 test_expect_success \
692 'F: verify other commit' \
693 'git cat-file commit other >actual &&
694 test_cmp expect actual'
700 old_branch
=`git rev-parse --verify branch^0`
702 cat >input
<<INPUT_END
703 commit refs/heads/branch
704 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
706 losing things already?
709 from refs/heads/branch~1
712 test_expect_success \
713 'G: non-fast-forward update forced' \
714 'git fast-import --force <input'
716 test_expect_success
'G: verify pack' '
720 test_expect_success \
721 'G: branch changed, but logged' \
722 'test $old_branch != `git rev-parse --verify branch^0` &&
723 test $old_branch = `git rev-parse --verify branch@{1}`'
730 cat >input
<<INPUT_END
732 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
737 from refs/heads/branch^0
738 M 644 inline i-will-die
740 this file will never exist.
744 M 644 inline h/e/l/lo
750 test_expect_success \
751 'H: deletall, add 1' \
752 'git fast-import <input &&
755 test_expect_success
'H: verify pack' '
760 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
761 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
762 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
763 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
764 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
766 git diff-tree
-M -r H^ H
>actual
767 test_expect_success \
768 'H: validate old files removed, new files added' \
769 'compare_diff_raw expect actual'
771 echo "$file5_data" >expect
772 test_expect_success \
774 'git cat-file blob H:h/e/l/lo >actual &&
775 test_cmp expect actual'
781 cat >input
<<INPUT_END
782 commit refs/heads/export-boundary
783 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
785 we have a border. its only 40 characters wide.
788 from refs/heads/branch
791 test_expect_success \
792 'I: export-pack-edges' \
793 'git fast-import --export-pack-edges=edges.list <input'
796 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
798 test_expect_success \
799 'I: verify edge list' \
800 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
801 test_cmp expect actual'
807 cat >input
<<INPUT_END
809 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
814 from refs/heads/branch
819 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
825 test_expect_success \
826 'J: reset existing branch creates empty commit' \
827 'git fast-import <input'
828 test_expect_success \
829 'J: branch has 1 commit, empty tree' \
830 'test 1 = `git rev-list J | wc -l` &&
831 test 0 = `git ls-tree J | wc -l`'
833 cat >input
<<INPUT_END
839 Tag branch that was reset.
842 test_expect_success \
843 'J: tag must fail on empty branch' \
844 'test_must_fail git fast-import <input'
849 cat >input
<<INPUT_END
851 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
856 from refs/heads/branch
859 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
864 from refs/heads/branch^1
867 test_expect_success \
868 'K: reinit branch with from' \
869 'git fast-import <input'
870 test_expect_success \
871 'K: verify K^1 = branch^1' \
872 'test `git rev-parse --verify branch^1` \
873 = `git rev-parse --verify K^1`'
879 cat >input
<<INPUT_END
893 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
903 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
913 cat >expect
<<EXPECT_END
914 :100644 100644 4268632... 55d3a52... M b.
915 :040000 040000 0ae5cac... 443c768... M b
916 :100644 100644 4268632... 55d3a52... M ba
919 test_expect_success \
920 'L: verify internal tree sorting' \
921 'git fast-import <input &&
922 git diff-tree --abbrev --raw L^ L >output &&
923 test_cmp expect output'
925 cat >input
<<INPUT_END
933 committer C O Mitter <committer@example.com> 1112912473 -0700
942 committer C O Mitter <committer@example.com> 1112912473 -0700
956 test_expect_success \
957 'L: nested tree copy does not corrupt deltas' \
958 'git fast-import <input &&
959 git ls-tree L2 g/b/ >tmp &&
960 cat tmp | cut -f 2 >actual &&
961 test_cmp expect actual &&
962 git fsck `git rev-parse L2`'
964 git update-ref
-d refs
/heads
/L2
971 cat >input
<<INPUT_END
973 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
978 from refs/heads/branch^0
979 R file2/newf file2/n.e.w.f
984 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
986 test_expect_success \
987 'M: rename file in same subdirectory' \
988 'git fast-import <input &&
989 git diff-tree -M -r M1^ M1 >actual &&
990 compare_diff_raw expect actual'
992 cat >input
<<INPUT_END
994 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
999 from refs/heads/branch^0
1000 R file2/newf i/am/new/to/you
1005 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
1007 test_expect_success \
1008 'M: rename file to new subdirectory' \
1009 'git fast-import <input &&
1010 git diff-tree -M -r M2^ M2 >actual &&
1011 compare_diff_raw expect actual'
1013 cat >input
<<INPUT_END
1014 commit refs/heads/M3
1015 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1020 from refs/heads/M2^0
1026 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1028 test_expect_success \
1029 'M: rename subdirectory to new subdirectory' \
1030 'git fast-import <input &&
1031 git diff-tree -M -r M3^ M3 >actual &&
1032 compare_diff_raw expect actual'
1034 cat >input
<<INPUT_END
1035 commit refs/heads/M4
1036 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1041 from refs/heads/M2^0
1047 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1048 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1049 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1050 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1051 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1053 test_expect_success \
1054 'M: rename root to subdirectory' \
1055 'git fast-import <input &&
1056 git diff-tree -M -r M4^ M4 >actual &&
1058 compare_diff_raw expect actual'
1065 cat >input
<<INPUT_END
1066 commit refs/heads/N1
1067 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1072 from refs/heads/branch^0
1073 C file2/newf file2/n.e.w.f
1078 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1080 test_expect_success \
1081 'N: copy file in same subdirectory' \
1082 'git fast-import <input &&
1083 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1084 compare_diff_raw expect actual'
1086 cat >input
<<INPUT_END
1087 commit refs/heads/N2
1088 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1090 clean directory copy
1093 from refs/heads/branch^0
1096 commit refs/heads/N2
1097 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1099 modify directory copy
1102 M 644 inline file3/file5
1110 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1111 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1112 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1114 test_expect_success \
1115 'N: copy then modify subdirectory' \
1116 'git fast-import <input &&
1117 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1118 compare_diff_raw expect actual'
1120 cat >input
<<INPUT_END
1121 commit refs/heads/N3
1122 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1124 dirty directory copy
1127 from refs/heads/branch^0
1128 M 644 inline file2/file5
1138 test_expect_success \
1139 'N: copy dirty subdirectory' \
1140 'git fast-import <input &&
1141 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
1143 test_expect_success \
1144 'N: copy directory by id' \
1145 'cat >expect <<-\EOF &&
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/N4
1152 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1157 from refs/heads/branch^0
1158 M 040000 $subdir file3
1160 git fast-import <input &&
1161 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1162 compare_diff_raw expect actual'
1164 test_expect_success PIPE
'N: read and copy directory' '
1166 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1167 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1169 git update-ref -d refs/heads/N4 &&
1175 commit refs/heads/N4
1176 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1178 copy by tree hash, part 2
1181 from refs/heads/branch^0
1184 read mode type tree filename &&
1185 echo "M 040000 $tree file3"
1187 git fast-import --cat-blob-fd=3 3>backflow &&
1188 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1189 compare_diff_raw expect actual
1192 test_expect_success PIPE
'N: empty directory reads as missing' '
1193 cat <<-\EOF >expect &&
1195 :000000 100644 OBJNAME OBJNAME A unrelated
1197 echo "missing src" >expect.response &&
1198 git update-ref -d refs/heads/read-empty &&
1204 commit refs/heads/read-empty
1205 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1207 read "empty" (missing) directory
1210 M 100644 inline src/greeting
1214 C src/greeting dst1/non-greeting
1215 C src/greeting unrelated
1216 # leave behind "empty" src directory
1221 printf "%s\n" "$line" >response &&
1227 git fast-import --cat-blob-fd=3 3>backflow &&
1228 test_cmp expect.response response &&
1229 git rev-list read-empty |
1230 git diff-tree -r --root --stdin |
1231 sed "s/$_x40/OBJNAME/g" >actual &&
1232 test_cmp expect actual
1235 test_expect_success \
1236 'N: copy root directory by tree hash' \
1237 'cat >expect <<-\EOF &&
1238 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1239 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1241 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1242 cat >input <<-INPUT_END &&
1243 commit refs/heads/N6
1244 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1246 copy root directory by tree hash
1249 from refs/heads/branch^0
1252 git fast-import <input &&
1253 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1254 compare_diff_raw expect actual'
1256 test_expect_success \
1257 'N: copy root by path' \
1258 'cat >expect <<-\EOF &&
1259 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1260 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1261 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1262 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1263 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1265 cat >input <<-INPUT_END &&
1266 commit refs/heads/N-copy-root-path
1267 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1269 copy root directory by (empty) path
1272 from refs/heads/branch^0
1275 git fast-import <input &&
1276 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1277 compare_diff_raw expect actual'
1279 test_expect_success \
1280 'N: delete directory by copying' \
1281 'cat >expect <<-\EOF &&
1283 :100644 000000 OBJID OBJID D foo/bar/qux
1285 :000000 100644 OBJID OBJID A foo/bar/baz
1286 :000000 100644 OBJID OBJID A foo/bar/qux
1288 empty_tree=$(git mktree </dev/null) &&
1289 cat >input <<-INPUT_END &&
1290 commit refs/heads/N-delete
1291 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1293 collect data to be deleted
1297 M 100644 inline foo/bar/baz
1301 C "foo/bar/baz" "foo/bar/qux"
1302 C "foo/bar/baz" "foo/bar/quux/1"
1303 C "foo/bar/baz" "foo/bar/quuux"
1304 M 040000 $empty_tree foo/bar/quux
1305 M 040000 $empty_tree foo/bar/quuux
1307 commit refs/heads/N-delete
1308 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1313 M 040000 $empty_tree foo/bar/qux
1315 git fast-import <input &&
1316 git rev-list N-delete |
1317 git diff-tree -r --stdin --root --always |
1318 sed -e "s/$_x40/OBJID/g" >actual &&
1319 test_cmp expect actual'
1321 test_expect_success \
1322 'N: modify copied tree' \
1323 'cat >expect <<-\EOF &&
1324 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1325 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1326 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1328 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1329 cat >input <<-INPUT_END &&
1330 commit refs/heads/N5
1331 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1336 from refs/heads/branch^0
1337 M 040000 $subdir file3
1339 commit refs/heads/N5
1340 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1342 modify directory copy
1345 M 644 inline file3/file5
1350 git fast-import <input &&
1351 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1352 compare_diff_raw expect actual'
1354 test_expect_success \
1355 'N: reject foo/ syntax' \
1356 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1357 test_must_fail git fast-import <<-INPUT_END
1358 commit refs/heads/N5B
1359 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1361 copy with invalid syntax
1364 from refs/heads/branch^0
1365 M 040000 $subdir file3/
1368 test_expect_success \
1369 'N: reject foo/ syntax in copy source' \
1370 'test_must_fail git fast-import <<-INPUT_END
1371 commit refs/heads/N5C
1372 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1374 copy with invalid syntax
1377 from refs/heads/branch^0
1381 test_expect_success \
1382 'N: reject foo/ syntax in rename source' \
1383 'test_must_fail git fast-import <<-INPUT_END
1384 commit refs/heads/N5D
1385 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1387 rename with invalid syntax
1390 from refs/heads/branch^0
1394 test_expect_success \
1395 'N: reject foo/ syntax in ls argument' \
1396 'test_must_fail git fast-import <<-INPUT_END
1397 commit refs/heads/N5E
1398 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1400 copy with invalid syntax
1403 from refs/heads/branch^0
1407 test_expect_success \
1408 'N: copy to root by id and modify' \
1409 'echo "hello, world" >expect.foo &&
1410 echo hello >expect.bar &&
1411 git fast-import <<-SETUP_END &&
1412 commit refs/heads/N7
1413 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1419 M 644 inline foo/bar
1425 tree=$(git rev-parse --verify N7:) &&
1426 git fast-import <<-INPUT_END &&
1427 commit refs/heads/N8
1428 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1430 copy to root by id and modify
1434 M 644 inline foo/foo
1439 git show N8:foo/foo >actual.foo &&
1440 git show N8:foo/bar >actual.bar &&
1441 test_cmp expect.foo actual.foo &&
1442 test_cmp expect.bar actual.bar'
1444 test_expect_success \
1445 'N: extract subtree' \
1446 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1447 cat >input <<-INPUT_END &&
1448 commit refs/heads/N9
1449 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1451 extract subtree branch:newdir
1457 git fast-import <input &&
1458 git diff --exit-code branch:newdir N9'
1460 test_expect_success \
1461 'N: modify subtree, extract it, and modify again' \
1462 'echo hello >expect.baz &&
1463 echo hello, world >expect.qux &&
1464 git fast-import <<-SETUP_END &&
1465 commit refs/heads/N10
1466 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1472 M 644 inline foo/bar/baz
1478 tree=$(git rev-parse --verify N10:) &&
1479 git fast-import <<-INPUT_END &&
1480 commit refs/heads/N11
1481 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1483 copy to root by id and modify
1487 M 100644 inline foo/bar/qux
1492 C "bar/qux" "bar/quux"
1494 git show N11:bar/baz >actual.baz &&
1495 git show N11:bar/qux >actual.qux &&
1496 git show N11:bar/quux >actual.quux &&
1497 test_cmp expect.baz actual.baz &&
1498 test_cmp expect.qux actual.qux &&
1499 test_cmp expect.qux actual.quux'
1505 cat >input
<<INPUT_END
1507 commit refs/heads/O1
1508 # -- ignore all of this text
1509 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1510 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1512 dirty directory copy
1515 # don't forget the import blank line!
1517 # yes, we started from our usual base of branch^0.
1519 from refs/heads/branch^0
1520 # and we need to reuse file2/file5 from N3 above.
1521 M 644 inline file2/file5
1522 # otherwise the tree will be different
1527 # don't forget to copy file2 to file3
1530 # or to delete file5 from file2.
1536 test_expect_success \
1537 'O: comments are all skipped' \
1538 'git fast-import <input &&
1539 test `git rev-parse N3` = `git rev-parse O1`'
1541 cat >input
<<INPUT_END
1542 commit refs/heads/O2
1543 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1545 dirty directory copy
1547 from refs/heads/branch^0
1548 M 644 inline file2/file5
1557 test_expect_success \
1558 'O: blank lines not necessary after data commands' \
1559 'git fast-import <input &&
1560 test `git rev-parse N3` = `git rev-parse O2`'
1562 test_expect_success \
1563 'O: repack before next test' \
1566 cat >input
<<INPUT_END
1567 commit refs/heads/O3
1568 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1572 commit refs/heads/O3
1573 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1578 commit refs/heads/O3
1580 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1585 commit refs/heads/O3
1586 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1590 reset refs/tags/O3-2nd
1592 reset refs/tags/O3-3rd
1596 cat >expect
<<INPUT_END
1602 test_expect_success \
1603 'O: blank lines not necessary after other commands' \
1604 'git fast-import <input &&
1605 test 8 = `find .git/objects/pack -type f | wc -l` &&
1606 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1607 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1608 test_cmp expect actual'
1610 cat >input
<<INPUT_END
1611 commit refs/heads/O4
1612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1616 commit refs/heads/O4
1617 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1621 progress Two commits down, 2 to go!
1622 commit refs/heads/O4
1623 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1627 progress Three commits down, 1 to go!
1628 commit refs/heads/O4
1629 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1635 test_expect_success \
1636 'O: progress outputs as requested by input' \
1637 'git fast-import <input >actual &&
1638 grep "progress " <input >expect &&
1639 test_cmp expect actual'
1642 ### series P (gitlinks)
1645 cat >input
<<INPUT_END
1651 reset refs/heads/sub
1652 commit refs/heads/sub
1654 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1667 commit refs/heads/subuse1
1669 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1672 from refs/heads/master
1673 M 100644 :3 .gitmodules
1682 commit refs/heads/sub
1684 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1690 commit refs/heads/subuse1
1692 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1700 test_expect_success \
1701 'P: superproject & submodule mix' \
1702 'git fast-import <input &&
1703 git checkout subuse1 &&
1704 rm -rf sub && mkdir sub && (cd sub &&
1706 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1707 git checkout master) &&
1708 git submodule init &&
1709 git submodule update'
1711 SUBLAST
=$
(git rev-parse
--verify sub
)
1712 SUBPREV
=$
(git rev-parse
--verify sub^
)
1714 cat >input
<<INPUT_END
1723 commit refs/heads/subuse2
1725 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1728 from refs/heads/master
1729 M 100644 :1 .gitmodules
1730 M 160000 $SUBPREV sub
1732 commit refs/heads/subuse2
1734 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1738 M 160000 $SUBLAST sub
1742 test_expect_success \
1743 'P: verbatim SHA gitlinks' \
1744 'git branch -D sub &&
1745 git gc && git prune &&
1746 git fast-import <input &&
1747 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1750 cat >input
<<INPUT_END
1751 commit refs/heads/subuse3
1753 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1758 from refs/heads/subuse2
1766 test_expect_success
'P: fail on inline gitlink' '
1767 test_must_fail git fast-import <input'
1770 cat >input
<<INPUT_END
1777 commit refs/heads/subuse3
1779 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1784 from refs/heads/subuse2
1789 test_expect_success
'P: fail on blob mark in gitlink' '
1790 test_must_fail git fast-import <input'
1793 ### series Q (notes)
1796 note1_data
="The first note for the first commit"
1797 note2_data
="The first note for the second commit"
1798 note3_data
="The first note for the third commit"
1799 note1b_data
="The second note for the first commit"
1800 note1c_data
="The third note for the first commit"
1801 note2b_data
="The second note for the second commit"
1804 cat >input
<<INPUT_END
1811 commit refs/heads/notes-test
1813 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1824 commit refs/heads/notes-test
1826 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1833 commit refs/heads/notes-test
1835 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1862 commit refs/notes/foobar
1864 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1876 commit refs/notes/foobar
1878 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1888 commit refs/notes/foobar2
1890 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1900 commit refs/notes/foobar
1902 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1915 test_expect_success \
1917 'git fast-import <input &&
1918 git whatchanged notes-test'
1920 test_expect_success
'Q: verify pack' '
1924 commit1
=$
(git rev-parse notes-test~
2)
1925 commit2
=$
(git rev-parse notes-test^
)
1926 commit3
=$
(git rev-parse notes-test
)
1929 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1930 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1934 test_expect_success \
1935 'Q: verify first commit' \
1936 'git cat-file commit notes-test~2 | sed 1d >actual &&
1937 test_cmp expect actual'
1941 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1942 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1946 test_expect_success \
1947 'Q: verify second commit' \
1948 'git cat-file commit notes-test^ | sed 1d >actual &&
1949 test_cmp expect actual'
1953 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1954 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1958 test_expect_success \
1959 'Q: verify third commit' \
1960 'git cat-file commit notes-test | sed 1d >actual &&
1961 test_cmp expect actual'
1964 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1965 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1969 test_expect_success \
1970 'Q: verify first notes commit' \
1971 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1972 test_cmp expect actual'
1974 cat >expect.unsorted
<<EOF
1975 100644 blob $commit1
1976 100644 blob $commit2
1977 100644 blob $commit3
1979 cat expect.unsorted |
sort >expect
1980 test_expect_success \
1981 'Q: verify first notes tree' \
1982 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1983 test_cmp expect actual'
1985 echo "$note1_data" >expect
1986 test_expect_success \
1987 'Q: verify first note for first commit' \
1988 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1990 echo "$note2_data" >expect
1991 test_expect_success \
1992 'Q: verify first note for second commit' \
1993 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1995 echo "$note3_data" >expect
1996 test_expect_success \
1997 'Q: verify first note for third commit' \
1998 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
2001 parent `git rev-parse --verify refs/notes/foobar~2`
2002 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2003 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2007 test_expect_success \
2008 'Q: verify second notes commit' \
2009 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
2010 test_cmp expect actual'
2012 cat >expect.unsorted
<<EOF
2013 100644 blob $commit1
2014 100644 blob $commit2
2015 100644 blob $commit3
2017 cat expect.unsorted |
sort >expect
2018 test_expect_success \
2019 'Q: verify second notes tree' \
2020 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2021 test_cmp expect actual'
2023 echo "$note1b_data" >expect
2024 test_expect_success \
2025 'Q: verify second note for first commit' \
2026 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
2028 echo "$note2_data" >expect
2029 test_expect_success \
2030 'Q: verify first note for second commit' \
2031 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
2033 echo "$note3_data" >expect
2034 test_expect_success \
2035 'Q: verify first note for third commit' \
2036 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
2039 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2040 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2044 test_expect_success \
2045 'Q: verify third notes commit' \
2046 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2047 test_cmp expect actual'
2049 cat >expect.unsorted
<<EOF
2050 100644 blob $commit1
2052 cat expect.unsorted |
sort >expect
2053 test_expect_success \
2054 'Q: verify third notes tree' \
2055 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2056 test_cmp expect actual'
2058 echo "$note1c_data" >expect
2059 test_expect_success \
2060 'Q: verify third note for first commit' \
2061 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
2064 parent `git rev-parse --verify refs/notes/foobar^`
2065 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2066 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2070 test_expect_success \
2071 'Q: verify fourth notes commit' \
2072 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
2073 test_cmp expect actual'
2075 cat >expect.unsorted
<<EOF
2076 100644 blob $commit2
2078 cat expect.unsorted |
sort >expect
2079 test_expect_success \
2080 'Q: verify fourth notes tree' \
2081 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2082 test_cmp expect actual'
2084 echo "$note2b_data" >expect
2085 test_expect_success \
2086 'Q: verify second note for second commit' \
2087 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
2092 commit refs/heads/note-Q0
2093 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2095 Note for an empty branch.
2098 N inline refs/heads/Q0
2103 test_expect_success \
2104 'Q: deny note on empty branch' \
2105 'test_must_fail git fast-import <input'
2107 ### series R (feature and option)
2111 feature no-such-feature-exists
2114 test_expect_success
'R: abort on unsupported feature' '
2115 test_must_fail git fast-import <input
2119 feature date-format=now
2122 test_expect_success
'R: supported feature is accepted' '
2123 git fast-import <input
2130 feature date-format=now
2133 test_expect_success
'R: abort on receiving feature after data command' '
2134 test_must_fail git fast-import <input
2138 feature import-marks=git.marks
2139 feature import-marks=git2.marks
2142 test_expect_success
'R: only one import-marks feature allowed per stream' '
2143 test_must_fail git fast-import <input
2147 feature export-marks=git.marks
2155 test_expect_success \
2156 'R: export-marks feature results in a marks file being created' \
2157 'cat input | git fast-import &&
2160 test_expect_success \
2161 'R: export-marks options can be overridden by commandline options' \
2162 'cat input | git fast-import --export-marks=other.marks &&
2163 grep :1 other.marks'
2165 test_expect_success
'R: catch typo in marks file name' '
2166 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2167 echo "feature import-marks=nonexistent.marks" |
2168 test_must_fail git fast-import
2171 test_expect_success
'R: import and output marks can be the same file' '
2173 blob=$(echo hi | git hash-object --stdin) &&
2174 cat >expect <<-EOF &&
2178 git fast-import --export-marks=io.marks <<-\EOF &&
2185 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2192 test_cmp expect io.marks
2195 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
2197 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2206 test_expect_success
'R: --import-marks-if-exists' '
2208 blob=$(echo hi | git hash-object --stdin) &&
2209 echo ":1 $blob" >expect &&
2210 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2217 test_cmp expect io.marks
2220 test_expect_success
'R: feature import-marks-if-exists' '
2224 git fast-import --export-marks=io.marks <<-\EOF &&
2225 feature import-marks-if-exists=not_io.marks
2227 test_cmp expect io.marks &&
2229 blob=$(echo hi | git hash-object --stdin) &&
2231 echo ":1 $blob" >io.marks &&
2232 echo ":1 $blob" >expect &&
2233 echo ":2 $blob" >>expect &&
2235 git fast-import --export-marks=io.marks <<-\EOF &&
2236 feature import-marks-if-exists=io.marks
2243 test_cmp expect io.marks &&
2245 echo ":3 $blob" >>expect &&
2247 git fast-import --import-marks=io.marks \
2248 --export-marks=io.marks <<-\EOF &&
2249 feature import-marks-if-exists=not_io.marks
2256 test_cmp expect io.marks &&
2260 git fast-import --import-marks-if-exists=not_io.marks \
2261 --export-marks=io.marks <<-\EOF
2262 feature import-marks-if-exists=io.marks
2264 test_cmp expect io.marks
2268 feature import-marks=marks.out
2269 feature export-marks=marks.new
2272 test_expect_success \
2273 'R: import to output marks works without any content' \
2274 'cat input | git fast-import &&
2275 test_cmp marks.out marks.new'
2278 feature import-marks=nonexistent.marks
2279 feature export-marks=marks.new
2282 test_expect_success \
2283 'R: import marks prefers commandline marks file over the stream' \
2284 'cat input | git fast-import --import-marks=marks.out &&
2285 test_cmp marks.out marks.new'
2289 feature import-marks=nonexistent.marks
2290 feature export-marks=combined.marks
2293 test_expect_success
'R: multiple --import-marks= should be honoured' '
2294 head -n2 marks.out > one.marks &&
2295 tail -n +3 marks.out > two.marks &&
2296 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2297 test_cmp marks.out combined.marks
2301 feature relative-marks
2302 feature import-marks=relative.in
2303 feature export-marks=relative.out
2306 test_expect_success
'R: feature relative-marks should be honoured' '
2307 mkdir -p .git/info/fast-import/ &&
2308 cp marks.new .git/info/fast-import/relative.in &&
2309 git fast-import <input &&
2310 test_cmp marks.new .git/info/fast-import/relative.out
2314 feature relative-marks
2315 feature import-marks=relative.in
2316 feature no-relative-marks
2317 feature export-marks=non-relative.out
2320 test_expect_success
'R: feature no-relative-marks should be honoured' '
2321 git fast-import <input &&
2322 test_cmp marks.new non-relative.out
2325 test_expect_success
'R: feature ls supported' '
2330 test_expect_success
'R: feature cat-blob supported' '
2331 echo "feature cat-blob" |
2335 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
2336 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2339 test_expect_success NOT_MINGW
'R: print old blob' '
2340 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2341 cat >expect <<-EOF &&
2346 echo "cat-blob $blob" |
2347 git fast-import --cat-blob-fd=6 6>actual &&
2348 test_cmp expect actual
2351 test_expect_success NOT_MINGW
'R: in-stream cat-blob-fd not respected' '
2352 echo hello >greeting &&
2353 blob=$(git hash-object -w greeting) &&
2354 cat >expect <<-EOF &&
2359 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2362 test_cmp expect actual.3 &&
2363 test_cmp empty actual.1 &&
2364 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2365 option cat-blob-fd=3
2368 test_cmp empty actual.3 &&
2369 test_cmp expect actual.1
2372 test_expect_success NOT_MINGW
'R: print new blob' '
2373 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2374 cat >expect <<-EOF &&
2379 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2387 test_cmp expect actual
2390 test_expect_success NOT_MINGW
'R: print new blob by sha1' '
2391 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2392 cat >expect <<-EOF &&
2394 a new blob named by sha1
2397 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2400 a new blob named by sha1
2404 test_cmp expect actual
2407 test_expect_success
'setup: big file' '
2409 echo "the quick brown fox jumps over the lazy dog" >big &&
2412 cat big big big big >bigger &&
2413 cat bigger bigger bigger bigger >big ||
2419 test_expect_success
'R: print two blobs to stdout' '
2420 blob1=$(git hash-object big) &&
2421 blob1_len=$(wc -c <big) &&
2422 blob2=$(echo hello | git hash-object --stdin) &&
2424 echo ${blob1} blob $blob1_len &&
2434 cat <<-\END_PART1 &&
2451 git fast-import >actual &&
2452 test_cmp expect actual
2455 test_expect_success PIPE
'R: copy using cat-file' '
2456 expect_id=$(git hash-object big) &&
2457 expect_len=$(wc -c <big) &&
2458 echo $expect_id blob $expect_len >expect.response &&
2461 cat >frontend <<-\FRONTEND_END &&
2467 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2480 read blob_id type size <&3 &&
2481 echo "$blob_id $type $size" >response &&
2482 head_c $size >blob <&3 &&
2486 commit refs/heads/copied
2487 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2489 copy big file as file3
2497 git fast-import --cat-blob-fd=3 3>blobs &&
2498 git show copied:file3 >actual &&
2499 test_cmp expect.response response &&
2503 test_expect_success PIPE
'R: print blob mid-commit' '
2505 echo "A blob from _before_ the commit." >expect &&
2514 A blob from _before_ the commit.
2516 commit refs/heads/temporary
2517 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2524 read blob_id type size <&3 &&
2525 head_c $size >actual <&3 &&
2530 git fast-import --cat-blob-fd=3 3>blobs &&
2531 test_cmp expect actual
2534 test_expect_success PIPE
'R: print staged blob within commit' '
2536 echo "A blob from _within_ the commit." >expect &&
2542 commit refs/heads/within
2543 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2549 A blob from _within_ the commit.
2554 echo "A blob from _within_ the commit." |
2555 git hash-object --stdin
2557 echo "cat-blob $to_get" &&
2559 read blob_id type size <&3 &&
2560 head_c $size >actual <&3 &&
2565 git fast-import --cat-blob-fd=3 3>blobs &&
2566 test_cmp expect actual
2577 test_expect_success
'R: quiet option results in no stats being output' '
2578 cat input | git fast-import 2> output &&
2579 test_cmp empty output
2582 test_expect_success
'R: feature done means terminating "done" is mandatory' '
2583 echo feature done | test_must_fail git fast-import &&
2584 test_must_fail git fast-import --done </dev/null
2587 test_expect_success
'R: terminating "done" with trailing gibberish is ok' '
2588 git fast-import <<-\EOF &&
2593 git fast-import <<-\EOF
2595 more trailing gibberish
2599 test_expect_success
'R: terminating "done" within commit' '
2600 cat >expect <<-\EOF &&
2602 :000000 100644 OBJID OBJID A hello.c
2603 :000000 100644 OBJID OBJID A hello2.c
2605 git fast-import <<-EOF &&
2606 commit refs/heads/done-ends
2607 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2609 Commit terminated by "done" command
2611 M 100644 inline hello.c
2618 git rev-list done-ends |
2619 git diff-tree -r --stdin --root --always |
2620 sed -e "s/$_x40/OBJID/g" >actual &&
2621 test_cmp expect actual
2625 option git non-existing-option
2628 test_expect_success
'R: die on unknown option' '
2629 test_must_fail git fast-import <input
2632 test_expect_success
'R: unknown commandline options are rejected' '\
2633 test_must_fail git fast-import --non-existing-option < /dev/null
2636 test_expect_success
'R: die on invalid option argument' '
2637 echo "option git active-branches=-5" |
2638 test_must_fail git fast-import &&
2639 echo "option git depth=" |
2640 test_must_fail git fast-import &&
2641 test_must_fail git fast-import --depth="5 elephants" </dev/null
2645 option non-existing-vcs non-existing-option
2648 test_expect_success
'R: ignore non-git options' '
2649 git fast-import <input
2653 ## R: very large blobs
2655 blobsize
=$
((2*1024*1024 + 53))
2656 test-genrandom bar
$blobsize >expect
2657 cat >input
<<INPUT_END
2658 commit refs/heads/big-file
2659 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2668 cat >>input
<<INPUT_END
2675 test_expect_success \
2676 'R: blob bigger than threshold' \
2677 'test_create_repo R &&
2678 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2680 test_expect_success
'R: verify created pack' '
2683 verify_packs -v > ../verify
2687 test_expect_success \
2688 'R: verify written objects' \
2689 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2690 test_cmp expect actual &&
2691 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2692 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2694 test_expect_success \
2695 'R: blob appears only once' \
2696 'n=$(grep $a verify | wc -l) &&
2703 # Make sure missing spaces and EOLs after mark references
2712 # commit marks: 301, 302, 303, 304
2713 # blob marks: 403, 404, resp.
2716 # The error message when a space is missing not at the
2717 # end of the line is:
2719 # Missing space after ..
2721 # or when extra characters come after the mark at the end
2726 # or when the dataref is neither "inline " or a known SHA1,
2728 # Invalid dataref ..
2732 cat >input
<<INPUT_END
2735 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2739 M 100644 inline hello.c
2746 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2751 M 100644 inline hello.c
2769 test_expect_success
'S: initialize for S tests' '
2770 git fast-import --export-marks=marks <input
2774 # filemodify, three datarefs
2776 test_expect_success
'S: filemodify with garbage after mark must fail' '
2777 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2779 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2783 M 100644 :403x hello.c
2786 test_i18ngrep "space after mark" err
2789 # inline is misspelled; fast-import thinks it is some unknown dataref
2790 test_expect_success
'S: filemodify with garbage after inline must fail' '
2791 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2793 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2797 M 100644 inlineX hello.c
2803 test_i18ngrep "nvalid dataref" err
2806 test_expect_success
'S: filemodify with garbage after sha1 must fail' '
2807 sha1=$(grep :403 marks | cut -d\ -f2) &&
2808 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2814 M 100644 ${sha1}x hello.c
2817 test_i18ngrep "space after SHA1" err
2821 # notemodify, three ways to say dataref
2823 test_expect_success
'S: notemodify with garabge after mark dataref must fail' '
2824 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2826 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2828 commit S note dataref markref
2833 test_i18ngrep "space after mark" err
2836 test_expect_success
'S: notemodify with garbage after inline dataref must fail' '
2837 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2839 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2841 commit S note dataref inline
2849 test_i18ngrep "nvalid dataref" err
2852 test_expect_success
'S: notemodify with garbage after sha1 dataref must fail' '
2853 sha1=$(grep :202 marks | cut -d\ -f2) &&
2854 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2856 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2858 commit S note dataref sha1
2863 test_i18ngrep "space after SHA1" err
2867 # notemodify, mark in commit-ish
2869 test_expect_success
'S: notemodify with garbarge after mark commit-ish must fail' '
2870 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2871 commit refs/heads/Snotes
2872 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2874 commit S note commit-ish
2879 test_i18ngrep "after mark" err
2885 test_expect_success
'S: from with garbage after mark must fail' '
2887 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err
2888 commit refs/heads/S2
2890 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2895 M 100644 :403 hello.c
2899 echo returned $ret &&
2900 test $ret -ne 0 && # failed, but it created the commit
2902 # go create the commit, need it for merge test
2903 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2904 commit refs/heads/S2
2906 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2911 M 100644 :403 hello.c
2914 # now evaluate the error
2916 test_i18ngrep "after mark" err
2923 test_expect_success
'S: merge with garbage after mark must fail' '
2924 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2927 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2933 M 100644 :403 hello.c
2936 test_i18ngrep "after mark" err
2942 test_expect_success
'S: tag with garbage after mark must fail' '
2943 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2946 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2952 test_i18ngrep "after mark" err
2958 test_expect_success
'S: cat-blob with garbage after mark must fail' '
2959 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2963 test_i18ngrep "after mark" err
2969 test_expect_success
'S: ls with garbage after mark must fail' '
2970 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2974 test_i18ngrep "space after mark" err
2977 test_expect_success
'S: ls with garbage after sha1 must fail' '
2978 sha1=$(grep :302 marks | cut -d\ -f2) &&
2979 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2983 test_i18ngrep "space after tree-ish" err
2989 # Setup is carried over from series S.
2991 test_expect_success
'T: ls root tree' '
2992 sed -e "s/Z\$//" >expect <<-EOF &&
2993 040000 tree $(git rev-parse S^{tree}) Z
2995 sha1=$(git rev-parse --verify S) &&
2996 git fast-import --import-marks=marks <<-EOF >actual &&
2999 test_cmp expect actual