3 # Copyright (c) 2007 Shawn Pearce
6 test_description='test git fast-import utility'
8 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
10 # Print $1 bytes from stdin to stdout.
12 # This could be written as "head -c $1", but IRIX "head" does not
13 # support the -c option.
19 my $nread = sysread(STDIN, $s, $len);
20 die "cannot read: $!" unless defined($nread);
28 for p in .git/objects/pack/*.pack
30 git verify-pack "$@" "$p" || return
44 file5_data='an inline file.
45 we should see it later.'
58 test_expect_success 'empty stream succeeds' '
59 git fast-import </dev/null
62 cat >input <<INPUT_END
79 commit refs/heads/master
81 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
93 An annotated tag without a tagger
99 An annotated tag that annotates a blob.
103 test_expect_success 'A: create pack from stdin' '
104 git fast-import --export-marks=marks.out <input &&
105 git whatchanged master
108 test_expect_success 'A: verify pack' '
113 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
114 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
118 test_expect_success 'A: verify commit' '
119 git cat-file commit master | sed 1d >actual &&
120 test_cmp expect actual
128 test_expect_success 'A: verify tree' '
129 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
130 test_cmp expect actual
133 echo "$file2_data" >expect
134 test_expect_success 'A: verify file2' '
135 git cat-file blob master:file2 >actual && test_cmp expect actual
138 echo "$file3_data" >expect
139 test_expect_success 'A: verify file3' '
140 git cat-file blob master:file3 >actual && test_cmp expect actual
143 printf "$file4_data" >expect
144 test_expect_success 'A: verify file4' '
145 git cat-file blob master:file4 >actual && test_cmp expect actual
149 object $(git rev-parse refs/heads/master)
153 An annotated tag without a tagger
155 test_expect_success 'A: verify tag/series-A' '
156 git cat-file tag tags/series-A >actual &&
157 test_cmp expect actual
161 object $(git rev-parse refs/heads/master:file3)
165 An annotated tag that annotates a blob.
167 test_expect_success 'A: verify tag/series-A-blob' '
168 git cat-file tag tags/series-A-blob >actual &&
169 test_cmp expect actual
173 :2 `git rev-parse --verify master:file2`
174 :3 `git rev-parse --verify master:file3`
175 :4 `git rev-parse --verify master:file4`
176 :5 `git rev-parse --verify master^0`
178 test_expect_success 'A: verify marks output' '
179 test_cmp expect marks.out
182 test_expect_success 'A: verify marks import' '
184 --import-marks=marks.out \
185 --export-marks=marks.new \
187 test_cmp expect marks.new
191 new_blob=$(echo testing | git hash-object --stdin)
192 cat >input <<INPUT_END
194 from $(git rev-parse refs/heads/master:file3)
205 commit refs/heads/new_blob
209 #pretend we got sha1 from fast-import
220 object $(git rev-parse refs/heads/master:file3)
232 test_expect_success 'A: tag blob by sha1' '
233 git fast-import <input &&
234 git cat-file tag tags/series-A-blob-2 >actual &&
235 git cat-file tag tags/series-A-blob-3 >>actual &&
236 test_cmp expect actual
240 cat >input <<INPUT_END
241 commit refs/heads/verify--import-marks
242 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
248 M 755 :2 copy-of-file2
251 test_expect_success 'A: verify marks import does not crash' '
252 git fast-import --import-marks=marks.out <input &&
253 git whatchanged verify--import-marks
256 test_expect_success 'A: verify pack' '
261 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
263 git diff-tree -M -r master verify--import-marks >actual
264 test_expect_success 'A: verify diff' '
265 compare_diff_raw expect actual &&
266 test `git rev-parse --verify master:file2` \
267 = `git rev-parse --verify verify--import-marks:copy-of-file2`
271 mt=$(git hash-object --stdin < /dev/null)
276 cat >input.commit <<EOF
277 commit refs/heads/verify--dump-marks
278 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
280 test the sparse array dumping routines with exponentially growing marks
288 while test "$i" -lt 27; do
289 cat >>input.blob <<EOF
300 echo "M 100644 :$l l$i" >>input.commit
301 echo "M 100644 :$m m$i" >>input.commit
302 echo "M 100644 :$n n$i" >>input.commit
304 echo ":$l $mt" >>marks.exp
305 echo ":$m $mt" >>marks.exp
306 echo ":$n $mt" >>marks.exp
308 printf "100644 blob $mt\tl$i\n" >>tree.exp
309 printf "100644 blob $mt\tm$i\n" >>tree.exp
310 printf "100644 blob $mt\tn$i\n" >>tree.exp
319 sort tree.exp > tree.exp_s
321 test_expect_success 'A: export marks with large values' '
322 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
323 git ls-tree refs/heads/verify--dump-marks >tree.out &&
324 test_cmp tree.exp_s tree.out &&
325 test_cmp marks.exp marks.large
333 cat >input <<INPUT_END
334 commit refs/heads/branch
336 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
341 from refs/heads/master
342 M 755 0000000000000000000000000000000000000001 zero1
345 test_expect_success 'B: fail on invalid blob sha1' '
346 test_must_fail git fast-import <input
348 rm -f .git/objects/pack_* .git/objects/index_*
350 cat >input <<INPUT_END
352 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
357 from refs/heads/master
360 test_expect_success 'B: accept branch name "TEMP_TAG"' '
361 git fast-import <input &&
362 test -f .git/TEMP_TAG &&
363 test `git rev-parse master` = `git rev-parse TEMP_TAG^`
367 git gc 2>/dev/null >/dev/null
368 git prune 2>/dev/null >/dev/null
370 cat >input <<INPUT_END
371 commit refs/heads/empty-committer-1
372 committer <> $GIT_COMMITTER_DATE
377 test_expect_success 'B: accept empty committer' '
378 git fast-import <input &&
383 git update-ref -d refs/heads/empty-committer-1 || true
385 git gc 2>/dev/null >/dev/null
386 git prune 2>/dev/null >/dev/null
388 cat >input <<INPUT_END
389 commit refs/heads/empty-committer-2
390 committer <a@b.com> $GIT_COMMITTER_DATE
395 test_expect_success 'B: accept and fixup committer with no name' '
396 git fast-import <input &&
401 git update-ref -d refs/heads/empty-committer-2 || true
403 git gc 2>/dev/null >/dev/null
404 git prune 2>/dev/null >/dev/null
406 cat >input <<INPUT_END
407 commit refs/heads/invalid-committer
408 committer Name email> $GIT_COMMITTER_DATE
413 test_expect_success 'B: fail on invalid committer (1)' '
414 test_must_fail git fast-import <input
416 git update-ref -d refs/heads/invalid-committer || true
418 cat >input <<INPUT_END
419 commit refs/heads/invalid-committer
420 committer Name <e<mail> $GIT_COMMITTER_DATE
425 test_expect_success 'B: fail on invalid committer (2)' '
426 test_must_fail git fast-import <input
428 git update-ref -d refs/heads/invalid-committer || true
430 cat >input <<INPUT_END
431 commit refs/heads/invalid-committer
432 committer Name <email>> $GIT_COMMITTER_DATE
437 test_expect_success 'B: fail on invalid committer (3)' '
438 test_must_fail git fast-import <input
440 git update-ref -d refs/heads/invalid-committer || true
442 cat >input <<INPUT_END
443 commit refs/heads/invalid-committer
444 committer Name <email $GIT_COMMITTER_DATE
449 test_expect_success 'B: fail on invalid committer (4)' '
450 test_must_fail git fast-import <input
452 git update-ref -d refs/heads/invalid-committer || true
454 cat >input <<INPUT_END
455 commit refs/heads/invalid-committer
456 committer Name<email> $GIT_COMMITTER_DATE
461 test_expect_success 'B: fail on invalid committer (5)' '
462 test_must_fail git fast-import <input
464 git update-ref -d refs/heads/invalid-committer || true
470 newf=`echo hi newf | git hash-object -w --stdin`
471 oldf=`git rev-parse --verify master:file2`
473 cat >input <<INPUT_END
474 commit refs/heads/branch
475 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
480 from refs/heads/master
481 M 644 $oldf file2/oldf
482 M 755 $newf file2/newf
486 test_expect_success 'C: incremental import create pack from stdin' '
487 git fast-import <input &&
488 git whatchanged branch
491 test_expect_success 'C: verify pack' '
495 test_expect_success 'C: validate reuse existing blob' '
496 test $newf = `git rev-parse --verify branch:file2/newf` &&
497 test $oldf = `git rev-parse --verify branch:file2/oldf`
501 parent `git rev-parse --verify master^0`
502 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
503 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
507 test_expect_success 'C: verify commit' '
508 git cat-file commit branch | sed 1d >actual &&
509 test_cmp expect actual
513 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
514 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
515 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
517 git diff-tree -M -r master branch >actual
518 test_expect_success 'C: validate rename result' '
519 compare_diff_raw expect actual
527 cat >input <<INPUT_END
528 commit refs/heads/branch
529 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
534 from refs/heads/branch^0
535 M 644 inline newdir/interesting
540 M 755 inline newdir/exec.sh
546 test_expect_success 'D: inline data in commit' '
547 git fast-import <input &&
548 git whatchanged branch
551 test_expect_success 'D: verify pack' '
556 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
557 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
559 git diff-tree -M -r branch^ branch >actual
560 test_expect_success 'D: validate new files added' '
561 compare_diff_raw expect actual
564 echo "$file5_data" >expect
565 test_expect_success 'D: verify file5' '
566 git cat-file blob branch:newdir/interesting >actual &&
567 test_cmp expect actual
570 echo "$file6_data" >expect
571 test_expect_success 'D: verify file6' '
572 git cat-file blob branch:newdir/exec.sh >actual &&
573 test_cmp expect actual
580 cat >input <<INPUT_END
581 commit refs/heads/branch
582 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
583 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
588 from refs/heads/branch^0
591 test_expect_success 'E: rfc2822 date, --date-format=raw' '
592 test_must_fail git fast-import --date-format=raw <input
594 test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
595 git fast-import --date-format=rfc2822 <input
598 test_expect_success 'E: verify pack' '
603 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
604 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
608 test_expect_success 'E: verify commit' '
609 git cat-file commit branch | sed 1,2d >actual &&
610 test_cmp expect actual
617 old_branch=`git rev-parse --verify branch^0`
619 cat >input <<INPUT_END
620 commit refs/heads/branch
621 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
623 losing things already?
626 from refs/heads/branch~1
628 reset refs/heads/other
629 from refs/heads/branch
632 test_expect_success 'F: non-fast-forward update skips' '
633 test_must_fail git fast-import <input &&
634 # branch must remain unaffected
635 test $old_branch = `git rev-parse --verify branch^0`
638 test_expect_success 'F: verify pack' '
643 tree `git rev-parse branch~1^{tree}`
644 parent `git rev-parse branch~1`
645 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
646 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
648 losing things already?
650 test_expect_success 'F: verify other commit' '
651 git cat-file commit other >actual &&
652 test_cmp expect actual
659 old_branch=`git rev-parse --verify branch^0`
661 cat >input <<INPUT_END
662 commit refs/heads/branch
663 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
665 losing things already?
668 from refs/heads/branch~1
671 test_expect_success 'G: non-fast-forward update forced' '
672 git fast-import --force <input
675 test_expect_success 'G: verify pack' '
679 test_expect_success 'G: branch changed, but logged' '
680 test $old_branch != `git rev-parse --verify branch^0` &&
681 test $old_branch = `git rev-parse --verify branch@{1}`
689 cat >input <<INPUT_END
691 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
696 from refs/heads/branch^0
697 M 644 inline i-will-die
699 this file will never exist.
703 M 644 inline h/e/l/lo
709 test_expect_success 'H: deletall, add 1' '
710 git fast-import <input &&
714 test_expect_success 'H: verify pack' '
719 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
720 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
721 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
722 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
723 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
725 git diff-tree -M -r H^ H >actual
726 test_expect_success 'H: validate old files removed, new files added' '
727 compare_diff_raw expect actual
730 echo "$file5_data" >expect
731 test_expect_success 'H: verify file' '
732 git cat-file blob H:h/e/l/lo >actual &&
733 test_cmp expect actual
740 cat >input <<INPUT_END
741 commit refs/heads/export-boundary
742 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
744 we have a border. its only 40 characters wide.
747 from refs/heads/branch
750 test_expect_success 'I: export-pack-edges' '
751 git fast-import --export-pack-edges=edges.list <input
755 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
757 test_expect_success 'I: verify edge list' '
758 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
759 test_cmp expect actual
766 cat >input <<INPUT_END
768 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
773 from refs/heads/branch
778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
784 test_expect_success 'J: reset existing branch creates empty commit' '
785 git fast-import <input
787 test_expect_success 'J: branch has 1 commit, empty tree' '
788 test 1 = `git rev-list J | wc -l` &&
789 test 0 = `git ls-tree J | wc -l`
792 cat >input <<INPUT_END
798 Tag branch that was reset.
801 test_expect_success 'J: tag must fail on empty branch' '
802 test_must_fail git fast-import <input
808 cat >input <<INPUT_END
810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
815 from refs/heads/branch
818 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
823 from refs/heads/branch^1
826 test_expect_success 'K: reinit branch with from' '
827 git fast-import <input
829 test_expect_success 'K: verify K^1 = branch^1' '
830 test `git rev-parse --verify branch^1` \
831 = `git rev-parse --verify K^1`
838 cat >input <<INPUT_END
852 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
872 cat >expect <<EXPECT_END
873 :100644 100644 4268632... 55d3a52... M b.
874 :040000 040000 0ae5cac... 443c768... M b
875 :100644 100644 4268632... 55d3a52... M ba
878 test_expect_success 'L: verify internal tree sorting' '
879 git fast-import <input &&
880 git diff-tree --abbrev --raw L^ L >output &&
881 test_cmp expect output
884 cat >input <<INPUT_END
892 committer C O Mitter <committer@example.com> 1112912473 -0700
901 committer C O Mitter <committer@example.com> 1112912473 -0700
915 test_expect_success 'L: nested tree copy does not corrupt deltas' '
916 git fast-import <input &&
917 git ls-tree L2 g/b/ >tmp &&
918 cat tmp | cut -f 2 >actual &&
919 test_cmp expect actual &&
920 git fsck `git rev-parse L2`
923 git update-ref -d refs/heads/L2
930 cat >input <<INPUT_END
932 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
937 from refs/heads/branch^0
938 R file2/newf file2/n.e.w.f
943 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
945 test_expect_success 'M: rename file in same subdirectory' '
946 git fast-import <input &&
947 git diff-tree -M -r M1^ M1 >actual &&
948 compare_diff_raw expect actual
951 cat >input <<INPUT_END
953 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
958 from refs/heads/branch^0
959 R file2/newf i/am/new/to/you
964 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
966 test_expect_success 'M: rename file to new subdirectory' '
967 git fast-import <input &&
968 git diff-tree -M -r M2^ M2 >actual &&
969 compare_diff_raw expect actual
972 cat >input <<INPUT_END
974 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
985 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
987 test_expect_success 'M: rename subdirectory to new subdirectory' '
988 git fast-import <input &&
989 git diff-tree -M -r M3^ M3 >actual &&
990 compare_diff_raw expect actual
993 cat >input <<INPUT_END
995 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1000 from refs/heads/M2^0
1006 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1007 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1008 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1009 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1010 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1012 test_expect_success 'M: rename root to subdirectory' '
1013 git fast-import <input &&
1014 git diff-tree -M -r M4^ M4 >actual &&
1016 compare_diff_raw expect actual
1024 cat >input <<INPUT_END
1025 commit refs/heads/N1
1026 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1031 from refs/heads/branch^0
1032 C file2/newf file2/n.e.w.f
1037 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1039 test_expect_success 'N: copy file in same subdirectory' '
1040 git fast-import <input &&
1041 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1042 compare_diff_raw expect actual
1045 cat >input <<INPUT_END
1046 commit refs/heads/N2
1047 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1049 clean directory copy
1052 from refs/heads/branch^0
1055 commit refs/heads/N2
1056 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1058 modify directory copy
1061 M 644 inline file3/file5
1069 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1070 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1071 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1073 test_expect_success 'N: copy then modify subdirectory' '
1074 git fast-import <input &&
1075 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1076 compare_diff_raw expect actual
1079 cat >input <<INPUT_END
1080 commit refs/heads/N3
1081 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1083 dirty directory copy
1086 from refs/heads/branch^0
1087 M 644 inline file2/file5
1097 test_expect_success 'N: copy dirty subdirectory' '
1098 git fast-import <input &&
1099 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`
1102 test_expect_success 'N: copy directory by id' '
1103 cat >expect <<-\EOF &&
1104 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1105 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1107 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1108 cat >input <<-INPUT_END &&
1109 commit refs/heads/N4
1110 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1115 from refs/heads/branch^0
1116 M 040000 $subdir file3
1118 git fast-import <input &&
1119 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1120 compare_diff_raw expect actual
1123 test_expect_success PIPE 'N: read and copy directory' '
1124 cat >expect <<-\EOF &&
1125 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1126 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1128 git update-ref -d refs/heads/N4 &&
1134 commit refs/heads/N4
1135 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1137 copy by tree hash, part 2
1140 from refs/heads/branch^0
1143 read mode type tree filename &&
1144 echo "M 040000 $tree file3"
1146 git fast-import --cat-blob-fd=3 3>backflow &&
1147 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1148 compare_diff_raw expect actual
1151 test_expect_success PIPE 'N: empty directory reads as missing' '
1152 cat <<-\EOF >expect &&
1154 :000000 100644 OBJNAME OBJNAME A unrelated
1156 echo "missing src" >expect.response &&
1157 git update-ref -d refs/heads/read-empty &&
1163 commit refs/heads/read-empty
1164 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1166 read "empty" (missing) directory
1169 M 100644 inline src/greeting
1173 C src/greeting dst1/non-greeting
1174 C src/greeting unrelated
1175 # leave behind "empty" src directory
1180 printf "%s\n" "$line" >response &&
1186 git fast-import --cat-blob-fd=3 3>backflow &&
1187 test_cmp expect.response response &&
1188 git rev-list read-empty |
1189 git diff-tree -r --root --stdin |
1190 sed "s/$_x40/OBJNAME/g" >actual &&
1191 test_cmp expect actual
1194 test_expect_success 'N: copy root directory by tree hash' '
1195 cat >expect <<-\EOF &&
1196 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1197 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1199 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1200 cat >input <<-INPUT_END &&
1201 commit refs/heads/N6
1202 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1204 copy root directory by tree hash
1207 from refs/heads/branch^0
1210 git fast-import <input &&
1211 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1212 compare_diff_raw expect actual
1215 test_expect_success 'N: copy root by path' '
1216 cat >expect <<-\EOF &&
1217 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1218 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1219 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1220 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1221 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1223 cat >input <<-INPUT_END &&
1224 commit refs/heads/N-copy-root-path
1225 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1227 copy root directory by (empty) path
1230 from refs/heads/branch^0
1233 git fast-import <input &&
1234 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1235 compare_diff_raw expect actual
1238 test_expect_success 'N: delete directory by copying' '
1239 cat >expect <<-\EOF &&
1241 :100644 000000 OBJID OBJID D foo/bar/qux
1243 :000000 100644 OBJID OBJID A foo/bar/baz
1244 :000000 100644 OBJID OBJID A foo/bar/qux
1246 empty_tree=$(git mktree </dev/null) &&
1247 cat >input <<-INPUT_END &&
1248 commit refs/heads/N-delete
1249 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1251 collect data to be deleted
1255 M 100644 inline foo/bar/baz
1259 C "foo/bar/baz" "foo/bar/qux"
1260 C "foo/bar/baz" "foo/bar/quux/1"
1261 C "foo/bar/baz" "foo/bar/quuux"
1262 M 040000 $empty_tree foo/bar/quux
1263 M 040000 $empty_tree foo/bar/quuux
1265 commit refs/heads/N-delete
1266 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1271 M 040000 $empty_tree foo/bar/qux
1273 git fast-import <input &&
1274 git rev-list N-delete |
1275 git diff-tree -r --stdin --root --always |
1276 sed -e "s/$_x40/OBJID/g" >actual &&
1277 test_cmp expect actual
1280 test_expect_success 'N: modify copied tree' '
1281 cat >expect <<-\EOF &&
1282 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1283 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1284 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1286 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1287 cat >input <<-INPUT_END &&
1288 commit refs/heads/N5
1289 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1294 from refs/heads/branch^0
1295 M 040000 $subdir file3
1297 commit refs/heads/N5
1298 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1300 modify directory copy
1303 M 644 inline file3/file5
1308 git fast-import <input &&
1309 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1310 compare_diff_raw expect actual
1313 test_expect_success 'N: reject foo/ syntax' '
1314 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1315 test_must_fail git fast-import <<-INPUT_END
1316 commit refs/heads/N5B
1317 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1319 copy with invalid syntax
1322 from refs/heads/branch^0
1323 M 040000 $subdir file3/
1327 test_expect_success 'N: reject foo/ syntax in copy source' '
1328 test_must_fail git fast-import <<-INPUT_END
1329 commit refs/heads/N5C
1330 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1332 copy with invalid syntax
1335 from refs/heads/branch^0
1340 test_expect_success 'N: reject foo/ syntax in rename source' '
1341 test_must_fail git fast-import <<-INPUT_END
1342 commit refs/heads/N5D
1343 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1345 rename with invalid syntax
1348 from refs/heads/branch^0
1353 test_expect_success 'N: reject foo/ syntax in ls argument' '
1354 test_must_fail git fast-import <<-INPUT_END
1355 commit refs/heads/N5E
1356 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1358 copy with invalid syntax
1361 from refs/heads/branch^0
1366 test_expect_success 'N: copy to root by id and modify' '
1367 echo "hello, world" >expect.foo &&
1368 echo hello >expect.bar &&
1369 git fast-import <<-SETUP_END &&
1370 commit refs/heads/N7
1371 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1377 M 644 inline foo/bar
1383 tree=$(git rev-parse --verify N7:) &&
1384 git fast-import <<-INPUT_END &&
1385 commit refs/heads/N8
1386 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1388 copy to root by id and modify
1392 M 644 inline foo/foo
1397 git show N8:foo/foo >actual.foo &&
1398 git show N8:foo/bar >actual.bar &&
1399 test_cmp expect.foo actual.foo &&
1400 test_cmp expect.bar actual.bar
1403 test_expect_success 'N: extract subtree' '
1404 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1405 cat >input <<-INPUT_END &&
1406 commit refs/heads/N9
1407 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1409 extract subtree branch:newdir
1415 git fast-import <input &&
1416 git diff --exit-code branch:newdir N9
1419 test_expect_success 'N: modify subtree, extract it, and modify again' '
1420 echo hello >expect.baz &&
1421 echo hello, world >expect.qux &&
1422 git fast-import <<-SETUP_END &&
1423 commit refs/heads/N10
1424 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1430 M 644 inline foo/bar/baz
1436 tree=$(git rev-parse --verify N10:) &&
1437 git fast-import <<-INPUT_END &&
1438 commit refs/heads/N11
1439 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1441 copy to root by id and modify
1445 M 100644 inline foo/bar/qux
1450 C "bar/qux" "bar/quux"
1452 git show N11:bar/baz >actual.baz &&
1453 git show N11:bar/qux >actual.qux &&
1454 git show N11:bar/quux >actual.quux &&
1455 test_cmp expect.baz actual.baz &&
1456 test_cmp expect.qux actual.qux &&
1457 test_cmp expect.qux actual.quux'
1463 cat >input <<INPUT_END
1465 commit refs/heads/O1
1466 # -- ignore all of this text
1467 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1468 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1470 dirty directory copy
1473 # don't forget the import blank line!
1475 # yes, we started from our usual base of branch^0.
1477 from refs/heads/branch^0
1478 # and we need to reuse file2/file5 from N3 above.
1479 M 644 inline file2/file5
1480 # otherwise the tree will be different
1485 # don't forget to copy file2 to file3
1488 # or to delete file5 from file2.
1494 test_expect_success 'O: comments are all skipped' '
1495 git fast-import <input &&
1496 test `git rev-parse N3` = `git rev-parse O1`
1499 cat >input <<INPUT_END
1500 commit refs/heads/O2
1501 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1503 dirty directory copy
1505 from refs/heads/branch^0
1506 M 644 inline file2/file5
1515 test_expect_success 'O: blank lines not necessary after data commands' '
1516 git fast-import <input &&
1517 test `git rev-parse N3` = `git rev-parse O2`
1520 test_expect_success 'O: repack before next test' '
1524 cat >input <<INPUT_END
1525 commit refs/heads/O3
1526 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1530 commit refs/heads/O3
1531 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1536 commit refs/heads/O3
1538 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1543 commit refs/heads/O3
1544 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1548 reset refs/tags/O3-2nd
1550 reset refs/tags/O3-3rd
1554 cat >expect <<INPUT_END
1560 test_expect_success 'O: blank lines not necessary after other commands' '
1561 git fast-import <input &&
1562 test 8 = `find .git/objects/pack -type f | wc -l` &&
1563 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1564 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1565 test_cmp expect actual
1568 cat >input <<INPUT_END
1569 commit refs/heads/O4
1570 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1574 commit refs/heads/O4
1575 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1579 progress Two commits down, 2 to go!
1580 commit refs/heads/O4
1581 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1585 progress Three commits down, 1 to go!
1586 commit refs/heads/O4
1587 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1593 test_expect_success 'O: progress outputs as requested by input' '
1594 git fast-import <input >actual &&
1595 grep "progress " <input >expect &&
1596 test_cmp expect actual
1600 ### series P (gitlinks)
1603 cat >input <<INPUT_END
1609 reset refs/heads/sub
1610 commit refs/heads/sub
1612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1625 commit refs/heads/subuse1
1627 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1630 from refs/heads/master
1631 M 100644 :3 .gitmodules
1640 commit refs/heads/sub
1642 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1648 commit refs/heads/subuse1
1650 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1658 test_expect_success 'P: superproject & submodule mix' '
1659 git fast-import <input &&
1660 git checkout subuse1 &&
1661 rm -rf sub && mkdir sub && (cd sub &&
1663 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1664 git checkout master) &&
1665 git submodule init &&
1666 git submodule update
1669 SUBLAST=$(git rev-parse --verify sub)
1670 SUBPREV=$(git rev-parse --verify sub^)
1672 cat >input <<INPUT_END
1681 commit refs/heads/subuse2
1683 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1686 from refs/heads/master
1687 M 100644 :1 .gitmodules
1688 M 160000 $SUBPREV sub
1690 commit refs/heads/subuse2
1692 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1696 M 160000 $SUBLAST sub
1700 test_expect_success 'P: verbatim SHA gitlinks' '
1701 git branch -D sub &&
1702 git gc && git prune &&
1703 git fast-import <input &&
1704 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1708 cat >input <<INPUT_END
1709 commit refs/heads/subuse3
1711 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1716 from refs/heads/subuse2
1724 test_expect_success 'P: fail on inline gitlink' '
1725 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
1753 ### series Q (notes)
1756 note1_data="The first note for the first commit"
1757 note2_data="The first note for the second commit"
1758 note3_data="The first note for the third commit"
1759 note1b_data="The second note for the first commit"
1760 note1c_data="The third note for the first commit"
1761 note2b_data="The second note for the second commit"
1764 cat >input <<INPUT_END
1771 commit refs/heads/notes-test
1773 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1784 commit refs/heads/notes-test
1786 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1793 commit refs/heads/notes-test
1795 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1822 commit refs/notes/foobar
1824 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1836 commit refs/notes/foobar
1838 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1848 commit refs/notes/foobar2
1850 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1860 commit refs/notes/foobar
1862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1875 test_expect_success 'Q: commit notes' '
1876 git fast-import <input &&
1877 git whatchanged notes-test
1880 test_expect_success 'Q: verify pack' '
1884 commit1=$(git rev-parse notes-test~2)
1885 commit2=$(git rev-parse notes-test^)
1886 commit3=$(git rev-parse notes-test)
1889 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1890 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1894 test_expect_success 'Q: verify first commit' '
1895 git cat-file commit notes-test~2 | sed 1d >actual &&
1896 test_cmp expect actual
1901 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1902 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1906 test_expect_success 'Q: verify second commit' '
1907 git cat-file commit notes-test^ | sed 1d >actual &&
1908 test_cmp expect actual
1913 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1914 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1918 test_expect_success 'Q: verify third commit' '
1919 git cat-file commit notes-test | sed 1d >actual &&
1920 test_cmp expect actual
1924 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1925 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1929 test_expect_success 'Q: verify first notes commit' '
1930 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1931 test_cmp expect actual
1934 cat >expect.unsorted <<EOF
1935 100644 blob $commit1
1936 100644 blob $commit2
1937 100644 blob $commit3
1939 cat expect.unsorted | sort >expect
1940 test_expect_success '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
1945 echo "$note1_data" >expect
1946 test_expect_success 'Q: verify first note for first commit' '
1947 git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual
1950 echo "$note2_data" >expect
1951 test_expect_success 'Q: verify first note for second commit' '
1952 git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual
1955 echo "$note3_data" >expect
1956 test_expect_success 'Q: verify first note for third commit' '
1957 git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual
1961 parent `git rev-parse --verify refs/notes/foobar~2`
1962 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1963 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1967 test_expect_success 'Q: verify second notes commit' '
1968 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1969 test_cmp expect actual
1972 cat >expect.unsorted <<EOF
1973 100644 blob $commit1
1974 100644 blob $commit2
1975 100644 blob $commit3
1977 cat expect.unsorted | sort >expect
1978 test_expect_success '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
1983 echo "$note1b_data" >expect
1984 test_expect_success 'Q: verify second note for first commit' '
1985 git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual
1988 echo "$note2_data" >expect
1989 test_expect_success 'Q: verify first note for second commit' '
1990 git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual
1993 echo "$note3_data" >expect
1994 test_expect_success 'Q: verify first note for third commit' '
1995 git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual
1999 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2000 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2004 test_expect_success 'Q: verify third notes commit' '
2005 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2006 test_cmp expect actual
2009 cat >expect.unsorted <<EOF
2010 100644 blob $commit1
2012 cat expect.unsorted | sort >expect
2013 test_expect_success '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
2018 echo "$note1c_data" >expect
2019 test_expect_success 'Q: verify third note for first commit' '
2020 git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual
2024 parent `git rev-parse --verify refs/notes/foobar^`
2025 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2026 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2030 test_expect_success 'Q: verify fourth notes commit' '
2031 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2032 test_cmp expect actual
2035 cat >expect.unsorted <<EOF
2036 100644 blob $commit2
2038 cat expect.unsorted | sort >expect
2039 test_expect_success '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
2044 echo "$note2b_data" >expect
2045 test_expect_success 'Q: verify second note for second commit' '
2046 git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual
2052 commit refs/heads/note-Q0
2053 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2055 Note for an empty branch.
2058 N inline refs/heads/Q0
2063 test_expect_success 'Q: deny note on empty branch' '
2064 test_must_fail git fast-import <input
2067 ### series R (feature and option)
2071 feature no-such-feature-exists
2074 test_expect_success 'R: abort on unsupported feature' '
2075 test_must_fail git fast-import <input
2079 feature date-format=now
2082 test_expect_success 'R: supported feature is accepted' '
2083 git fast-import <input
2090 feature date-format=now
2093 test_expect_success 'R: abort on receiving feature after data command' '
2094 test_must_fail git fast-import <input
2098 feature import-marks=git.marks
2099 feature import-marks=git2.marks
2102 test_expect_success 'R: only one import-marks feature allowed per stream' '
2103 test_must_fail git fast-import <input
2107 feature export-marks=git.marks
2115 test_expect_success 'R: export-marks feature results in a marks file being created' '
2116 cat input | git fast-import &&
2120 test_expect_success 'R: export-marks options can be overridden by commandline options' '
2121 cat input | git fast-import --export-marks=other.marks &&
2125 test_expect_success 'R: catch typo in marks file name' '
2126 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2127 echo "feature import-marks=nonexistent.marks" |
2128 test_must_fail git fast-import
2131 test_expect_success 'R: import and output marks can be the same file' '
2133 blob=$(echo hi | git hash-object --stdin) &&
2134 cat >expect <<-EOF &&
2138 git fast-import --export-marks=io.marks <<-\EOF &&
2145 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2152 test_cmp expect io.marks
2155 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2157 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2166 test_expect_success 'R: --import-marks-if-exists' '
2168 blob=$(echo hi | git hash-object --stdin) &&
2169 echo ":1 $blob" >expect &&
2170 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2177 test_cmp expect io.marks
2180 test_expect_success 'R: feature import-marks-if-exists' '
2184 git fast-import --export-marks=io.marks <<-\EOF &&
2185 feature import-marks-if-exists=not_io.marks
2187 test_cmp expect io.marks &&
2189 blob=$(echo hi | git hash-object --stdin) &&
2191 echo ":1 $blob" >io.marks &&
2192 echo ":1 $blob" >expect &&
2193 echo ":2 $blob" >>expect &&
2195 git fast-import --export-marks=io.marks <<-\EOF &&
2196 feature import-marks-if-exists=io.marks
2203 test_cmp expect io.marks &&
2205 echo ":3 $blob" >>expect &&
2207 git fast-import --import-marks=io.marks \
2208 --export-marks=io.marks <<-\EOF &&
2209 feature import-marks-if-exists=not_io.marks
2216 test_cmp expect io.marks &&
2220 git fast-import --import-marks-if-exists=not_io.marks \
2221 --export-marks=io.marks <<-\EOF &&
2222 feature import-marks-if-exists=io.marks
2224 test_cmp expect io.marks
2228 feature import-marks=marks.out
2229 feature export-marks=marks.new
2232 test_expect_success 'R: import to output marks works without any content' '
2233 cat input | git fast-import &&
2234 test_cmp marks.out marks.new
2238 feature import-marks=nonexistent.marks
2239 feature export-marks=marks.new
2242 test_expect_success '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
2249 feature import-marks=nonexistent.marks
2250 feature export-marks=combined.marks
2253 test_expect_success 'R: multiple --import-marks= should be honoured' '
2254 head -n2 marks.out > one.marks &&
2255 tail -n +3 marks.out > two.marks &&
2256 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2257 test_cmp marks.out combined.marks
2261 feature relative-marks
2262 feature import-marks=relative.in
2263 feature export-marks=relative.out
2266 test_expect_success 'R: feature relative-marks should be honoured' '
2267 mkdir -p .git/info/fast-import/ &&
2268 cp marks.new .git/info/fast-import/relative.in &&
2269 git fast-import <input &&
2270 test_cmp marks.new .git/info/fast-import/relative.out
2274 feature relative-marks
2275 feature import-marks=relative.in
2276 feature no-relative-marks
2277 feature export-marks=non-relative.out
2280 test_expect_success 'R: feature no-relative-marks should be honoured' '
2281 git fast-import <input &&
2282 test_cmp marks.new non-relative.out
2285 test_expect_success 'R: feature ls supported' '
2290 test_expect_success 'R: feature cat-blob supported' '
2291 echo "feature cat-blob" |
2295 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2296 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2299 test_expect_success !MINGW 'R: print old blob' '
2300 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2301 cat >expect <<-EOF &&
2306 echo "cat-blob $blob" |
2307 git fast-import --cat-blob-fd=6 6>actual &&
2308 test_cmp expect actual
2311 test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
2312 echo hello >greeting &&
2313 blob=$(git hash-object -w greeting) &&
2314 cat >expect <<-EOF &&
2319 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2322 test_cmp expect actual.3 &&
2323 test_cmp empty actual.1 &&
2324 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2325 option cat-blob-fd=3
2328 test_cmp empty actual.3 &&
2329 test_cmp expect actual.1
2332 test_expect_success !MINGW 'R: print mark for new blob' '
2333 echo "effluentish" | git hash-object --stdin >expect &&
2334 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2342 test_cmp expect actual
2345 test_expect_success !MINGW 'R: print new blob' '
2346 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2347 cat >expect <<-EOF &&
2352 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2360 test_cmp expect actual
2363 test_expect_success !MINGW 'R: print new blob by sha1' '
2364 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2365 cat >expect <<-EOF &&
2367 a new blob named by sha1
2370 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2373 a new blob named by sha1
2377 test_cmp expect actual
2380 test_expect_success 'setup: big file' '
2382 echo "the quick brown fox jumps over the lazy dog" >big &&
2385 cat big big big big >bigger &&
2386 cat bigger bigger bigger bigger >big ||
2392 test_expect_success 'R: print two blobs to stdout' '
2393 blob1=$(git hash-object big) &&
2394 blob1_len=$(wc -c <big) &&
2395 blob2=$(echo hello | git hash-object --stdin) &&
2397 echo ${blob1} blob $blob1_len &&
2407 cat <<-\END_PART1 &&
2424 git fast-import >actual &&
2425 test_cmp expect actual
2428 test_expect_success PIPE 'R: copy using cat-file' '
2429 expect_id=$(git hash-object big) &&
2430 expect_len=$(wc -c <big) &&
2431 echo $expect_id blob $expect_len >expect.response &&
2434 cat >frontend <<-\FRONTEND_END &&
2440 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2453 read blob_id type size <&3 &&
2454 echo "$blob_id $type $size" >response &&
2455 head_c $size >blob <&3 &&
2459 commit refs/heads/copied
2460 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2462 copy big file as file3
2470 git fast-import --cat-blob-fd=3 3>blobs &&
2471 git show copied:file3 >actual &&
2472 test_cmp expect.response response &&
2476 test_expect_success PIPE 'R: print blob mid-commit' '
2478 echo "A blob from _before_ the commit." >expect &&
2487 A blob from _before_ the commit.
2489 commit refs/heads/temporary
2490 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2497 read blob_id type size <&3 &&
2498 head_c $size >actual <&3 &&
2503 git fast-import --cat-blob-fd=3 3>blobs &&
2504 test_cmp expect actual
2507 test_expect_success PIPE 'R: print staged blob within commit' '
2509 echo "A blob from _within_ the commit." >expect &&
2515 commit refs/heads/within
2516 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2522 A blob from _within_ the commit.
2527 echo "A blob from _within_ the commit." |
2528 git hash-object --stdin
2530 echo "cat-blob $to_get" &&
2532 read blob_id type size <&3 &&
2533 head_c $size >actual <&3 &&
2538 git fast-import --cat-blob-fd=3 3>blobs &&
2539 test_cmp expect actual
2550 test_expect_success 'R: quiet option results in no stats being output' '
2551 cat input | git fast-import 2> output &&
2552 test_cmp empty output
2555 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2556 echo feature done | test_must_fail git fast-import &&
2557 test_must_fail git fast-import --done </dev/null
2560 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2561 git fast-import <<-\EOF &&
2566 git fast-import <<-\EOF
2568 more trailing gibberish
2572 test_expect_success 'R: terminating "done" within commit' '
2573 cat >expect <<-\EOF &&
2575 :000000 100644 OBJID OBJID A hello.c
2576 :000000 100644 OBJID OBJID A hello2.c
2578 git fast-import <<-EOF &&
2579 commit refs/heads/done-ends
2580 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2582 Commit terminated by "done" command
2584 M 100644 inline hello.c
2591 git rev-list done-ends |
2592 git diff-tree -r --stdin --root --always |
2593 sed -e "s/$_x40/OBJID/g" >actual &&
2594 test_cmp expect actual
2598 option git non-existing-option
2601 test_expect_success 'R: die on unknown option' '
2602 test_must_fail git fast-import <input
2605 test_expect_success 'R: unknown commandline options are rejected' '\
2606 test_must_fail git fast-import --non-existing-option < /dev/null
2609 test_expect_success 'R: die on invalid option argument' '
2610 echo "option git active-branches=-5" |
2611 test_must_fail git fast-import &&
2612 echo "option git depth=" |
2613 test_must_fail git fast-import &&
2614 test_must_fail git fast-import --depth="5 elephants" </dev/null
2618 option non-existing-vcs non-existing-option
2621 test_expect_success 'R: ignore non-git options' '
2622 git fast-import <input
2626 ## R: very large blobs
2628 blobsize=$((2*1024*1024 + 53))
2629 test-genrandom bar $blobsize >expect
2630 cat >input <<INPUT_END
2631 commit refs/heads/big-file
2632 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2641 cat >>input <<INPUT_END
2648 test_expect_success 'R: blob bigger than threshold' '
2649 test_create_repo R &&
2650 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2653 test_expect_success 'R: verify created pack' '
2656 verify_packs -v > ../verify
2660 test_expect_success 'R: verify written objects' '
2661 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2662 test_cmp_bin expect actual &&
2663 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2664 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2668 test_expect_success 'R: blob appears only once' '
2669 n=$(grep $a verify | wc -l) &&
2677 # Make sure missing spaces and EOLs after mark references
2686 # commit marks: 301, 302, 303, 304
2687 # blob marks: 403, 404, resp.
2690 # The error message when a space is missing not at the
2691 # end of the line is:
2693 # Missing space after ..
2695 # or when extra characters come after the mark at the end
2700 # or when the dataref is neither "inline " or a known SHA1,
2702 # Invalid dataref ..
2706 cat >input <<INPUT_END
2709 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2713 M 100644 inline hello.c
2720 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2725 M 100644 inline hello.c
2743 test_expect_success 'S: initialize for S tests' '
2744 git fast-import --export-marks=marks <input
2748 # filemodify, three datarefs
2750 test_expect_success 'S: filemodify with garbage after mark must fail' '
2751 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2753 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2757 M 100644 :403x hello.c
2760 test_i18ngrep "space after mark" err
2763 # inline is misspelled; fast-import thinks it is some unknown dataref
2764 test_expect_success 'S: filemodify with garbage after inline must fail' '
2765 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2767 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2771 M 100644 inlineX hello.c
2777 test_i18ngrep "nvalid dataref" err
2780 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2781 sha1=$(grep :403 marks | cut -d\ -f2) &&
2782 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2784 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2788 M 100644 ${sha1}x hello.c
2791 test_i18ngrep "space after SHA1" err
2795 # notemodify, three ways to say dataref
2797 test_expect_success 'S: notemodify with garabge after mark dataref must fail' '
2798 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2800 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2802 commit S note dataref markref
2807 test_i18ngrep "space after mark" err
2810 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2811 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2813 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2815 commit S note dataref inline
2823 test_i18ngrep "nvalid dataref" err
2826 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2827 sha1=$(grep :202 marks | cut -d\ -f2) &&
2828 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2830 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2832 commit S note dataref sha1
2837 test_i18ngrep "space after SHA1" err
2841 # notemodify, mark in commit-ish
2843 test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
2844 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2845 commit refs/heads/Snotes
2846 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2848 commit S note commit-ish
2853 test_i18ngrep "after mark" err
2859 test_expect_success 'S: from with garbage after mark must fail' '
2861 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2862 commit refs/heads/S2
2864 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2869 M 100644 :403 hello.c
2873 # go create the commit, need it for merge test
2874 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2875 commit refs/heads/S2
2877 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2882 M 100644 :403 hello.c
2885 # now evaluate the error
2887 test_i18ngrep "after mark" err
2894 test_expect_success 'S: merge with garbage after mark must fail' '
2895 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2898 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2904 M 100644 :403 hello.c
2907 test_i18ngrep "after mark" err
2913 test_expect_success 'S: tag with garbage after mark must fail' '
2914 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2917 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2923 test_i18ngrep "after mark" err
2929 test_expect_success 'S: cat-blob with garbage after mark must fail' '
2930 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2934 test_i18ngrep "after mark" err
2940 test_expect_success 'S: ls with garbage after mark must fail' '
2941 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2945 test_i18ngrep "space after mark" err
2948 test_expect_success 'S: ls with garbage after sha1 must fail' '
2949 sha1=$(grep :302 marks | cut -d\ -f2) &&
2950 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2954 test_i18ngrep "space after tree-ish" err
2960 # Setup is carried over from series S.
2962 test_expect_success 'T: ls root tree' '
2963 sed -e "s/Z\$//" >expect <<-EOF &&
2964 040000 tree $(git rev-parse S^{tree}) Z
2966 sha1=$(git rev-parse --verify S) &&
2967 git fast-import --import-marks=marks <<-EOF >actual &&
2970 test_cmp expect actual
2973 test_expect_success 'T: delete branch' '
2974 git branch to-delete &&
2975 git fast-import <<-EOF &&
2976 reset refs/heads/to-delete
2977 from 0000000000000000000000000000000000000000
2979 test_must_fail git rev-parse --verify refs/heads/to-delete
2982 test_expect_success 'T: empty reset doesnt delete branch' '
2983 git branch not-to-delete &&
2984 git fast-import <<-EOF &&
2985 reset refs/heads/not-to-delete
2988 git rev-parse --verify refs/heads/not-to-delete
2992 ### series U (filedelete)
2995 cat >input <<INPUT_END
2997 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3001 M 100644 inline hello.c
3005 M 100644 inline good/night.txt
3009 M 100644 inline good/bye.txt
3016 test_expect_success 'U: initialize for U tests' '
3017 git fast-import <input
3020 cat >input <<INPUT_END
3022 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3024 delete good/night.txt
3031 test_expect_success 'U: filedelete file succeeds' '
3032 git fast-import <input
3036 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3039 git diff-tree -M -r U^1 U >actual
3041 test_expect_success 'U: validate file delete result' '
3042 compare_diff_raw expect actual
3045 cat >input <<INPUT_END
3047 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3056 test_expect_success 'U: filedelete directory succeeds' '
3057 git fast-import <input
3061 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3064 git diff-tree -M -r U^1 U >actual
3066 test_expect_success 'U: validate directory delete result' '
3067 compare_diff_raw expect actual
3070 cat >input <<INPUT_END
3072 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3081 test_expect_success 'U: filedelete root succeeds' '
3082 git fast-import <input
3086 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3089 git diff-tree -M -r U^1 U >actual
3091 test_expect_success 'U: validate root delete result' '
3092 compare_diff_raw expect actual