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.'
52 test_expect_success
'setup: have pipes?' '
66 test_expect_success
'empty stream succeeds' '
67 git fast-import </dev/null
70 cat >input
<<INPUT_END
87 commit refs/heads/master
89 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
101 An annotated tag without a tagger
107 An annotated tag that annotates a blob.
111 test_expect_success \
112 'A: create pack from stdin' \
113 'git fast-import --export-marks=marks.out <input &&
114 git whatchanged master'
116 test_expect_success
'A: verify pack' '
121 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
122 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
126 test_expect_success \
128 'git cat-file commit master | sed 1d >actual &&
129 test_cmp expect actual'
136 test_expect_success \
138 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
139 test_cmp expect actual'
141 echo "$file2_data" >expect
142 test_expect_success \
144 'git cat-file blob master:file2 >actual && test_cmp expect actual'
146 echo "$file3_data" >expect
147 test_expect_success \
149 'git cat-file blob master:file3 >actual && test_cmp expect actual'
151 printf "$file4_data" >expect
152 test_expect_success \
154 'git cat-file blob master:file4 >actual && test_cmp expect actual'
157 object $(git rev-parse refs/heads/master)
161 An annotated tag without a tagger
163 test_expect_success
'A: verify tag/series-A' '
164 git cat-file tag tags/series-A >actual &&
165 test_cmp expect actual
169 object $(git rev-parse refs/heads/master:file3)
173 An annotated tag that annotates a blob.
175 test_expect_success
'A: verify tag/series-A-blob' '
176 git cat-file tag tags/series-A-blob >actual &&
177 test_cmp expect actual
181 :2 `git rev-parse --verify master:file2`
182 :3 `git rev-parse --verify master:file3`
183 :4 `git rev-parse --verify master:file4`
184 :5 `git rev-parse --verify master^0`
186 test_expect_success \
187 'A: verify marks output' \
188 'test_cmp expect marks.out'
190 test_expect_success \
191 'A: verify marks import' \
193 --import-marks=marks.out \
194 --export-marks=marks.new \
196 test_cmp expect marks.new'
199 new_blob
=$
(echo testing | git hash-object
--stdin)
200 cat >input
<<INPUT_END
202 from $(git rev-parse refs/heads/master:file3)
213 commit refs/heads/new_blob
217 #pretend we got sha1 from fast-import
228 object $(git rev-parse refs/heads/master:file3)
240 test_expect_success \
241 'A: tag blob by sha1' \
242 'git fast-import <input &&
243 git cat-file tag tags/series-A-blob-2 >actual &&
244 git cat-file tag tags/series-A-blob-3 >>actual &&
245 test_cmp expect actual'
248 cat >input
<<INPUT_END
249 commit refs/heads/verify--import-marks
250 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
256 M 755 :2 copy-of-file2
259 test_expect_success \
260 'A: verify marks import does not crash' \
261 'git fast-import --import-marks=marks.out <input &&
262 git whatchanged verify--import-marks'
264 test_expect_success
'A: verify pack' '
269 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
271 git diff-tree
-M -r master verify--import-marks
>actual
272 test_expect_success \
274 'compare_diff_raw expect actual &&
275 test `git rev-parse --verify master:file2` \
276 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
279 mt
=$
(git hash-object
--stdin < /dev
/null
)
284 cat >input.commit
<<EOF
285 commit refs/heads/verify--dump-marks
286 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
288 test the sparse array dumping routines with exponentially growing marks
296 while test "$i" -lt 27; do
297 cat >>input.blob
<<EOF
308 echo "M 100644 :$l l$i" >>input.commit
309 echo "M 100644 :$m m$i" >>input.commit
310 echo "M 100644 :$n n$i" >>input.commit
312 echo ":$l $mt" >>marks.exp
313 echo ":$m $mt" >>marks.exp
314 echo ":$n $mt" >>marks.exp
316 printf "100644 blob $mt\tl$i\n" >>tree.exp
317 printf "100644 blob $mt\tm$i\n" >>tree.exp
318 printf "100644 blob $mt\tn$i\n" >>tree.exp
327 sort tree.exp
> tree.exp_s
329 test_expect_success
'A: export marks with large values' '
330 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
331 git ls-tree refs/heads/verify--dump-marks >tree.out &&
332 test_cmp tree.exp_s tree.out &&
333 test_cmp marks.exp marks.large'
340 cat >input
<<INPUT_END
341 commit refs/heads/branch
343 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
348 from refs/heads/master
349 M 755 0000000000000000000000000000000000000001 zero1
352 test_expect_success
'B: fail on invalid blob sha1' '
353 test_must_fail git fast-import <input
355 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
357 cat >input
<<INPUT_END
358 commit .badbranchname
359 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
364 from refs/heads/master
367 test_expect_success
'B: fail on invalid branch name ".badbranchname"' '
368 test_must_fail git fast-import <input
370 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
372 cat >input
<<INPUT_END
373 commit bad[branch]name
374 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
379 from refs/heads/master
382 test_expect_success
'B: fail on invalid branch name "bad[branch]name"' '
383 test_must_fail git fast-import <input
385 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
387 cat >input
<<INPUT_END
389 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
394 from refs/heads/master
397 test_expect_success \
398 'B: accept branch name "TEMP_TAG"' \
399 'git fast-import <input &&
400 test -f .git/TEMP_TAG &&
401 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
404 git gc
2>/dev
/null
>/dev
/null
405 git prune
2>/dev
/null
>/dev
/null
407 cat >input
<<INPUT_END
408 commit refs/heads/empty-committer-1
409 committer <> $GIT_COMMITTER_DATE
414 test_expect_success
'B: accept empty committer' '
415 git fast-import <input &&
420 git update-ref
-d refs
/heads
/empty-committer-1 || true
422 git gc
2>/dev
/null
>/dev
/null
423 git prune
2>/dev
/null
>/dev
/null
425 cat >input
<<INPUT_END
426 commit refs/heads/empty-committer-2
427 committer <a@b.com> $GIT_COMMITTER_DATE
432 test_expect_success
'B: accept and fixup committer with no name' '
433 git fast-import <input &&
438 git update-ref
-d refs
/heads
/empty-committer-2 || true
440 git gc
2>/dev
/null
>/dev
/null
441 git prune
2>/dev
/null
>/dev
/null
443 cat >input
<<INPUT_END
444 commit refs/heads/invalid-committer
445 committer Name email> $GIT_COMMITTER_DATE
450 test_expect_success
'B: fail on invalid committer (1)' '
451 test_must_fail git fast-import <input
453 git update-ref
-d refs
/heads
/invalid-committer || true
455 cat >input
<<INPUT_END
456 commit refs/heads/invalid-committer
457 committer Name <e<mail> $GIT_COMMITTER_DATE
462 test_expect_success
'B: fail on invalid committer (2)' '
463 test_must_fail git fast-import <input
465 git update-ref
-d refs
/heads
/invalid-committer || true
467 cat >input
<<INPUT_END
468 commit refs/heads/invalid-committer
469 committer Name <email>> $GIT_COMMITTER_DATE
474 test_expect_success
'B: fail on invalid committer (3)' '
475 test_must_fail git fast-import <input
477 git update-ref
-d refs
/heads
/invalid-committer || true
479 cat >input
<<INPUT_END
480 commit refs/heads/invalid-committer
481 committer Name <email $GIT_COMMITTER_DATE
486 test_expect_success
'B: fail on invalid committer (4)' '
487 test_must_fail git fast-import <input
489 git update-ref
-d refs
/heads
/invalid-committer || true
491 cat >input
<<INPUT_END
492 commit refs/heads/invalid-committer
493 committer Name<email> $GIT_COMMITTER_DATE
498 test_expect_success
'B: fail on invalid committer (5)' '
499 test_must_fail git fast-import <input
501 git update-ref
-d refs
/heads
/invalid-committer || true
507 newf
=`echo hi newf | git hash-object -w --stdin`
508 oldf
=`git rev-parse --verify master:file2`
510 cat >input
<<INPUT_END
511 commit refs/heads/branch
512 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
517 from refs/heads/master
518 M 644 $oldf file2/oldf
519 M 755 $newf file2/newf
523 test_expect_success \
524 'C: incremental import create pack from stdin' \
525 'git fast-import <input &&
526 git whatchanged branch'
528 test_expect_success
'C: verify pack' '
532 test_expect_success \
533 'C: validate reuse existing blob' \
534 'test $newf = `git rev-parse --verify branch:file2/newf` &&
535 test $oldf = `git rev-parse --verify branch:file2/oldf`'
538 parent `git rev-parse --verify master^0`
539 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
540 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
544 test_expect_success \
546 'git cat-file commit branch | sed 1d >actual &&
547 test_cmp expect actual'
550 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
551 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
552 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
554 git diff-tree
-M -r master branch
>actual
555 test_expect_success \
556 'C: validate rename result' \
557 'compare_diff_raw expect actual'
564 cat >input
<<INPUT_END
565 commit refs/heads/branch
566 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
571 from refs/heads/branch^0
572 M 644 inline newdir/interesting
577 M 755 inline newdir/exec.sh
583 test_expect_success \
584 'D: inline data in commit' \
585 'git fast-import <input &&
586 git whatchanged branch'
588 test_expect_success
'D: verify pack' '
593 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
594 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
596 git diff-tree
-M -r branch^ branch
>actual
597 test_expect_success \
598 'D: validate new files added' \
599 'compare_diff_raw expect actual'
601 echo "$file5_data" >expect
602 test_expect_success \
604 'git cat-file blob branch:newdir/interesting >actual &&
605 test_cmp expect actual'
607 echo "$file6_data" >expect
608 test_expect_success \
610 'git cat-file blob branch:newdir/exec.sh >actual &&
611 test_cmp expect actual'
617 cat >input
<<INPUT_END
618 commit refs/heads/branch
619 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
620 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
625 from refs/heads/branch^0
628 test_expect_success
'E: rfc2822 date, --date-format=raw' '
629 test_must_fail git fast-import --date-format=raw <input
631 test_expect_success \
632 'E: rfc2822 date, --date-format=rfc2822' \
633 'git fast-import --date-format=rfc2822 <input'
635 test_expect_success
'E: verify pack' '
640 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
641 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
645 test_expect_success \
647 'git cat-file commit branch | sed 1,2d >actual &&
648 test_cmp expect actual'
654 old_branch
=`git rev-parse --verify branch^0`
656 cat >input
<<INPUT_END
657 commit refs/heads/branch
658 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
660 losing things already?
663 from refs/heads/branch~1
665 reset refs/heads/other
666 from refs/heads/branch
669 test_expect_success \
670 'F: non-fast-forward update skips' \
671 'if git fast-import <input
673 echo BAD gfi did not fail
676 if test $old_branch = `git rev-parse --verify branch^0`
678 : branch unaffected and failure returned
681 echo BAD gfi changed branch $old_branch
687 test_expect_success
'F: verify pack' '
692 tree `git rev-parse branch~1^{tree}`
693 parent `git rev-parse branch~1`
694 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
695 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
697 losing things already?
699 test_expect_success \
700 'F: verify other commit' \
701 'git cat-file commit other >actual &&
702 test_cmp expect actual'
708 old_branch
=`git rev-parse --verify branch^0`
710 cat >input
<<INPUT_END
711 commit refs/heads/branch
712 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
714 losing things already?
717 from refs/heads/branch~1
720 test_expect_success \
721 'G: non-fast-forward update forced' \
722 'git fast-import --force <input'
724 test_expect_success
'G: verify pack' '
728 test_expect_success \
729 'G: branch changed, but logged' \
730 'test $old_branch != `git rev-parse --verify branch^0` &&
731 test $old_branch = `git rev-parse --verify branch@{1}`'
738 cat >input
<<INPUT_END
740 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
745 from refs/heads/branch^0
746 M 644 inline i-will-die
748 this file will never exist.
752 M 644 inline h/e/l/lo
758 test_expect_success \
759 'H: deletall, add 1' \
760 'git fast-import <input &&
763 test_expect_success
'H: verify pack' '
768 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
769 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
770 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
771 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
772 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
774 git diff-tree
-M -r H^ H
>actual
775 test_expect_success \
776 'H: validate old files removed, new files added' \
777 'compare_diff_raw expect actual'
779 echo "$file5_data" >expect
780 test_expect_success \
782 'git cat-file blob H:h/e/l/lo >actual &&
783 test_cmp expect actual'
789 cat >input
<<INPUT_END
790 commit refs/heads/export-boundary
791 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
793 we have a border. its only 40 characters wide.
796 from refs/heads/branch
799 test_expect_success \
800 'I: export-pack-edges' \
801 'git fast-import --export-pack-edges=edges.list <input'
804 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
806 test_expect_success \
807 'I: verify edge list' \
808 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
809 test_cmp expect actual'
815 cat >input
<<INPUT_END
817 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
822 from refs/heads/branch
827 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
833 test_expect_success \
834 'J: reset existing branch creates empty commit' \
835 'git fast-import <input'
836 test_expect_success \
837 'J: branch has 1 commit, empty tree' \
838 'test 1 = `git rev-list J | wc -l` &&
839 test 0 = `git ls-tree J | wc -l`'
841 cat >input
<<INPUT_END
847 Tag branch that was reset.
850 test_expect_success \
851 'J: tag must fail on empty branch' \
852 'test_must_fail git fast-import <input'
857 cat >input
<<INPUT_END
859 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
864 from refs/heads/branch
867 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
872 from refs/heads/branch^1
875 test_expect_success \
876 'K: reinit branch with from' \
877 'git fast-import <input'
878 test_expect_success \
879 'K: verify K^1 = branch^1' \
880 'test `git rev-parse --verify branch^1` \
881 = `git rev-parse --verify K^1`'
887 cat >input
<<INPUT_END
901 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
911 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
921 cat >expect
<<EXPECT_END
922 :100644 100644 4268632... 55d3a52... M b.
923 :040000 040000 0ae5cac... 443c768... M b
924 :100644 100644 4268632... 55d3a52... M ba
927 test_expect_success \
928 'L: verify internal tree sorting' \
929 'git fast-import <input &&
930 git diff-tree --abbrev --raw L^ L >output &&
931 test_cmp expect output'
933 cat >input
<<INPUT_END
941 committer C O Mitter <committer@example.com> 1112912473 -0700
950 committer C O Mitter <committer@example.com> 1112912473 -0700
964 test_expect_success \
965 'L: nested tree copy does not corrupt deltas' \
966 'git fast-import <input &&
967 git ls-tree L2 g/b/ >tmp &&
968 cat tmp | cut -f 2 >actual &&
969 test_cmp expect actual &&
970 git fsck `git rev-parse L2`'
972 git update-ref
-d refs
/heads
/L2
979 cat >input
<<INPUT_END
981 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
986 from refs/heads/branch^0
987 R file2/newf file2/n.e.w.f
992 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
994 test_expect_success \
995 'M: rename file in same subdirectory' \
996 'git fast-import <input &&
997 git diff-tree -M -r M1^ M1 >actual &&
998 compare_diff_raw expect actual'
1000 cat >input
<<INPUT_END
1001 commit refs/heads/M2
1002 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1007 from refs/heads/branch^0
1008 R file2/newf i/am/new/to/you
1013 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
1015 test_expect_success \
1016 'M: rename file to new subdirectory' \
1017 'git fast-import <input &&
1018 git diff-tree -M -r M2^ M2 >actual &&
1019 compare_diff_raw expect actual'
1021 cat >input
<<INPUT_END
1022 commit refs/heads/M3
1023 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1028 from refs/heads/M2^0
1034 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1036 test_expect_success \
1037 'M: rename subdirectory to new subdirectory' \
1038 'git fast-import <input &&
1039 git diff-tree -M -r M3^ M3 >actual &&
1040 compare_diff_raw expect actual'
1047 cat >input
<<INPUT_END
1048 commit refs/heads/N1
1049 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1054 from refs/heads/branch^0
1055 C file2/newf file2/n.e.w.f
1060 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1062 test_expect_success \
1063 'N: copy file in same subdirectory' \
1064 'git fast-import <input &&
1065 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1066 compare_diff_raw expect actual'
1068 cat >input
<<INPUT_END
1069 commit refs/heads/N2
1070 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1072 clean directory copy
1075 from refs/heads/branch^0
1078 commit refs/heads/N2
1079 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1081 modify directory copy
1084 M 644 inline file3/file5
1092 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1093 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1094 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1096 test_expect_success \
1097 'N: copy then modify subdirectory' \
1098 'git fast-import <input &&
1099 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1100 compare_diff_raw expect actual'
1102 cat >input
<<INPUT_END
1103 commit refs/heads/N3
1104 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1106 dirty directory copy
1109 from refs/heads/branch^0
1110 M 644 inline file2/file5
1120 test_expect_success \
1121 'N: copy dirty subdirectory' \
1122 'git fast-import <input &&
1123 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
1125 test_expect_success \
1126 'N: copy directory by id' \
1127 'cat >expect <<-\EOF &&
1128 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1129 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1131 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1132 cat >input <<-INPUT_END &&
1133 commit refs/heads/N4
1134 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1139 from refs/heads/branch^0
1140 M 040000 $subdir file3
1142 git fast-import <input &&
1143 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1144 compare_diff_raw expect actual'
1146 test_expect_success PIPE
'N: read and copy directory' '
1148 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1149 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1151 git update-ref -d refs/heads/N4 &&
1157 commit refs/heads/N4
1158 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1160 copy by tree hash, part 2
1163 from refs/heads/branch^0
1166 read mode type tree filename &&
1167 echo "M 040000 $tree file3"
1169 git fast-import --cat-blob-fd=3 3>backflow &&
1170 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1171 compare_diff_raw expect actual
1174 test_expect_success PIPE
'N: empty directory reads as missing' '
1175 cat <<-\EOF >expect &&
1177 :000000 100644 OBJNAME OBJNAME A unrelated
1179 echo "missing src" >expect.response &&
1180 git update-ref -d refs/heads/read-empty &&
1186 commit refs/heads/read-empty
1187 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1189 read "empty" (missing) directory
1192 M 100644 inline src/greeting
1196 C src/greeting dst1/non-greeting
1197 C src/greeting unrelated
1198 # leave behind "empty" src directory
1203 printf "%s\n" "$line" >response &&
1209 git fast-import --cat-blob-fd=3 3>backflow &&
1210 test_cmp expect.response response &&
1211 git rev-list read-empty |
1212 git diff-tree -r --root --stdin |
1213 sed "s/$_x40/OBJNAME/g" >actual &&
1214 test_cmp expect actual
1217 test_expect_success \
1218 'N: copy root directory by tree hash' \
1219 'cat >expect <<-\EOF &&
1220 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1221 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1223 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1224 cat >input <<-INPUT_END &&
1225 commit refs/heads/N6
1226 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1228 copy root directory by tree hash
1231 from refs/heads/branch^0
1234 git fast-import <input &&
1235 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1236 compare_diff_raw expect actual'
1238 test_expect_success \
1239 'N: delete directory by copying' \
1240 'cat >expect <<-\EOF &&
1242 :100644 000000 OBJID OBJID D foo/bar/qux
1244 :000000 100644 OBJID OBJID A foo/bar/baz
1245 :000000 100644 OBJID OBJID A foo/bar/qux
1247 empty_tree=$(git mktree </dev/null) &&
1248 cat >input <<-INPUT_END &&
1249 commit refs/heads/N-delete
1250 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1252 collect data to be deleted
1256 M 100644 inline foo/bar/baz
1260 C "foo/bar/baz" "foo/bar/qux"
1261 C "foo/bar/baz" "foo/bar/quux/1"
1262 C "foo/bar/baz" "foo/bar/quuux"
1263 M 040000 $empty_tree foo/bar/quux
1264 M 040000 $empty_tree foo/bar/quuux
1266 commit refs/heads/N-delete
1267 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1272 M 040000 $empty_tree foo/bar/qux
1274 git fast-import <input &&
1275 git rev-list N-delete |
1276 git diff-tree -r --stdin --root --always |
1277 sed -e "s/$_x40/OBJID/g" >actual &&
1278 test_cmp expect actual'
1280 test_expect_success \
1281 'N: modify copied tree' \
1282 'cat >expect <<-\EOF &&
1283 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1284 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1285 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1287 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1288 cat >input <<-INPUT_END &&
1289 commit refs/heads/N5
1290 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1295 from refs/heads/branch^0
1296 M 040000 $subdir file3
1298 commit refs/heads/N5
1299 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1301 modify directory copy
1304 M 644 inline file3/file5
1309 git fast-import <input &&
1310 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1311 compare_diff_raw expect actual'
1313 test_expect_success \
1314 'N: reject foo/ syntax' \
1315 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1316 test_must_fail git fast-import <<-INPUT_END
1317 commit refs/heads/N5B
1318 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1320 copy with invalid syntax
1323 from refs/heads/branch^0
1324 M 040000 $subdir file3/
1327 test_expect_success \
1328 'N: reject foo/ syntax in copy source' \
1329 'test_must_fail git fast-import <<-INPUT_END
1330 commit refs/heads/N5C
1331 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1333 copy with invalid syntax
1336 from refs/heads/branch^0
1340 test_expect_success \
1341 'N: reject foo/ syntax in rename source' \
1342 'test_must_fail git fast-import <<-INPUT_END
1343 commit refs/heads/N5D
1344 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1346 rename with invalid syntax
1349 from refs/heads/branch^0
1353 test_expect_success \
1354 'N: reject foo/ syntax in ls argument' \
1355 'test_must_fail git fast-import <<-INPUT_END
1356 commit refs/heads/N5E
1357 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1359 copy with invalid syntax
1362 from refs/heads/branch^0
1366 test_expect_success \
1367 'N: copy to root by id and modify' \
1368 'echo "hello, world" >expect.foo &&
1369 echo hello >expect.bar &&
1370 git fast-import <<-SETUP_END &&
1371 commit refs/heads/N7
1372 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1378 M 644 inline foo/bar
1384 tree=$(git rev-parse --verify N7:) &&
1385 git fast-import <<-INPUT_END &&
1386 commit refs/heads/N8
1387 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1389 copy to root by id and modify
1393 M 644 inline foo/foo
1398 git show N8:foo/foo >actual.foo &&
1399 git show N8:foo/bar >actual.bar &&
1400 test_cmp expect.foo actual.foo &&
1401 test_cmp expect.bar actual.bar'
1403 test_expect_success \
1404 'N: extract subtree' \
1405 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1406 cat >input <<-INPUT_END &&
1407 commit refs/heads/N9
1408 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1410 extract subtree branch:newdir
1416 git fast-import <input &&
1417 git diff --exit-code branch:newdir N9'
1419 test_expect_success \
1420 'N: modify subtree, extract it, and modify again' \
1421 'echo hello >expect.baz &&
1422 echo hello, world >expect.qux &&
1423 git fast-import <<-SETUP_END &&
1424 commit refs/heads/N10
1425 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1431 M 644 inline foo/bar/baz
1437 tree=$(git rev-parse --verify N10:) &&
1438 git fast-import <<-INPUT_END &&
1439 commit refs/heads/N11
1440 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1442 copy to root by id and modify
1446 M 100644 inline foo/bar/qux
1451 C "bar/qux" "bar/quux"
1453 git show N11:bar/baz >actual.baz &&
1454 git show N11:bar/qux >actual.qux &&
1455 git show N11:bar/quux >actual.quux &&
1456 test_cmp expect.baz actual.baz &&
1457 test_cmp expect.qux actual.qux &&
1458 test_cmp expect.qux actual.quux'
1464 cat >input
<<INPUT_END
1466 commit refs/heads/O1
1467 # -- ignore all of this text
1468 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1469 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1471 dirty directory copy
1474 # don't forget the import blank line!
1476 # yes, we started from our usual base of branch^0.
1478 from refs/heads/branch^0
1479 # and we need to reuse file2/file5 from N3 above.
1480 M 644 inline file2/file5
1481 # otherwise the tree will be different
1486 # don't forget to copy file2 to file3
1489 # or to delete file5 from file2.
1495 test_expect_success \
1496 'O: comments are all skipped' \
1497 'git fast-import <input &&
1498 test `git rev-parse N3` = `git rev-parse O1`'
1500 cat >input
<<INPUT_END
1501 commit refs/heads/O2
1502 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1504 dirty directory copy
1506 from refs/heads/branch^0
1507 M 644 inline file2/file5
1516 test_expect_success \
1517 'O: blank lines not necessary after data commands' \
1518 'git fast-import <input &&
1519 test `git rev-parse N3` = `git rev-parse O2`'
1521 test_expect_success \
1522 'O: repack before next test' \
1525 cat >input
<<INPUT_END
1526 commit refs/heads/O3
1527 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1531 commit refs/heads/O3
1532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1537 commit refs/heads/O3
1539 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1544 commit refs/heads/O3
1545 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1549 reset refs/tags/O3-2nd
1551 reset refs/tags/O3-3rd
1555 cat >expect
<<INPUT_END
1561 test_expect_success \
1562 'O: blank lines not necessary after other commands' \
1563 'git fast-import <input &&
1564 test 8 = `find .git/objects/pack -type f | wc -l` &&
1565 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1566 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1567 test_cmp expect actual'
1569 cat >input
<<INPUT_END
1570 commit refs/heads/O4
1571 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1575 commit refs/heads/O4
1576 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1580 progress Two commits down, 2 to go!
1581 commit refs/heads/O4
1582 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1586 progress Three commits down, 1 to go!
1587 commit refs/heads/O4
1588 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1594 test_expect_success \
1595 'O: progress outputs as requested by input' \
1596 'git fast-import <input >actual &&
1597 grep "progress " <input >expect &&
1598 test_cmp expect actual'
1601 ### series P (gitlinks)
1604 cat >input
<<INPUT_END
1610 reset refs/heads/sub
1611 commit refs/heads/sub
1613 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1626 commit refs/heads/subuse1
1628 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1631 from refs/heads/master
1632 M 100644 :3 .gitmodules
1641 commit refs/heads/sub
1643 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1649 commit refs/heads/subuse1
1651 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1659 test_expect_success \
1660 'P: superproject & submodule mix' \
1661 'git fast-import <input &&
1662 git checkout subuse1 &&
1663 rm -rf sub && mkdir sub && (cd sub &&
1665 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1666 git checkout master) &&
1667 git submodule init &&
1668 git submodule update'
1670 SUBLAST
=$
(git rev-parse
--verify sub
)
1671 SUBPREV
=$
(git rev-parse
--verify sub^
)
1673 cat >input
<<INPUT_END
1682 commit refs/heads/subuse2
1684 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1687 from refs/heads/master
1688 M 100644 :1 .gitmodules
1689 M 160000 $SUBPREV sub
1691 commit refs/heads/subuse2
1693 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1697 M 160000 $SUBLAST sub
1701 test_expect_success \
1702 'P: verbatim SHA gitlinks' \
1703 'git branch -D sub &&
1704 git gc && git prune &&
1705 git fast-import <input &&
1706 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1709 cat >input
<<INPUT_END
1710 commit refs/heads/subuse3
1712 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1717 from refs/heads/subuse2
1725 test_expect_success
'P: fail on inline gitlink' '
1726 test_must_fail git fast-import <input'
1729 cat >input
<<INPUT_END
1736 commit refs/heads/subuse3
1738 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1743 from refs/heads/subuse2
1748 test_expect_success
'P: fail on blob mark in gitlink' '
1749 test_must_fail git fast-import <input'
1752 ### series Q (notes)
1755 note1_data
="The first note for the first commit"
1756 note2_data
="The first note for the second commit"
1757 note3_data
="The first note for the third commit"
1758 note1b_data
="The second note for the first commit"
1759 note1c_data
="The third note for the first commit"
1760 note2b_data
="The second note for the second commit"
1763 cat >input
<<INPUT_END
1770 commit refs/heads/notes-test
1772 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1783 commit refs/heads/notes-test
1785 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1792 commit refs/heads/notes-test
1794 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1821 commit refs/notes/foobar
1823 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1835 commit refs/notes/foobar
1837 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1847 commit refs/notes/foobar2
1849 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1859 commit refs/notes/foobar
1861 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1874 test_expect_success \
1876 'git fast-import <input &&
1877 git whatchanged notes-test'
1879 test_expect_success
'Q: verify pack' '
1883 commit1
=$
(git rev-parse notes-test~
2)
1884 commit2
=$
(git rev-parse notes-test^
)
1885 commit3
=$
(git rev-parse notes-test
)
1888 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1889 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1893 test_expect_success \
1894 'Q: verify first commit' \
1895 'git cat-file commit notes-test~2 | sed 1d >actual &&
1896 test_cmp expect actual'
1900 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1901 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1905 test_expect_success \
1906 'Q: verify second commit' \
1907 'git cat-file commit notes-test^ | sed 1d >actual &&
1908 test_cmp expect actual'
1912 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1913 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1917 test_expect_success \
1918 'Q: verify third commit' \
1919 'git cat-file commit notes-test | sed 1d >actual &&
1920 test_cmp expect actual'
1923 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1924 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1928 test_expect_success \
1929 'Q: verify first notes commit' \
1930 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1931 test_cmp expect actual'
1933 cat >expect.unsorted
<<EOF
1934 100644 blob $commit1
1935 100644 blob $commit2
1936 100644 blob $commit3
1938 cat expect.unsorted |
sort >expect
1939 test_expect_success \
1940 'Q: verify first notes tree' \
1941 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1942 test_cmp expect actual'
1944 echo "$note1_data" >expect
1945 test_expect_success \
1946 'Q: verify first note for first commit' \
1947 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1949 echo "$note2_data" >expect
1950 test_expect_success \
1951 'Q: verify first note for second commit' \
1952 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1954 echo "$note3_data" >expect
1955 test_expect_success \
1956 'Q: verify first note for third commit' \
1957 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1960 parent `git rev-parse --verify refs/notes/foobar~2`
1961 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1962 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1966 test_expect_success \
1967 'Q: verify second notes commit' \
1968 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1969 test_cmp expect actual'
1971 cat >expect.unsorted
<<EOF
1972 100644 blob $commit1
1973 100644 blob $commit2
1974 100644 blob $commit3
1976 cat expect.unsorted |
sort >expect
1977 test_expect_success \
1978 'Q: verify second notes tree' \
1979 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1980 test_cmp expect actual'
1982 echo "$note1b_data" >expect
1983 test_expect_success \
1984 'Q: verify second note for first commit' \
1985 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1987 echo "$note2_data" >expect
1988 test_expect_success \
1989 'Q: verify first note for second commit' \
1990 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1992 echo "$note3_data" >expect
1993 test_expect_success \
1994 'Q: verify first note for third commit' \
1995 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1998 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1999 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2003 test_expect_success \
2004 'Q: verify third notes commit' \
2005 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2006 test_cmp expect actual'
2008 cat >expect.unsorted
<<EOF
2009 100644 blob $commit1
2011 cat expect.unsorted |
sort >expect
2012 test_expect_success \
2013 'Q: verify third notes tree' \
2014 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2015 test_cmp expect actual'
2017 echo "$note1c_data" >expect
2018 test_expect_success \
2019 'Q: verify third note for first commit' \
2020 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
2023 parent `git rev-parse --verify refs/notes/foobar^`
2024 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2025 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2029 test_expect_success \
2030 'Q: verify fourth notes commit' \
2031 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
2032 test_cmp expect actual'
2034 cat >expect.unsorted
<<EOF
2035 100644 blob $commit2
2037 cat expect.unsorted |
sort >expect
2038 test_expect_success \
2039 'Q: verify fourth notes tree' \
2040 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2041 test_cmp expect actual'
2043 echo "$note2b_data" >expect
2044 test_expect_success \
2045 'Q: verify second note for second commit' \
2046 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
2051 commit refs/heads/note-Q0
2052 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2054 Note for an empty branch.
2057 N inline refs/heads/Q0
2062 test_expect_success \
2063 'Q: deny note on empty branch' \
2064 'test_must_fail git fast-import <input'
2066 ### series R (feature and option)
2070 feature no-such-feature-exists
2073 test_expect_success
'R: abort on unsupported feature' '
2074 test_must_fail git fast-import <input
2078 feature date-format=now
2081 test_expect_success
'R: supported feature is accepted' '
2082 git fast-import <input
2089 feature date-format=now
2092 test_expect_success
'R: abort on receiving feature after data command' '
2093 test_must_fail git fast-import <input
2097 feature import-marks=git.marks
2098 feature import-marks=git2.marks
2101 test_expect_success
'R: only one import-marks feature allowed per stream' '
2102 test_must_fail git fast-import <input
2106 feature export-marks=git.marks
2114 test_expect_success \
2115 'R: export-marks feature results in a marks file being created' \
2116 'cat input | git fast-import &&
2119 test_expect_success \
2120 'R: export-marks options can be overridden by commandline options' \
2121 'cat input | git fast-import --export-marks=other.marks &&
2122 grep :1 other.marks'
2124 test_expect_success
'R: catch typo in marks file name' '
2125 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2126 echo "feature import-marks=nonexistent.marks" |
2127 test_must_fail git fast-import
2130 test_expect_success
'R: import and output marks can be the same file' '
2132 blob=$(echo hi | git hash-object --stdin) &&
2133 cat >expect <<-EOF &&
2137 git fast-import --export-marks=io.marks <<-\EOF &&
2144 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2151 test_cmp expect io.marks
2154 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
2156 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2165 test_expect_success
'R: --import-marks-if-exists' '
2167 blob=$(echo hi | git hash-object --stdin) &&
2168 echo ":1 $blob" >expect &&
2169 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2176 test_cmp expect io.marks
2179 test_expect_success
'R: feature import-marks-if-exists' '
2183 git fast-import --export-marks=io.marks <<-\EOF &&
2184 feature import-marks-if-exists=not_io.marks
2186 test_cmp expect io.marks &&
2188 blob=$(echo hi | git hash-object --stdin) &&
2190 echo ":1 $blob" >io.marks &&
2191 echo ":1 $blob" >expect &&
2192 echo ":2 $blob" >>expect &&
2194 git fast-import --export-marks=io.marks <<-\EOF &&
2195 feature import-marks-if-exists=io.marks
2202 test_cmp expect io.marks &&
2204 echo ":3 $blob" >>expect &&
2206 git fast-import --import-marks=io.marks \
2207 --export-marks=io.marks <<-\EOF &&
2208 feature import-marks-if-exists=not_io.marks
2215 test_cmp expect io.marks &&
2219 git fast-import --import-marks-if-exists=not_io.marks \
2220 --export-marks=io.marks <<-\EOF
2221 feature import-marks-if-exists=io.marks
2223 test_cmp expect io.marks
2227 feature import-marks=marks.out
2228 feature export-marks=marks.new
2231 test_expect_success \
2232 'R: import to output marks works without any content' \
2233 'cat input | git fast-import &&
2234 test_cmp marks.out marks.new'
2237 feature import-marks=nonexistent.marks
2238 feature export-marks=marks.new
2241 test_expect_success \
2242 'R: import marks prefers commandline marks file over the stream' \
2243 'cat input | git fast-import --import-marks=marks.out &&
2244 test_cmp marks.out marks.new'
2248 feature import-marks=nonexistent.marks
2249 feature export-marks=combined.marks
2252 test_expect_success
'R: multiple --import-marks= should be honoured' '
2253 head -n2 marks.out > one.marks &&
2254 tail -n +3 marks.out > two.marks &&
2255 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2256 test_cmp marks.out combined.marks
2260 feature relative-marks
2261 feature import-marks=relative.in
2262 feature export-marks=relative.out
2265 test_expect_success
'R: feature relative-marks should be honoured' '
2266 mkdir -p .git/info/fast-import/ &&
2267 cp marks.new .git/info/fast-import/relative.in &&
2268 git fast-import <input &&
2269 test_cmp marks.new .git/info/fast-import/relative.out
2273 feature relative-marks
2274 feature import-marks=relative.in
2275 feature no-relative-marks
2276 feature export-marks=non-relative.out
2279 test_expect_success
'R: feature no-relative-marks should be honoured' '
2280 git fast-import <input &&
2281 test_cmp marks.new non-relative.out
2284 test_expect_success
'R: feature ls supported' '
2289 test_expect_success
'R: feature cat-blob supported' '
2290 echo "feature cat-blob" |
2294 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
2295 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2298 test_expect_success NOT_MINGW
'R: print old blob' '
2299 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2300 cat >expect <<-EOF &&
2305 echo "cat-blob $blob" |
2306 git fast-import --cat-blob-fd=6 6>actual &&
2307 test_cmp expect actual
2310 test_expect_success NOT_MINGW
'R: in-stream cat-blob-fd not respected' '
2311 echo hello >greeting &&
2312 blob=$(git hash-object -w greeting) &&
2313 cat >expect <<-EOF &&
2318 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2321 test_cmp expect actual.3 &&
2322 test_cmp empty actual.1 &&
2323 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2324 option cat-blob-fd=3
2327 test_cmp empty actual.3 &&
2328 test_cmp expect actual.1
2331 test_expect_success NOT_MINGW
'R: print new blob' '
2332 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2333 cat >expect <<-EOF &&
2338 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2346 test_cmp expect actual
2349 test_expect_success NOT_MINGW
'R: print new blob by sha1' '
2350 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2351 cat >expect <<-EOF &&
2353 a new blob named by sha1
2356 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2359 a new blob named by sha1
2363 test_cmp expect actual
2366 test_expect_success
'setup: big file' '
2368 echo "the quick brown fox jumps over the lazy dog" >big &&
2371 cat big big big big >bigger &&
2372 cat bigger bigger bigger bigger >big ||
2378 test_expect_success
'R: print two blobs to stdout' '
2379 blob1=$(git hash-object big) &&
2380 blob1_len=$(wc -c <big) &&
2381 blob2=$(echo hello | git hash-object --stdin) &&
2383 echo ${blob1} blob $blob1_len &&
2393 cat <<-\END_PART1 &&
2410 git fast-import >actual &&
2411 test_cmp expect actual
2414 test_expect_success PIPE
'R: copy using cat-file' '
2415 expect_id=$(git hash-object big) &&
2416 expect_len=$(wc -c <big) &&
2417 echo $expect_id blob $expect_len >expect.response &&
2420 cat >frontend <<-\FRONTEND_END &&
2426 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2439 read blob_id type size <&3 &&
2440 echo "$blob_id $type $size" >response &&
2441 head_c $size >blob <&3 &&
2445 commit refs/heads/copied
2446 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2448 copy big file as file3
2456 git fast-import --cat-blob-fd=3 3>blobs &&
2457 git show copied:file3 >actual &&
2458 test_cmp expect.response response &&
2462 test_expect_success PIPE
'R: print blob mid-commit' '
2464 echo "A blob from _before_ the commit." >expect &&
2473 A blob from _before_ the commit.
2475 commit refs/heads/temporary
2476 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2483 read blob_id type size <&3 &&
2484 head_c $size >actual <&3 &&
2489 git fast-import --cat-blob-fd=3 3>blobs &&
2490 test_cmp expect actual
2493 test_expect_success PIPE
'R: print staged blob within commit' '
2495 echo "A blob from _within_ the commit." >expect &&
2501 commit refs/heads/within
2502 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2508 A blob from _within_ the commit.
2513 echo "A blob from _within_ the commit." |
2514 git hash-object --stdin
2516 echo "cat-blob $to_get" &&
2518 read blob_id type size <&3 &&
2519 head_c $size >actual <&3 &&
2524 git fast-import --cat-blob-fd=3 3>blobs &&
2525 test_cmp expect actual
2536 test_expect_success
'R: quiet option results in no stats being output' '
2537 cat input | git fast-import 2> output &&
2538 test_cmp empty output
2541 test_expect_success
'R: feature done means terminating "done" is mandatory' '
2542 echo feature done | test_must_fail git fast-import &&
2543 test_must_fail git fast-import --done </dev/null
2546 test_expect_success
'R: terminating "done" with trailing gibberish is ok' '
2547 git fast-import <<-\EOF &&
2552 git fast-import <<-\EOF
2554 more trailing gibberish
2558 test_expect_success
'R: terminating "done" within commit' '
2559 cat >expect <<-\EOF &&
2561 :000000 100644 OBJID OBJID A hello.c
2562 :000000 100644 OBJID OBJID A hello2.c
2564 git fast-import <<-EOF &&
2565 commit refs/heads/done-ends
2566 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2568 Commit terminated by "done" command
2570 M 100644 inline hello.c
2577 git rev-list done-ends |
2578 git diff-tree -r --stdin --root --always |
2579 sed -e "s/$_x40/OBJID/g" >actual &&
2580 test_cmp expect actual
2584 option git non-existing-option
2587 test_expect_success
'R: die on unknown option' '
2588 test_must_fail git fast-import <input
2591 test_expect_success
'R: unknown commandline options are rejected' '\
2592 test_must_fail git fast-import --non-existing-option < /dev/null
2595 test_expect_success
'R: die on invalid option argument' '
2596 echo "option git active-branches=-5" |
2597 test_must_fail git fast-import &&
2598 echo "option git depth=" |
2599 test_must_fail git fast-import &&
2600 test_must_fail git fast-import --depth="5 elephants" </dev/null
2604 option non-existing-vcs non-existing-option
2607 test_expect_success
'R: ignore non-git options' '
2608 git fast-import <input
2612 ## R: very large blobs
2614 blobsize
=$
((2*1024*1024 + 53))
2615 test-genrandom bar
$blobsize >expect
2616 cat >input
<<INPUT_END
2617 commit refs/heads/big-file
2618 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2627 cat >>input
<<INPUT_END
2634 test_expect_success \
2635 'R: blob bigger than threshold' \
2636 'test_create_repo R &&
2637 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2639 test_expect_success
'R: verify created pack' '
2642 verify_packs -v > ../verify
2646 test_expect_success \
2647 'R: verify written objects' \
2648 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2649 test_cmp expect actual &&
2650 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2651 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2653 test_expect_success \
2654 'R: blob appears only once' \
2655 'n=$(grep $a verify | wc -l) &&
2662 # Make sure missing spaces and EOLs after mark references
2671 # commit marks: 301, 302, 303, 304
2672 # blob marks: 403, 404, resp.
2675 # The error message when a space is missing not at the
2676 # end of the line is:
2678 # Missing space after ..
2680 # or when extra characters come after the mark at the end
2685 # or when the dataref is neither "inline " or a known SHA1,
2687 # Invalid dataref ..
2691 cat >input
<<INPUT_END
2694 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2698 M 100644 inline hello.c
2705 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2710 M 100644 inline hello.c
2728 test_expect_success
'S: initialize for S tests' '
2729 git fast-import --export-marks=marks <input
2733 # filemodify, three datarefs
2735 test_expect_success
'S: filemodify with garbage after mark must fail' '
2736 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2738 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2742 M 100644 :403x hello.c
2745 test_i18ngrep "space after mark" err
2748 # inline is misspelled; fast-import thinks it is some unknown dataref
2749 test_expect_success
'S: filemodify with garbage after inline must fail' '
2750 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2752 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2756 M 100644 inlineX hello.c
2762 test_i18ngrep "nvalid dataref" err
2765 test_expect_success
'S: filemodify with garbage after sha1 must fail' '
2766 sha1=$(grep :403 marks | cut -d\ -f2) &&
2767 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2769 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2773 M 100644 ${sha1}x hello.c
2776 test_i18ngrep "space after SHA1" err
2780 # notemodify, three ways to say dataref
2782 test_expect_success
'S: notemodify with garabge after mark dataref must fail' '
2783 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2785 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2787 commit S note dataref markref
2792 test_i18ngrep "space after mark" err
2795 test_expect_success
'S: notemodify with garbage after inline dataref must fail' '
2796 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2798 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2800 commit S note dataref inline
2808 test_i18ngrep "nvalid dataref" err
2811 test_expect_success
'S: notemodify with garbage after sha1 dataref must fail' '
2812 sha1=$(grep :202 marks | cut -d\ -f2) &&
2813 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2815 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2817 commit S note dataref sha1
2822 test_i18ngrep "space after SHA1" err
2826 # notemodify, mark in committish
2828 test_expect_success
'S: notemodify with garbarge after mark committish must fail' '
2829 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2830 commit refs/heads/Snotes
2831 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2833 commit S note committish
2838 test_i18ngrep "after mark" err
2844 test_expect_success
'S: from with garbage after mark must fail' '
2846 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err
2847 commit refs/heads/S2
2849 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2854 M 100644 :403 hello.c
2858 echo returned $ret &&
2859 test $ret -ne 0 && # failed, but it created the commit
2861 # go create the commit, need it for merge test
2862 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2863 commit refs/heads/S2
2865 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2870 M 100644 :403 hello.c
2873 # now evaluate the error
2875 test_i18ngrep "after mark" err
2882 test_expect_success
'S: merge with garbage after mark must fail' '
2883 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2886 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2892 M 100644 :403 hello.c
2895 test_i18ngrep "after mark" err
2901 test_expect_success
'S: tag with garbage after mark must fail' '
2902 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2905 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2911 test_i18ngrep "after mark" err
2917 test_expect_success
'S: cat-blob with garbage after mark must fail' '
2918 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2922 test_i18ngrep "after mark" err
2928 test_expect_success
'S: ls with garbage after mark must fail' '
2929 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2933 test_i18ngrep "space after mark" err
2936 test_expect_success
'S: ls with garbage after sha1 must fail' '
2937 sha1=$(grep :302 marks | cut -d\ -f2) &&
2938 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2942 test_i18ngrep "space after tree-ish" err