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.'
56 test_expect_success
'empty stream succeeds' '
57 git fast-import </dev/null
60 cat >input
<<INPUT_END
77 commit refs/heads/master
79 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
91 An annotated tag without a tagger
97 An annotated tag that annotates a blob.
101 test_expect_success
'A: create pack from stdin' '
102 git fast-import --export-marks=marks.out <input &&
103 git whatchanged master
106 test_expect_success
'A: verify pack' '
111 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
112 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
116 test_expect_success
'A: verify commit' '
117 git cat-file commit master | sed 1d >actual &&
118 test_cmp expect actual
126 test_expect_success
'A: verify tree' '
127 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
128 test_cmp expect actual
131 echo "$file2_data" >expect
132 test_expect_success
'A: verify file2' '
133 git cat-file blob master:file2 >actual && test_cmp expect actual
136 echo "$file3_data" >expect
137 test_expect_success
'A: verify file3' '
138 git cat-file blob master:file3 >actual && test_cmp expect actual
141 printf "$file4_data" >expect
142 test_expect_success
'A: verify file4' '
143 git cat-file blob master:file4 >actual && test_cmp expect actual
147 object $(git rev-parse refs/heads/master)
151 An annotated tag without a tagger
153 test_expect_success
'A: verify tag/series-A' '
154 git cat-file tag tags/series-A >actual &&
155 test_cmp expect actual
159 object $(git rev-parse refs/heads/master:file3)
163 An annotated tag that annotates a blob.
165 test_expect_success
'A: verify tag/series-A-blob' '
166 git cat-file tag tags/series-A-blob >actual &&
167 test_cmp expect actual
171 :2 `git rev-parse --verify master:file2`
172 :3 `git rev-parse --verify master:file3`
173 :4 `git rev-parse --verify master:file4`
174 :5 `git rev-parse --verify master^0`
176 test_expect_success
'A: verify marks output' '
177 test_cmp expect marks.out
180 test_expect_success
'A: verify marks import' '
182 --import-marks=marks.out \
183 --export-marks=marks.new \
185 test_cmp expect marks.new
189 new_blob
=$
(echo testing | git hash-object
--stdin)
190 cat >input
<<INPUT_END
192 from $(git rev-parse refs/heads/master:file3)
203 commit refs/heads/new_blob
207 #pretend we got sha1 from fast-import
218 object $(git rev-parse refs/heads/master:file3)
230 test_expect_success
'A: tag blob by sha1' '
231 git fast-import <input &&
232 git cat-file tag tags/series-A-blob-2 >actual &&
233 git cat-file tag tags/series-A-blob-3 >>actual &&
234 test_cmp expect actual
238 cat >input
<<INPUT_END
239 commit refs/heads/verify--import-marks
240 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
246 M 755 :2 copy-of-file2
249 test_expect_success
'A: verify marks import does not crash' '
250 git fast-import --import-marks=marks.out <input &&
251 git whatchanged verify--import-marks
254 test_expect_success
'A: verify pack' '
259 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
261 git diff-tree
-M -r master verify--import-marks
>actual
262 test_expect_success
'A: verify diff' '
263 compare_diff_raw expect actual &&
264 test `git rev-parse --verify master:file2` \
265 = `git rev-parse --verify verify--import-marks:copy-of-file2`
269 mt
=$
(git hash-object
--stdin < /dev
/null
)
274 cat >input.commit
<<EOF
275 commit refs/heads/verify--dump-marks
276 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
278 test the sparse array dumping routines with exponentially growing marks
286 while test "$i" -lt 27; do
287 cat >>input.blob
<<EOF
298 echo "M 100644 :$l l$i" >>input.commit
299 echo "M 100644 :$m m$i" >>input.commit
300 echo "M 100644 :$n n$i" >>input.commit
302 echo ":$l $mt" >>marks.exp
303 echo ":$m $mt" >>marks.exp
304 echo ":$n $mt" >>marks.exp
306 printf "100644 blob $mt\tl$i\n" >>tree.exp
307 printf "100644 blob $mt\tm$i\n" >>tree.exp
308 printf "100644 blob $mt\tn$i\n" >>tree.exp
317 sort tree.exp
> tree.exp_s
319 test_expect_success
'A: export marks with large values' '
320 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
321 git ls-tree refs/heads/verify--dump-marks >tree.out &&
322 test_cmp tree.exp_s tree.out &&
323 test_cmp marks.exp marks.large
331 cat >input
<<INPUT_END
332 commit refs/heads/branch
334 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
339 from refs/heads/master
340 M 755 0000000000000000000000000000000000000001 zero1
343 test_expect_success
'B: fail on invalid blob sha1' '
344 test_must_fail git fast-import <input
346 rm -f .git
/objects
/pack_
* .git
/objects
/index_
*
348 cat >input
<<INPUT_END
350 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
355 from refs/heads/master
358 test_expect_success
'B: accept branch name "TEMP_TAG"' '
359 git fast-import <input &&
360 test -f .git/TEMP_TAG &&
361 test `git rev-parse master` = `git rev-parse TEMP_TAG^`
365 git gc
2>/dev
/null
>/dev
/null
366 git prune
2>/dev
/null
>/dev
/null
368 cat >input
<<INPUT_END
369 commit refs/heads/empty-committer-1
370 committer <> $GIT_COMMITTER_DATE
375 test_expect_success
'B: accept empty committer' '
376 git fast-import <input &&
381 git update-ref
-d refs
/heads
/empty-committer-1 || true
383 git gc
2>/dev
/null
>/dev
/null
384 git prune
2>/dev
/null
>/dev
/null
386 cat >input
<<INPUT_END
387 commit refs/heads/empty-committer-2
388 committer <a@b.com> $GIT_COMMITTER_DATE
393 test_expect_success
'B: accept and fixup committer with no name' '
394 git fast-import <input &&
399 git update-ref
-d refs
/heads
/empty-committer-2 || true
401 git gc
2>/dev
/null
>/dev
/null
402 git prune
2>/dev
/null
>/dev
/null
404 cat >input
<<INPUT_END
405 commit refs/heads/invalid-committer
406 committer Name email> $GIT_COMMITTER_DATE
411 test_expect_success
'B: fail on invalid committer (1)' '
412 test_must_fail git fast-import <input
414 git update-ref
-d refs
/heads
/invalid-committer || true
416 cat >input
<<INPUT_END
417 commit refs/heads/invalid-committer
418 committer Name <e<mail> $GIT_COMMITTER_DATE
423 test_expect_success
'B: fail on invalid committer (2)' '
424 test_must_fail git fast-import <input
426 git update-ref
-d refs
/heads
/invalid-committer || true
428 cat >input
<<INPUT_END
429 commit refs/heads/invalid-committer
430 committer Name <email>> $GIT_COMMITTER_DATE
435 test_expect_success
'B: fail on invalid committer (3)' '
436 test_must_fail git fast-import <input
438 git update-ref
-d refs
/heads
/invalid-committer || true
440 cat >input
<<INPUT_END
441 commit refs/heads/invalid-committer
442 committer Name <email $GIT_COMMITTER_DATE
447 test_expect_success
'B: fail on invalid committer (4)' '
448 test_must_fail git fast-import <input
450 git update-ref
-d refs
/heads
/invalid-committer || true
452 cat >input
<<INPUT_END
453 commit refs/heads/invalid-committer
454 committer Name<email> $GIT_COMMITTER_DATE
459 test_expect_success
'B: fail on invalid committer (5)' '
460 test_must_fail git fast-import <input
462 git update-ref
-d refs
/heads
/invalid-committer || true
468 newf
=`echo hi newf | git hash-object -w --stdin`
469 oldf
=`git rev-parse --verify master:file2`
471 cat >input
<<INPUT_END
472 commit refs/heads/branch
473 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
478 from refs/heads/master
479 M 644 $oldf file2/oldf
480 M 755 $newf file2/newf
484 test_expect_success
'C: incremental import create pack from stdin' '
485 git fast-import <input &&
486 git whatchanged branch
489 test_expect_success
'C: verify pack' '
493 test_expect_success
'C: validate reuse existing blob' '
494 test $newf = `git rev-parse --verify branch:file2/newf` &&
495 test $oldf = `git rev-parse --verify branch:file2/oldf`
499 parent `git rev-parse --verify master^0`
500 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
501 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
505 test_expect_success
'C: verify commit' '
506 git cat-file commit branch | sed 1d >actual &&
507 test_cmp expect actual
511 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
512 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
513 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
515 git diff-tree
-M -r master branch
>actual
516 test_expect_success
'C: validate rename result' '
517 compare_diff_raw expect actual
525 cat >input
<<INPUT_END
526 commit refs/heads/branch
527 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
532 from refs/heads/branch^0
533 M 644 inline newdir/interesting
538 M 755 inline newdir/exec.sh
544 test_expect_success
'D: inline data in commit' '
545 git fast-import <input &&
546 git whatchanged branch
549 test_expect_success
'D: verify pack' '
554 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
555 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
557 git diff-tree
-M -r branch^ branch
>actual
558 test_expect_success
'D: validate new files added' '
559 compare_diff_raw expect actual
562 echo "$file5_data" >expect
563 test_expect_success
'D: verify file5' '
564 git cat-file blob branch:newdir/interesting >actual &&
565 test_cmp expect actual
568 echo "$file6_data" >expect
569 test_expect_success
'D: verify file6' '
570 git cat-file blob branch:newdir/exec.sh >actual &&
571 test_cmp expect actual
578 cat >input
<<INPUT_END
579 commit refs/heads/branch
580 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
581 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
586 from refs/heads/branch^0
589 test_expect_success
'E: rfc2822 date, --date-format=raw' '
590 test_must_fail git fast-import --date-format=raw <input
592 test_expect_success
'E: rfc2822 date, --date-format=rfc2822' '
593 git fast-import --date-format=rfc2822 <input
596 test_expect_success
'E: verify pack' '
601 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
602 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
606 test_expect_success
'E: verify commit' '
607 git cat-file commit branch | sed 1,2d >actual &&
608 test_cmp expect actual
615 old_branch
=`git rev-parse --verify branch^0`
617 cat >input
<<INPUT_END
618 commit refs/heads/branch
619 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
621 losing things already?
624 from refs/heads/branch~1
626 reset refs/heads/other
627 from refs/heads/branch
630 test_expect_success
'F: non-fast-forward update skips' '
631 test_must_fail git fast-import <input &&
632 # branch must remain unaffected
633 test $old_branch = `git rev-parse --verify branch^0`
636 test_expect_success
'F: verify pack' '
641 tree `git rev-parse branch~1^{tree}`
642 parent `git rev-parse branch~1`
643 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
644 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
646 losing things already?
648 test_expect_success
'F: verify other commit' '
649 git cat-file commit other >actual &&
650 test_cmp expect actual
657 old_branch
=`git rev-parse --verify branch^0`
659 cat >input
<<INPUT_END
660 commit refs/heads/branch
661 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
663 losing things already?
666 from refs/heads/branch~1
669 test_expect_success
'G: non-fast-forward update forced' '
670 git fast-import --force <input
673 test_expect_success
'G: verify pack' '
677 test_expect_success
'G: branch changed, but logged' '
678 test $old_branch != `git rev-parse --verify branch^0` &&
679 test $old_branch = `git rev-parse --verify branch@{1}`
687 cat >input
<<INPUT_END
689 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
694 from refs/heads/branch^0
695 M 644 inline i-will-die
697 this file will never exist.
701 M 644 inline h/e/l/lo
707 test_expect_success
'H: deletall, add 1' '
708 git fast-import <input &&
712 test_expect_success
'H: verify pack' '
717 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
718 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
719 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
720 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
721 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
723 git diff-tree
-M -r H^ H
>actual
724 test_expect_success
'H: validate old files removed, new files added' '
725 compare_diff_raw expect actual
728 echo "$file5_data" >expect
729 test_expect_success
'H: verify file' '
730 git cat-file blob H:h/e/l/lo >actual &&
731 test_cmp expect actual
738 cat >input
<<INPUT_END
739 commit refs/heads/export-boundary
740 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
742 we have a border. its only 40 characters wide.
745 from refs/heads/branch
748 test_expect_success
'I: export-pack-edges' '
749 git fast-import --export-pack-edges=edges.list <input
753 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
755 test_expect_success
'I: verify edge list' '
756 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
757 test_cmp expect actual
764 cat >input
<<INPUT_END
766 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
771 from refs/heads/branch
776 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
782 test_expect_success
'J: reset existing branch creates empty commit' '
783 git fast-import <input
785 test_expect_success
'J: branch has 1 commit, empty tree' '
786 test 1 = `git rev-list J | wc -l` &&
787 test 0 = `git ls-tree J | wc -l`
790 cat >input
<<INPUT_END
796 Tag branch that was reset.
799 test_expect_success
'J: tag must fail on empty branch' '
800 test_must_fail git fast-import <input
806 cat >input
<<INPUT_END
808 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
813 from refs/heads/branch
816 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
821 from refs/heads/branch^1
824 test_expect_success
'K: reinit branch with from' '
825 git fast-import <input
827 test_expect_success
'K: verify K^1 = branch^1' '
828 test `git rev-parse --verify branch^1` \
829 = `git rev-parse --verify K^1`
836 cat >input
<<INPUT_END
850 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
860 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
870 cat >expect
<<EXPECT_END
871 :100644 100644 4268632... 55d3a52... M b.
872 :040000 040000 0ae5cac... 443c768... M b
873 :100644 100644 4268632... 55d3a52... M ba
876 test_expect_success
'L: verify internal tree sorting' '
877 git fast-import <input &&
878 git diff-tree --abbrev --raw L^ L >output &&
879 test_cmp expect output
882 cat >input
<<INPUT_END
890 committer C O Mitter <committer@example.com> 1112912473 -0700
899 committer C O Mitter <committer@example.com> 1112912473 -0700
913 test_expect_success
'L: nested tree copy does not corrupt deltas' '
914 git fast-import <input &&
915 git ls-tree L2 g/b/ >tmp &&
916 cat tmp | cut -f 2 >actual &&
917 test_cmp expect actual &&
918 git fsck `git rev-parse L2`
921 git update-ref
-d refs
/heads
/L2
928 cat >input
<<INPUT_END
930 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
935 from refs/heads/branch^0
936 R file2/newf file2/n.e.w.f
941 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
943 test_expect_success
'M: rename file in same subdirectory' '
944 git fast-import <input &&
945 git diff-tree -M -r M1^ M1 >actual &&
946 compare_diff_raw expect actual
949 cat >input
<<INPUT_END
951 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
956 from refs/heads/branch^0
957 R file2/newf i/am/new/to/you
962 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
964 test_expect_success
'M: rename file to new subdirectory' '
965 git fast-import <input &&
966 git diff-tree -M -r M2^ M2 >actual &&
967 compare_diff_raw expect actual
970 cat >input
<<INPUT_END
972 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
983 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
985 test_expect_success
'M: rename subdirectory to new subdirectory' '
986 git fast-import <input &&
987 git diff-tree -M -r M3^ M3 >actual &&
988 compare_diff_raw expect actual
991 cat >input
<<INPUT_END
993 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1004 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1005 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1006 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1007 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1008 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1010 test_expect_success
'M: rename root to subdirectory' '
1011 git fast-import <input &&
1012 git diff-tree -M -r M4^ M4 >actual &&
1014 compare_diff_raw expect actual
1022 cat >input
<<INPUT_END
1023 commit refs/heads/N1
1024 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1029 from refs/heads/branch^0
1030 C file2/newf file2/n.e.w.f
1035 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1037 test_expect_success
'N: copy file in same subdirectory' '
1038 git fast-import <input &&
1039 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1040 compare_diff_raw expect actual
1043 cat >input
<<INPUT_END
1044 commit refs/heads/N2
1045 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1047 clean directory copy
1050 from refs/heads/branch^0
1053 commit refs/heads/N2
1054 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1056 modify directory copy
1059 M 644 inline file3/file5
1067 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1068 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1069 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1071 test_expect_success
'N: copy then modify subdirectory' '
1072 git fast-import <input &&
1073 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1074 compare_diff_raw expect actual
1077 cat >input
<<INPUT_END
1078 commit refs/heads/N3
1079 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1081 dirty directory copy
1084 from refs/heads/branch^0
1085 M 644 inline file2/file5
1095 test_expect_success
'N: copy dirty subdirectory' '
1096 git fast-import <input &&
1097 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`
1100 test_expect_success
'N: copy directory by id' '
1101 cat >expect <<-\EOF &&
1102 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1103 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1105 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1106 cat >input <<-INPUT_END &&
1107 commit refs/heads/N4
1108 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1113 from refs/heads/branch^0
1114 M 040000 $subdir file3
1116 git fast-import <input &&
1117 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1118 compare_diff_raw expect actual
1121 test_expect_success PIPE
'N: read and copy directory' '
1122 cat >expect <<-\EOF &&
1123 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1124 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1126 git update-ref -d refs/heads/N4 &&
1132 commit refs/heads/N4
1133 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1135 copy by tree hash, part 2
1138 from refs/heads/branch^0
1141 read mode type tree filename &&
1142 echo "M 040000 $tree file3"
1144 git fast-import --cat-blob-fd=3 3>backflow &&
1145 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1146 compare_diff_raw expect actual
1149 test_expect_success PIPE
'N: empty directory reads as missing' '
1150 cat <<-\EOF >expect &&
1152 :000000 100644 OBJNAME OBJNAME A unrelated
1154 echo "missing src" >expect.response &&
1155 git update-ref -d refs/heads/read-empty &&
1161 commit refs/heads/read-empty
1162 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1164 read "empty" (missing) directory
1167 M 100644 inline src/greeting
1171 C src/greeting dst1/non-greeting
1172 C src/greeting unrelated
1173 # leave behind "empty" src directory
1178 printf "%s\n" "$line" >response &&
1184 git fast-import --cat-blob-fd=3 3>backflow &&
1185 test_cmp expect.response response &&
1186 git rev-list read-empty |
1187 git diff-tree -r --root --stdin |
1188 sed "s/$_x40/OBJNAME/g" >actual &&
1189 test_cmp expect actual
1192 test_expect_success
'N: copy root directory by tree hash' '
1193 cat >expect <<-\EOF &&
1194 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1195 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1197 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1198 cat >input <<-INPUT_END &&
1199 commit refs/heads/N6
1200 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1202 copy root directory by tree hash
1205 from refs/heads/branch^0
1208 git fast-import <input &&
1209 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1210 compare_diff_raw expect actual
1213 test_expect_success
'N: copy root by path' '
1214 cat >expect <<-\EOF &&
1215 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1216 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1217 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1218 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1219 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1221 cat >input <<-INPUT_END &&
1222 commit refs/heads/N-copy-root-path
1223 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1225 copy root directory by (empty) path
1228 from refs/heads/branch^0
1231 git fast-import <input &&
1232 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1233 compare_diff_raw expect actual
1236 test_expect_success
'N: delete directory by copying' '
1237 cat >expect <<-\EOF &&
1239 :100644 000000 OBJID OBJID D foo/bar/qux
1241 :000000 100644 OBJID OBJID A foo/bar/baz
1242 :000000 100644 OBJID OBJID A foo/bar/qux
1244 empty_tree=$(git mktree </dev/null) &&
1245 cat >input <<-INPUT_END &&
1246 commit refs/heads/N-delete
1247 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1249 collect data to be deleted
1253 M 100644 inline foo/bar/baz
1257 C "foo/bar/baz" "foo/bar/qux"
1258 C "foo/bar/baz" "foo/bar/quux/1"
1259 C "foo/bar/baz" "foo/bar/quuux"
1260 M 040000 $empty_tree foo/bar/quux
1261 M 040000 $empty_tree foo/bar/quuux
1263 commit refs/heads/N-delete
1264 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1269 M 040000 $empty_tree foo/bar/qux
1271 git fast-import <input &&
1272 git rev-list N-delete |
1273 git diff-tree -r --stdin --root --always |
1274 sed -e "s/$_x40/OBJID/g" >actual &&
1275 test_cmp expect actual
1278 test_expect_success
'N: modify copied tree' '
1279 cat >expect <<-\EOF &&
1280 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1281 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1282 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1284 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1285 cat >input <<-INPUT_END &&
1286 commit refs/heads/N5
1287 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1292 from refs/heads/branch^0
1293 M 040000 $subdir file3
1295 commit refs/heads/N5
1296 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1298 modify directory copy
1301 M 644 inline file3/file5
1306 git fast-import <input &&
1307 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1308 compare_diff_raw expect actual
1311 test_expect_success
'N: reject foo/ syntax' '
1312 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1313 test_must_fail git fast-import <<-INPUT_END
1314 commit refs/heads/N5B
1315 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1317 copy with invalid syntax
1320 from refs/heads/branch^0
1321 M 040000 $subdir file3/
1325 test_expect_success
'N: reject foo/ syntax in copy source' '
1326 test_must_fail git fast-import <<-INPUT_END
1327 commit refs/heads/N5C
1328 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1330 copy with invalid syntax
1333 from refs/heads/branch^0
1338 test_expect_success
'N: reject foo/ syntax in rename source' '
1339 test_must_fail git fast-import <<-INPUT_END
1340 commit refs/heads/N5D
1341 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1343 rename with invalid syntax
1346 from refs/heads/branch^0
1351 test_expect_success
'N: reject foo/ syntax in ls argument' '
1352 test_must_fail git fast-import <<-INPUT_END
1353 commit refs/heads/N5E
1354 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1356 copy with invalid syntax
1359 from refs/heads/branch^0
1364 test_expect_success
'N: copy to root by id and modify' '
1365 echo "hello, world" >expect.foo &&
1366 echo hello >expect.bar &&
1367 git fast-import <<-SETUP_END &&
1368 commit refs/heads/N7
1369 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1375 M 644 inline foo/bar
1381 tree=$(git rev-parse --verify N7:) &&
1382 git fast-import <<-INPUT_END &&
1383 commit refs/heads/N8
1384 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1386 copy to root by id and modify
1390 M 644 inline foo/foo
1395 git show N8:foo/foo >actual.foo &&
1396 git show N8:foo/bar >actual.bar &&
1397 test_cmp expect.foo actual.foo &&
1398 test_cmp expect.bar actual.bar
1401 test_expect_success
'N: extract subtree' '
1402 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1403 cat >input <<-INPUT_END &&
1404 commit refs/heads/N9
1405 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1407 extract subtree branch:newdir
1413 git fast-import <input &&
1414 git diff --exit-code branch:newdir N9
1417 test_expect_success
'N: modify subtree, extract it, and modify again' '
1418 echo hello >expect.baz &&
1419 echo hello, world >expect.qux &&
1420 git fast-import <<-SETUP_END &&
1421 commit refs/heads/N10
1422 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1428 M 644 inline foo/bar/baz
1434 tree=$(git rev-parse --verify N10:) &&
1435 git fast-import <<-INPUT_END &&
1436 commit refs/heads/N11
1437 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1439 copy to root by id and modify
1443 M 100644 inline foo/bar/qux
1448 C "bar/qux" "bar/quux"
1450 git show N11:bar/baz >actual.baz &&
1451 git show N11:bar/qux >actual.qux &&
1452 git show N11:bar/quux >actual.quux &&
1453 test_cmp expect.baz actual.baz &&
1454 test_cmp expect.qux actual.qux &&
1455 test_cmp expect.qux actual.quux'
1461 cat >input
<<INPUT_END
1463 commit refs/heads/O1
1464 # -- ignore all of this text
1465 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1466 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1468 dirty directory copy
1471 # don't forget the import blank line!
1473 # yes, we started from our usual base of branch^0.
1475 from refs/heads/branch^0
1476 # and we need to reuse file2/file5 from N3 above.
1477 M 644 inline file2/file5
1478 # otherwise the tree will be different
1483 # don't forget to copy file2 to file3
1486 # or to delete file5 from file2.
1492 test_expect_success
'O: comments are all skipped' '
1493 git fast-import <input &&
1494 test `git rev-parse N3` = `git rev-parse O1`
1497 cat >input
<<INPUT_END
1498 commit refs/heads/O2
1499 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1501 dirty directory copy
1503 from refs/heads/branch^0
1504 M 644 inline file2/file5
1513 test_expect_success
'O: blank lines not necessary after data commands' '
1514 git fast-import <input &&
1515 test `git rev-parse N3` = `git rev-parse O2`
1518 test_expect_success
'O: repack before next test' '
1522 cat >input
<<INPUT_END
1523 commit refs/heads/O3
1524 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1528 commit refs/heads/O3
1529 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1534 commit refs/heads/O3
1536 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1541 commit refs/heads/O3
1542 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1546 reset refs/tags/O3-2nd
1548 reset refs/tags/O3-3rd
1552 cat >expect
<<INPUT_END
1558 test_expect_success
'O: blank lines not necessary after other commands' '
1559 git fast-import <input &&
1560 test 8 = `find .git/objects/pack -type f | wc -l` &&
1561 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1562 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1563 test_cmp expect actual
1566 cat >input
<<INPUT_END
1567 commit refs/heads/O4
1568 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1572 commit refs/heads/O4
1573 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1577 progress Two commits down, 2 to go!
1578 commit refs/heads/O4
1579 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1583 progress Three commits down, 1 to go!
1584 commit refs/heads/O4
1585 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1591 test_expect_success
'O: progress outputs as requested by input' '
1592 git fast-import <input >actual &&
1593 grep "progress " <input >expect &&
1594 test_cmp expect actual
1598 ### series P (gitlinks)
1601 cat >input
<<INPUT_END
1607 reset refs/heads/sub
1608 commit refs/heads/sub
1610 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1623 commit refs/heads/subuse1
1625 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1628 from refs/heads/master
1629 M 100644 :3 .gitmodules
1638 commit refs/heads/sub
1640 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1646 commit refs/heads/subuse1
1648 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1656 test_expect_success
'P: superproject & submodule mix' '
1657 git fast-import <input &&
1658 git checkout subuse1 &&
1659 rm -rf sub && mkdir sub && (cd sub &&
1661 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1662 git checkout master) &&
1663 git submodule init &&
1664 git submodule update
1667 SUBLAST
=$
(git rev-parse
--verify sub
)
1668 SUBPREV
=$
(git rev-parse
--verify sub^
)
1670 cat >input
<<INPUT_END
1679 commit refs/heads/subuse2
1681 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1684 from refs/heads/master
1685 M 100644 :1 .gitmodules
1686 M 160000 $SUBPREV sub
1688 commit refs/heads/subuse2
1690 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1694 M 160000 $SUBLAST sub
1698 test_expect_success
'P: verbatim SHA gitlinks' '
1699 git branch -D sub &&
1700 git gc && git prune &&
1701 git fast-import <input &&
1702 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1706 cat >input
<<INPUT_END
1707 commit refs/heads/subuse3
1709 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1714 from refs/heads/subuse2
1722 test_expect_success
'P: fail on inline gitlink' '
1723 test_must_fail git fast-import <input
1727 cat >input
<<INPUT_END
1734 commit refs/heads/subuse3
1736 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1741 from refs/heads/subuse2
1746 test_expect_success
'P: fail on blob mark in gitlink' '
1747 test_must_fail git fast-import <input
1751 ### series Q (notes)
1754 note1_data
="The first note for the first commit"
1755 note2_data
="The first note for the second commit"
1756 note3_data
="The first note for the third commit"
1757 note1b_data
="The second note for the first commit"
1758 note1c_data
="The third note for the first commit"
1759 note2b_data
="The second note for the second commit"
1762 cat >input
<<INPUT_END
1769 commit refs/heads/notes-test
1771 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1782 commit refs/heads/notes-test
1784 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1791 commit refs/heads/notes-test
1793 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1820 commit refs/notes/foobar
1822 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1834 commit refs/notes/foobar
1836 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1846 commit refs/notes/foobar2
1848 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1858 commit refs/notes/foobar
1860 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1873 test_expect_success
'Q: commit notes' '
1874 git fast-import <input &&
1875 git whatchanged notes-test
1878 test_expect_success
'Q: verify pack' '
1882 commit1
=$
(git rev-parse notes-test~
2)
1883 commit2
=$
(git rev-parse notes-test^
)
1884 commit3
=$
(git rev-parse notes-test
)
1887 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1888 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1892 test_expect_success
'Q: verify first commit' '
1893 git cat-file commit notes-test~2 | sed 1d >actual &&
1894 test_cmp expect actual
1899 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1900 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1904 test_expect_success
'Q: verify second commit' '
1905 git cat-file commit notes-test^ | sed 1d >actual &&
1906 test_cmp expect actual
1911 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1912 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1916 test_expect_success
'Q: verify third commit' '
1917 git cat-file commit notes-test | sed 1d >actual &&
1918 test_cmp expect actual
1922 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1923 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1927 test_expect_success
'Q: verify first notes commit' '
1928 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1929 test_cmp expect actual
1932 cat >expect.unsorted
<<EOF
1933 100644 blob $commit1
1934 100644 blob $commit2
1935 100644 blob $commit3
1937 cat expect.unsorted |
sort >expect
1938 test_expect_success
'Q: verify first notes tree' '
1939 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1940 test_cmp expect actual
1943 echo "$note1_data" >expect
1944 test_expect_success
'Q: verify first note for first commit' '
1945 git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual
1948 echo "$note2_data" >expect
1949 test_expect_success
'Q: verify first note for second commit' '
1950 git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual
1953 echo "$note3_data" >expect
1954 test_expect_success
'Q: verify first note for third commit' '
1955 git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual
1959 parent `git rev-parse --verify refs/notes/foobar~2`
1960 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1961 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1965 test_expect_success
'Q: verify second notes commit' '
1966 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1967 test_cmp expect actual
1970 cat >expect.unsorted
<<EOF
1971 100644 blob $commit1
1972 100644 blob $commit2
1973 100644 blob $commit3
1975 cat expect.unsorted |
sort >expect
1976 test_expect_success
'Q: verify second notes tree' '
1977 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1978 test_cmp expect actual
1981 echo "$note1b_data" >expect
1982 test_expect_success
'Q: verify second note for first commit' '
1983 git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual
1986 echo "$note2_data" >expect
1987 test_expect_success
'Q: verify first note for second commit' '
1988 git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual
1991 echo "$note3_data" >expect
1992 test_expect_success
'Q: verify first note for third commit' '
1993 git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual
1997 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1998 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2002 test_expect_success
'Q: verify third notes commit' '
2003 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2004 test_cmp expect actual
2007 cat >expect.unsorted
<<EOF
2008 100644 blob $commit1
2010 cat expect.unsorted |
sort >expect
2011 test_expect_success
'Q: verify third notes tree' '
2012 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2013 test_cmp expect actual
2016 echo "$note1c_data" >expect
2017 test_expect_success
'Q: verify third note for first commit' '
2018 git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual
2022 parent `git rev-parse --verify refs/notes/foobar^`
2023 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2024 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2028 test_expect_success
'Q: verify fourth notes commit' '
2029 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2030 test_cmp expect actual
2033 cat >expect.unsorted
<<EOF
2034 100644 blob $commit2
2036 cat expect.unsorted |
sort >expect
2037 test_expect_success
'Q: verify fourth notes tree' '
2038 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2039 test_cmp expect actual
2042 echo "$note2b_data" >expect
2043 test_expect_success
'Q: verify second note for second commit' '
2044 git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual
2050 commit refs/heads/note-Q0
2051 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2053 Note for an empty branch.
2056 N inline refs/heads/Q0
2061 test_expect_success
'Q: deny note on empty branch' '
2062 test_must_fail git fast-import <input
2065 ### series R (feature and option)
2069 feature no-such-feature-exists
2072 test_expect_success
'R: abort on unsupported feature' '
2073 test_must_fail git fast-import <input
2077 feature date-format=now
2080 test_expect_success
'R: supported feature is accepted' '
2081 git fast-import <input
2088 feature date-format=now
2091 test_expect_success
'R: abort on receiving feature after data command' '
2092 test_must_fail git fast-import <input
2096 feature import-marks=git.marks
2097 feature import-marks=git2.marks
2100 test_expect_success
'R: only one import-marks feature allowed per stream' '
2101 test_must_fail git fast-import <input
2105 feature export-marks=git.marks
2113 test_expect_success
'R: export-marks feature results in a marks file being created' '
2114 cat input | git fast-import &&
2118 test_expect_success
'R: export-marks options can be overridden by commandline options' '
2119 cat input | git fast-import --export-marks=other.marks &&
2123 test_expect_success
'R: catch typo in marks file name' '
2124 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2125 echo "feature import-marks=nonexistent.marks" |
2126 test_must_fail git fast-import
2129 test_expect_success
'R: import and output marks can be the same file' '
2131 blob=$(echo hi | git hash-object --stdin) &&
2132 cat >expect <<-EOF &&
2136 git fast-import --export-marks=io.marks <<-\EOF &&
2143 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2150 test_cmp expect io.marks
2153 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
2155 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2164 test_expect_success
'R: --import-marks-if-exists' '
2166 blob=$(echo hi | git hash-object --stdin) &&
2167 echo ":1 $blob" >expect &&
2168 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2175 test_cmp expect io.marks
2178 test_expect_success
'R: feature import-marks-if-exists' '
2182 git fast-import --export-marks=io.marks <<-\EOF &&
2183 feature import-marks-if-exists=not_io.marks
2185 test_cmp expect io.marks &&
2187 blob=$(echo hi | git hash-object --stdin) &&
2189 echo ":1 $blob" >io.marks &&
2190 echo ":1 $blob" >expect &&
2191 echo ":2 $blob" >>expect &&
2193 git fast-import --export-marks=io.marks <<-\EOF &&
2194 feature import-marks-if-exists=io.marks
2201 test_cmp expect io.marks &&
2203 echo ":3 $blob" >>expect &&
2205 git fast-import --import-marks=io.marks \
2206 --export-marks=io.marks <<-\EOF &&
2207 feature import-marks-if-exists=not_io.marks
2214 test_cmp expect io.marks &&
2218 git fast-import --import-marks-if-exists=not_io.marks \
2219 --export-marks=io.marks <<-\EOF &&
2220 feature import-marks-if-exists=io.marks
2222 test_cmp expect io.marks
2226 feature import-marks=marks.out
2227 feature export-marks=marks.new
2230 test_expect_success
'R: import to output marks works without any content' '
2231 cat input | git fast-import &&
2232 test_cmp marks.out marks.new
2236 feature import-marks=nonexistent.marks
2237 feature export-marks=marks.new
2240 test_expect_success
'R: import marks prefers commandline marks file over the stream' '
2241 cat input | git fast-import --import-marks=marks.out &&
2242 test_cmp marks.out marks.new
2247 feature import-marks=nonexistent.marks
2248 feature export-marks=combined.marks
2251 test_expect_success
'R: multiple --import-marks= should be honoured' '
2252 head -n2 marks.out > one.marks &&
2253 tail -n +3 marks.out > two.marks &&
2254 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2255 test_cmp marks.out combined.marks
2259 feature relative-marks
2260 feature import-marks=relative.in
2261 feature export-marks=relative.out
2264 test_expect_success
'R: feature relative-marks should be honoured' '
2265 mkdir -p .git/info/fast-import/ &&
2266 cp marks.new .git/info/fast-import/relative.in &&
2267 git fast-import <input &&
2268 test_cmp marks.new .git/info/fast-import/relative.out
2272 feature relative-marks
2273 feature import-marks=relative.in
2274 feature no-relative-marks
2275 feature export-marks=non-relative.out
2278 test_expect_success
'R: feature no-relative-marks should be honoured' '
2279 git fast-import <input &&
2280 test_cmp marks.new non-relative.out
2283 test_expect_success
'R: feature ls supported' '
2288 test_expect_success
'R: feature cat-blob supported' '
2289 echo "feature cat-blob" |
2293 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
2294 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2297 test_expect_success
!MINGW
'R: print old blob' '
2298 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2299 cat >expect <<-EOF &&
2304 echo "cat-blob $blob" |
2305 git fast-import --cat-blob-fd=6 6>actual &&
2306 test_cmp expect actual
2309 test_expect_success
!MINGW
'R: in-stream cat-blob-fd not respected' '
2310 echo hello >greeting &&
2311 blob=$(git hash-object -w greeting) &&
2312 cat >expect <<-EOF &&
2317 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2320 test_cmp expect actual.3 &&
2321 test_must_be_empty actual.1 &&
2322 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2323 option cat-blob-fd=3
2326 test_must_be_empty actual.3 &&
2327 test_cmp expect actual.1
2330 test_expect_success
!MINGW
'R: print mark for new blob' '
2331 echo "effluentish" | git hash-object --stdin >expect &&
2332 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2340 test_cmp expect actual
2343 test_expect_success
!MINGW
'R: print new blob' '
2344 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2345 cat >expect <<-EOF &&
2350 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2358 test_cmp expect actual
2361 test_expect_success
!MINGW
'R: print new blob by sha1' '
2362 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2363 cat >expect <<-EOF &&
2365 a new blob named by sha1
2368 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2371 a new blob named by sha1
2375 test_cmp expect actual
2378 test_expect_success
'setup: big file' '
2380 echo "the quick brown fox jumps over the lazy dog" >big &&
2383 cat big big big big >bigger &&
2384 cat bigger bigger bigger bigger >big ||
2390 test_expect_success
'R: print two blobs to stdout' '
2391 blob1=$(git hash-object big) &&
2392 blob1_len=$(wc -c <big) &&
2393 blob2=$(echo hello | git hash-object --stdin) &&
2395 echo ${blob1} blob $blob1_len &&
2405 cat <<-\END_PART1 &&
2422 git fast-import >actual &&
2423 test_cmp expect actual
2426 test_expect_success PIPE
'R: copy using cat-file' '
2427 expect_id=$(git hash-object big) &&
2428 expect_len=$(wc -c <big) &&
2429 echo $expect_id blob $expect_len >expect.response &&
2432 cat >frontend <<-\FRONTEND_END &&
2438 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2451 read blob_id type size <&3 &&
2452 echo "$blob_id $type $size" >response &&
2453 head_c $size >blob <&3 &&
2457 commit refs/heads/copied
2458 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2460 copy big file as file3
2468 git fast-import --cat-blob-fd=3 3>blobs &&
2469 git show copied:file3 >actual &&
2470 test_cmp expect.response response &&
2474 test_expect_success PIPE
'R: print blob mid-commit' '
2476 echo "A blob from _before_ the commit." >expect &&
2485 A blob from _before_ the commit.
2487 commit refs/heads/temporary
2488 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2495 read blob_id type size <&3 &&
2496 head_c $size >actual <&3 &&
2501 git fast-import --cat-blob-fd=3 3>blobs &&
2502 test_cmp expect actual
2505 test_expect_success PIPE
'R: print staged blob within commit' '
2507 echo "A blob from _within_ the commit." >expect &&
2513 commit refs/heads/within
2514 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2520 A blob from _within_ the commit.
2525 echo "A blob from _within_ the commit." |
2526 git hash-object --stdin
2528 echo "cat-blob $to_get" &&
2530 read blob_id type size <&3 &&
2531 head_c $size >actual <&3 &&
2536 git fast-import --cat-blob-fd=3 3>blobs &&
2537 test_cmp expect actual
2548 test_expect_success
'R: quiet option results in no stats being output' '
2549 cat input | git fast-import 2> output &&
2550 test_must_be_empty output
2553 test_expect_success
'R: feature done means terminating "done" is mandatory' '
2554 echo feature done | test_must_fail git fast-import &&
2555 test_must_fail git fast-import --done </dev/null
2558 test_expect_success
'R: terminating "done" with trailing gibberish is ok' '
2559 git fast-import <<-\EOF &&
2564 git fast-import <<-\EOF
2566 more trailing gibberish
2570 test_expect_success
'R: terminating "done" within commit' '
2571 cat >expect <<-\EOF &&
2573 :000000 100644 OBJID OBJID A hello.c
2574 :000000 100644 OBJID OBJID A hello2.c
2576 git fast-import <<-EOF &&
2577 commit refs/heads/done-ends
2578 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2580 Commit terminated by "done" command
2582 M 100644 inline hello.c
2589 git rev-list done-ends |
2590 git diff-tree -r --stdin --root --always |
2591 sed -e "s/$_x40/OBJID/g" >actual &&
2592 test_cmp expect actual
2596 option git non-existing-option
2599 test_expect_success
'R: die on unknown option' '
2600 test_must_fail git fast-import <input
2603 test_expect_success
'R: unknown commandline options are rejected' '\
2604 test_must_fail git fast-import --non-existing-option < /dev/null
2607 test_expect_success
'R: die on invalid option argument' '
2608 echo "option git active-branches=-5" |
2609 test_must_fail git fast-import &&
2610 echo "option git depth=" |
2611 test_must_fail git fast-import &&
2612 test_must_fail git fast-import --depth="5 elephants" </dev/null
2616 option non-existing-vcs non-existing-option
2619 test_expect_success
'R: ignore non-git options' '
2620 git fast-import <input
2624 ## R: very large blobs
2626 blobsize
=$
((2*1024*1024 + 53))
2627 test-genrandom bar
$blobsize >expect
2628 cat >input
<<INPUT_END
2629 commit refs/heads/big-file
2630 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2639 cat >>input
<<INPUT_END
2646 test_expect_success
'R: blob bigger than threshold' '
2647 test_create_repo R &&
2648 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2651 test_expect_success
'R: verify created pack' '
2654 verify_packs -v > ../verify
2658 test_expect_success
'R: verify written objects' '
2659 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2660 test_cmp_bin expect actual &&
2661 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2662 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2666 test_expect_success
'R: blob appears only once' '
2667 n=$(grep $a verify | wc -l) &&
2675 # Make sure missing spaces and EOLs after mark references
2684 # commit marks: 301, 302, 303, 304
2685 # blob marks: 403, 404, resp.
2688 # The error message when a space is missing not at the
2689 # end of the line is:
2691 # Missing space after ..
2693 # or when extra characters come after the mark at the end
2698 # or when the dataref is neither "inline " or a known SHA1,
2700 # Invalid dataref ..
2704 cat >input
<<INPUT_END
2707 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2711 M 100644 inline hello.c
2718 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2723 M 100644 inline hello.c
2741 test_expect_success
'S: initialize for S tests' '
2742 git fast-import --export-marks=marks <input
2746 # filemodify, three datarefs
2748 test_expect_success
'S: filemodify with garbage after mark must fail' '
2749 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2751 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2755 M 100644 :403x hello.c
2758 test_i18ngrep "space after mark" err
2761 # inline is misspelled; fast-import thinks it is some unknown dataref
2762 test_expect_success
'S: filemodify with garbage after inline must fail' '
2763 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2765 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2769 M 100644 inlineX hello.c
2775 test_i18ngrep "nvalid dataref" err
2778 test_expect_success
'S: filemodify with garbage after sha1 must fail' '
2779 sha1=$(grep :403 marks | cut -d\ -f2) &&
2780 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2782 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2786 M 100644 ${sha1}x hello.c
2789 test_i18ngrep "space after SHA1" err
2793 # notemodify, three ways to say dataref
2795 test_expect_success
'S: notemodify with garabge after mark 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 markref
2805 test_i18ngrep "space after mark" err
2808 test_expect_success
'S: notemodify with garbage after inline dataref must fail' '
2809 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2811 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2813 commit S note dataref inline
2821 test_i18ngrep "nvalid dataref" err
2824 test_expect_success
'S: notemodify with garbage after sha1 dataref must fail' '
2825 sha1=$(grep :202 marks | cut -d\ -f2) &&
2826 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2828 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2830 commit S note dataref sha1
2835 test_i18ngrep "space after SHA1" err
2839 # notemodify, mark in commit-ish
2841 test_expect_success
'S: notemodify with garbage after mark commit-ish must fail' '
2842 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2843 commit refs/heads/Snotes
2844 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2846 commit S note commit-ish
2851 test_i18ngrep "after mark" err
2857 test_expect_success
'S: from with garbage after mark must fail' '
2859 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2860 commit refs/heads/S2
2862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2867 M 100644 :403 hello.c
2871 # go create the commit, need it for merge test
2872 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2873 commit refs/heads/S2
2875 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2880 M 100644 :403 hello.c
2883 # now evaluate the error
2885 test_i18ngrep "after mark" err
2892 test_expect_success
'S: merge with garbage after mark must fail' '
2893 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2896 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2902 M 100644 :403 hello.c
2905 test_i18ngrep "after mark" err
2911 test_expect_success
'S: tag with garbage after mark must fail' '
2912 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2915 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2921 test_i18ngrep "after mark" err
2927 test_expect_success
'S: cat-blob with garbage after mark must fail' '
2928 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2932 test_i18ngrep "after mark" err
2938 test_expect_success
'S: ls with garbage after mark must fail' '
2939 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2943 test_i18ngrep "space after mark" err
2946 test_expect_success
'S: ls with garbage after sha1 must fail' '
2947 sha1=$(grep :302 marks | cut -d\ -f2) &&
2948 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2952 test_i18ngrep "space after tree-ish" err
2958 # Setup is carried over from series S.
2960 test_expect_success
'T: ls root tree' '
2961 sed -e "s/Z\$//" >expect <<-EOF &&
2962 040000 tree $(git rev-parse S^{tree}) Z
2964 sha1=$(git rev-parse --verify S) &&
2965 git fast-import --import-marks=marks <<-EOF >actual &&
2968 test_cmp expect actual
2971 test_expect_success
'T: delete branch' '
2972 git branch to-delete &&
2973 git fast-import <<-EOF &&
2974 reset refs/heads/to-delete
2975 from 0000000000000000000000000000000000000000
2977 test_must_fail git rev-parse --verify refs/heads/to-delete
2980 test_expect_success
'T: empty reset doesnt delete branch' '
2981 git branch not-to-delete &&
2982 git fast-import <<-EOF &&
2983 reset refs/heads/not-to-delete
2986 git rev-parse --verify refs/heads/not-to-delete
2990 ### series U (filedelete)
2993 cat >input
<<INPUT_END
2995 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2999 M 100644 inline hello.c
3003 M 100644 inline good/night.txt
3007 M 100644 inline good/bye.txt
3014 test_expect_success
'U: initialize for U tests' '
3015 git fast-import <input
3018 cat >input
<<INPUT_END
3020 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3022 delete good/night.txt
3029 test_expect_success
'U: filedelete file succeeds' '
3030 git fast-import <input
3034 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3037 git diff-tree
-M -r U^
1 U
>actual
3039 test_expect_success
'U: validate file delete result' '
3040 compare_diff_raw expect actual
3043 cat >input
<<INPUT_END
3045 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3054 test_expect_success
'U: filedelete directory succeeds' '
3055 git fast-import <input
3059 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3062 git diff-tree
-M -r U^
1 U
>actual
3064 test_expect_success
'U: validate directory delete result' '
3065 compare_diff_raw expect actual
3068 cat >input
<<INPUT_END
3070 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3079 test_expect_success
'U: filedelete root succeeds' '
3080 git fast-import <input
3084 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3087 git diff-tree
-M -r U^
1 U
>actual
3089 test_expect_success
'U: validate root delete result' '
3090 compare_diff_raw expect actual