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.'
54 test_expect_success
'empty stream succeeds' '
55 git config fastimport.unpackLimit 0 &&
56 git fast-import </dev/null
59 test_expect_success
'truncated stream complains' '
60 echo "tag foo" | test_must_fail git fast-import
63 test_expect_success
'A: create pack from stdin' '
65 cat >input <<-INPUT_END &&
82 commit refs/heads/master
84 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
96 An annotated tag without a tagger
102 An annotated tag that annotates a blob.
106 git fast-import --export-marks=marks.out <input &&
107 git whatchanged master
110 test_expect_success
'A: verify pack' '
114 test_expect_success
'A: verify commit' '
115 cat >expect <<-EOF &&
116 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
117 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
121 git cat-file commit master | sed 1d >actual &&
122 test_cmp expect actual
125 test_expect_success
'A: verify tree' '
126 cat >expect <<-EOF &&
131 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
132 test_cmp expect actual
135 test_expect_success
'A: verify file2' '
136 echo "$file2_data" >expect &&
137 git cat-file blob master:file2 >actual &&
138 test_cmp expect actual
141 test_expect_success
'A: verify file3' '
142 echo "$file3_data" >expect &&
143 git cat-file blob master:file3 >actual &&
144 test_cmp expect actual
147 test_expect_success
'A: verify file4' '
148 printf "$file4_data" >expect &&
149 git cat-file blob master:file4 >actual &&
150 test_cmp expect actual
153 test_expect_success
'A: verify tag/series-A' '
154 cat >expect <<-EOF &&
155 object $(git rev-parse refs/heads/master)
159 An annotated tag without a tagger
161 git cat-file tag tags/series-A >actual &&
162 test_cmp expect actual
165 test_expect_success
'A: verify tag/series-A-blob' '
166 cat >expect <<-EOF &&
167 object $(git rev-parse refs/heads/master:file3)
171 An annotated tag that annotates a blob.
173 git cat-file tag tags/series-A-blob >actual &&
174 test_cmp expect actual
177 test_expect_success
'A: verify marks output' '
178 cat >expect <<-EOF &&
179 :2 $(git rev-parse --verify master:file2)
180 :3 $(git rev-parse --verify master:file3)
181 :4 $(git rev-parse --verify master:file4)
182 :5 $(git rev-parse --verify master^0)
184 test_cmp expect marks.out
187 test_expect_success
'A: verify marks import' '
189 --import-marks=marks.out \
190 --export-marks=marks.new \
192 test_cmp expect marks.new
195 test_expect_success
'A: tag blob by sha1' '
197 new_blob=$(echo testing | git hash-object --stdin) &&
198 cat >input <<-INPUT_END &&
200 from $(git rev-parse refs/heads/master:file3)
211 commit refs/heads/new_blob
215 #pretend we got sha1 from fast-import
225 cat >expect <<-EOF &&
226 object $(git rev-parse refs/heads/master:file3)
238 git fast-import <input &&
239 git cat-file tag tags/series-A-blob-2 >actual &&
240 git cat-file tag tags/series-A-blob-3 >>actual &&
241 test_cmp expect actual
244 test_expect_success
'A: verify marks import does not crash' '
246 cat >input <<-INPUT_END &&
247 commit refs/heads/verify--import-marks
248 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
254 M 755 :2 copy-of-file2
258 git fast-import --import-marks=marks.out <input &&
259 git whatchanged verify--import-marks
262 test_expect_success
'A: verify pack' '
266 test_expect_success
'A: verify diff' '
267 cat >expect <<-EOF &&
268 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
270 git diff-tree -M -r master verify--import-marks >actual &&
271 compare_diff_raw expect actual &&
272 test $(git rev-parse --verify master:file2) \
273 = $(git rev-parse --verify verify--import-marks:copy-of-file2)
276 test_expect_success
'A: export marks with large values' '
278 mt=$(git hash-object --stdin < /dev/null) &&
283 cat >input.commit <<-EOF &&
284 commit refs/heads/verify--dump-marks
285 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
287 test the sparse array dumping routines with exponentially growing marks
292 while test "$i" -lt 27
294 cat >>input.blob <<-EOF &&
305 echo "M 100644 :$l l$i" >>input.commit &&
306 echo "M 100644 :$m m$i" >>input.commit &&
307 echo "M 100644 :$n n$i" >>input.commit &&
309 echo ":$l $mt" >>marks.exp &&
310 echo ":$m $mt" >>marks.exp &&
311 echo ":$n $mt" >>marks.exp &&
313 printf "100644 blob $mt\tl$i\n" >>tree.exp &&
314 printf "100644 blob $mt\tm$i\n" >>tree.exp &&
315 printf "100644 blob $mt\tn$i\n" >>tree.exp &&
321 i=$((1 + $i)) || return 1
324 sort tree.exp > tree.exp_s &&
326 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
327 git ls-tree refs/heads/verify--dump-marks >tree.out &&
328 test_cmp tree.exp_s tree.out &&
329 test_cmp marks.exp marks.large
336 test_expect_success
'B: fail on invalid blob sha1' '
338 cat >input <<-INPUT_END &&
339 commit refs/heads/branch
341 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
346 from refs/heads/master
347 M 755 0000000000000000000000000000000000000001 zero1
351 test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
352 test_must_fail git fast-import <input
355 test_expect_success
'B: accept branch name "TEMP_TAG"' '
356 cat >input <<-INPUT_END &&
358 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
363 from refs/heads/master
367 test_when_finished "rm -f .git/TEMP_TAG
370 git fast-import <input &&
371 test -f .git/TEMP_TAG &&
372 test $(git rev-parse master) = $(git rev-parse TEMP_TAG^)
375 test_expect_success
'B: accept empty committer' '
376 cat >input <<-INPUT_END &&
377 commit refs/heads/empty-committer-1
378 committer <> $GIT_COMMITTER_DATE
384 test_when_finished "git update-ref -d refs/heads/empty-committer-1
387 git fast-import <input &&
393 test_expect_success
'B: accept and fixup committer with no name' '
394 cat >input <<-INPUT_END &&
395 commit refs/heads/empty-committer-2
396 committer <a@b.com> $GIT_COMMITTER_DATE
402 test_when_finished "git update-ref -d refs/heads/empty-committer-2
405 git fast-import <input &&
411 test_expect_success
'B: fail on invalid committer (1)' '
412 cat >input <<-INPUT_END &&
413 commit refs/heads/invalid-committer
414 committer Name email> $GIT_COMMITTER_DATE
420 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
421 test_must_fail git fast-import <input
424 test_expect_success
'B: fail on invalid committer (2)' '
425 cat >input <<-INPUT_END &&
426 commit refs/heads/invalid-committer
427 committer Name <e<mail> $GIT_COMMITTER_DATE
433 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
434 test_must_fail git fast-import <input
437 test_expect_success
'B: fail on invalid committer (3)' '
438 cat >input <<-INPUT_END &&
439 commit refs/heads/invalid-committer
440 committer Name <email>> $GIT_COMMITTER_DATE
446 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
447 test_must_fail git fast-import <input
450 test_expect_success
'B: fail on invalid committer (4)' '
451 cat >input <<-INPUT_END &&
452 commit refs/heads/invalid-committer
453 committer Name <email $GIT_COMMITTER_DATE
459 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
460 test_must_fail git fast-import <input
463 test_expect_success
'B: fail on invalid committer (5)' '
464 cat >input <<-INPUT_END &&
465 commit refs/heads/invalid-committer
466 committer Name<email> $GIT_COMMITTER_DATE
472 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
473 test_must_fail git fast-import <input
480 test_expect_success
'C: incremental import create pack from stdin' '
481 newf=$(echo hi newf | git hash-object -w --stdin) &&
482 oldf=$(git rev-parse --verify master:file2) &&
484 cat >input <<-INPUT_END &&
485 commit refs/heads/branch
486 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
491 from refs/heads/master
492 M 644 $oldf file2/oldf
493 M 755 $newf file2/newf
498 git fast-import <input &&
499 git whatchanged branch
502 test_expect_success
'C: verify pack' '
506 test_expect_success
'C: validate reuse existing blob' '
507 test $newf = $(git rev-parse --verify branch:file2/newf) &&
508 test $oldf = $(git rev-parse --verify branch:file2/oldf)
511 test_expect_success
'C: verify commit' '
512 cat >expect <<-EOF &&
513 parent $(git rev-parse --verify master^0)
514 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
515 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
520 git cat-file commit branch | sed 1d >actual &&
521 test_cmp expect actual
524 test_expect_success
'C: validate rename result' '
525 cat >expect <<-EOF &&
526 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
527 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
528 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
530 git diff-tree -M -r master branch >actual &&
531 compare_diff_raw expect actual
538 test_expect_success
'D: inline data in commit' '
540 cat >input <<-INPUT_END &&
541 commit refs/heads/branch
542 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
547 from refs/heads/branch^0
548 M 644 inline newdir/interesting
553 M 755 inline newdir/exec.sh
560 git fast-import <input &&
561 git whatchanged branch
564 test_expect_success
'D: verify pack' '
568 test_expect_success
'D: validate new files added' '
569 cat >expect <<-EOF &&
570 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
571 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
573 git diff-tree -M -r branch^ branch >actual &&
574 compare_diff_raw expect actual
577 test_expect_success
'D: verify file5' '
578 echo "$file5_data" >expect &&
579 git cat-file blob branch:newdir/interesting >actual &&
580 test_cmp expect actual
583 test_expect_success
'D: verify file6' '
584 echo "$file6_data" >expect &&
585 git cat-file blob branch:newdir/exec.sh >actual &&
586 test_cmp expect actual
593 test_expect_success
'E: rfc2822 date, --date-format=raw' '
594 cat >input <<-INPUT_END &&
595 commit refs/heads/branch
596 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
597 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
602 from refs/heads/branch^0
606 test_must_fail git fast-import --date-format=raw <input
608 test_expect_success
'E: rfc2822 date, --date-format=rfc2822' '
609 git fast-import --date-format=rfc2822 <input
612 test_expect_success
'E: verify pack' '
616 test_expect_success
'E: verify commit' '
617 cat >expect <<-EOF &&
618 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
619 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
623 git cat-file commit branch | sed 1,2d >actual &&
624 test_cmp expect actual
631 test_expect_success
'F: non-fast-forward update skips' '
632 old_branch=$(git rev-parse --verify branch^0) &&
634 cat >input <<-INPUT_END &&
635 commit refs/heads/branch
636 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
638 losing things already?
641 from refs/heads/branch~1
643 reset refs/heads/other
644 from refs/heads/branch
648 test_must_fail git fast-import <input &&
649 # branch must remain unaffected
650 test $old_branch = $(git rev-parse --verify branch^0)
653 test_expect_success
'F: verify pack' '
657 test_expect_success
'F: verify other commit' '
658 cat >expect <<-EOF &&
659 tree $(git rev-parse branch~1^{tree})
660 parent $(git rev-parse branch~1)
661 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
662 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
664 losing things already?
666 git cat-file commit other >actual &&
667 test_cmp expect actual
674 test_expect_success
'G: non-fast-forward update forced' '
675 old_branch=$(git rev-parse --verify branch^0) &&
677 cat >input <<-INPUT_END &&
678 commit refs/heads/branch
679 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
681 losing things already?
684 from refs/heads/branch~1
687 git fast-import --force <input
690 test_expect_success
'G: verify pack' '
694 test_expect_success
'G: branch changed, but logged' '
695 test $old_branch != $(git rev-parse --verify branch^0) &&
696 test $old_branch = $(git rev-parse --verify branch@{1})
703 test_expect_success
'H: deletall, add 1' '
705 cat >input <<-INPUT_END &&
707 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
712 from refs/heads/branch^0
713 M 644 inline i-will-die
715 this file will never exist.
719 M 644 inline h/e/l/lo
725 git fast-import <input &&
729 test_expect_success
'H: verify pack' '
733 test_expect_success
'H: validate old files removed, new files added' '
734 cat >expect <<-EOF &&
735 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
736 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
737 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
738 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
739 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
741 git diff-tree -M -r H^ H >actual &&
742 compare_diff_raw expect actual
745 test_expect_success
'H: verify file' '
746 echo "$file5_data" >expect &&
747 git cat-file blob H:h/e/l/lo >actual &&
748 test_cmp expect actual
755 test_expect_success
'I: export-pack-edges' '
756 cat >input <<-INPUT_END &&
757 commit refs/heads/export-boundary
758 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
760 we have a border. its only 40 characters wide.
763 from refs/heads/branch
766 git fast-import --export-pack-edges=edges.list <input
769 test_expect_success
'I: verify edge list' '
770 cat >expect <<-EOF &&
771 .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
773 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
774 test_cmp expect actual
781 test_expect_success
'J: reset existing branch creates empty commit' '
782 cat >input <<-INPUT_END &&
784 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
789 from refs/heads/branch
794 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
800 git fast-import <input
802 test_expect_success
'J: branch has 1 commit, empty tree' '
803 test 1 = $(git rev-list J | wc -l) &&
804 test 0 = $(git ls-tree J | wc -l)
807 test_expect_success
'J: tag must fail on empty branch' '
808 cat >input <<-INPUT_END &&
814 Tag branch that was reset.
817 test_must_fail git fast-import <input
824 test_expect_success
'K: reinit branch with from' '
825 cat >input <<-INPUT_END &&
827 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
832 from refs/heads/branch
835 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
840 from refs/heads/branch^1
843 git fast-import <input
845 test_expect_success
'K: verify K^1 = branch^1' '
846 test $(git rev-parse --verify branch^1) \
847 = $(git rev-parse --verify K^1)
854 test_expect_success
'L: verify internal tree sorting' '
855 cat >input <<-INPUT_END &&
869 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
879 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
889 cat >expect <<-EXPECT_END &&
890 :100644 100644 4268632... 55d3a52... M b.
891 :040000 040000 0ae5cac... 443c768... M b
892 :100644 100644 4268632... 55d3a52... M ba
895 git fast-import <input &&
896 git diff-tree --abbrev --raw L^ L >output &&
897 test_cmp expect output
900 test_expect_success
'L: nested tree copy does not corrupt deltas' '
901 cat >input <<-INPUT_END &&
909 committer C O Mitter <committer@example.com> 1112912473 -0700
918 committer C O Mitter <committer@example.com> 1112912473 -0700
927 cat >expect <<-\EOF &&
932 test_when_finished "git update-ref -d refs/heads/L2" &&
933 git fast-import <input &&
934 git ls-tree L2 g/b/ >tmp &&
935 cat tmp | cut -f 2 >actual &&
936 test_cmp expect actual &&
937 git fsck $(git rev-parse L2)
944 test_expect_success
'M: rename file in same subdirectory' '
946 cat >input <<-INPUT_END &&
948 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
953 from refs/heads/branch^0
954 R file2/newf file2/n.e.w.f
958 cat >expect <<-EOF &&
959 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
961 git fast-import <input &&
962 git diff-tree -M -r M1^ M1 >actual &&
963 compare_diff_raw expect actual
966 test_expect_success
'M: rename file to new subdirectory' '
967 cat >input <<-INPUT_END &&
969 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
974 from refs/heads/branch^0
975 R file2/newf i/am/new/to/you
979 cat >expect <<-EOF &&
980 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
982 git fast-import <input &&
983 git diff-tree -M -r M2^ M2 >actual &&
984 compare_diff_raw expect actual
987 test_expect_success
'M: rename subdirectory to new subdirectory' '
988 cat >input <<-INPUT_END &&
990 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1000 cat >expect <<-EOF &&
1001 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1003 git fast-import <input &&
1004 git diff-tree -M -r M3^ M3 >actual &&
1005 compare_diff_raw expect actual
1008 test_expect_success
'M: rename root to subdirectory' '
1009 cat >input <<-INPUT_END &&
1010 commit refs/heads/M4
1011 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1016 from refs/heads/M2^0
1021 cat >expect <<-EOF &&
1022 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1023 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1024 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1025 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1026 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1028 git fast-import <input &&
1029 git diff-tree -M -r M4^ M4 >actual &&
1031 compare_diff_raw expect actual
1038 test_expect_success
'N: copy file in same subdirectory' '
1040 cat >input <<-INPUT_END &&
1041 commit refs/heads/N1
1042 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1047 from refs/heads/branch^0
1048 C file2/newf file2/n.e.w.f
1052 cat >expect <<-EOF &&
1053 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1055 git fast-import <input &&
1056 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1057 compare_diff_raw expect actual
1060 test_expect_success
'N: copy then modify subdirectory' '
1061 cat >input <<-INPUT_END &&
1062 commit refs/heads/N2
1063 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1065 clean directory copy
1068 from refs/heads/branch^0
1071 commit refs/heads/N2
1072 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1074 modify directory copy
1077 M 644 inline file3/file5
1084 cat >expect <<-EOF &&
1085 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1086 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1087 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1089 git fast-import <input &&
1090 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1091 compare_diff_raw expect actual
1094 test_expect_success
'N: copy dirty subdirectory' '
1095 cat >input <<-INPUT_END &&
1096 commit refs/heads/N3
1097 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1099 dirty directory copy
1102 from refs/heads/branch^0
1103 M 644 inline file2/file5
1113 git fast-import <input &&
1114 test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})
1117 test_expect_success
'N: copy directory by id' '
1118 cat >expect <<-\EOF &&
1119 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1120 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1122 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1123 cat >input <<-INPUT_END &&
1124 commit refs/heads/N4
1125 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1130 from refs/heads/branch^0
1131 M 040000 $subdir file3
1133 git fast-import <input &&
1134 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1135 compare_diff_raw expect actual
1138 test_expect_success PIPE
'N: read and copy directory' '
1139 cat >expect <<-\EOF &&
1140 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1141 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1143 git update-ref -d refs/heads/N4 &&
1149 commit refs/heads/N4
1150 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1152 copy by tree hash, part 2
1155 from refs/heads/branch^0
1158 read mode type tree filename &&
1159 echo "M 040000 $tree file3"
1161 git fast-import --cat-blob-fd=3 3>backflow &&
1162 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1163 compare_diff_raw expect actual
1166 test_expect_success PIPE
'N: empty directory reads as missing' '
1167 cat <<-\EOF >expect &&
1169 :000000 100644 OBJNAME OBJNAME A unrelated
1171 echo "missing src" >expect.response &&
1172 git update-ref -d refs/heads/read-empty &&
1178 commit refs/heads/read-empty
1179 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1181 read "empty" (missing) directory
1184 M 100644 inline src/greeting
1188 C src/greeting dst1/non-greeting
1189 C src/greeting unrelated
1190 # leave behind "empty" src directory
1195 printf "%s\n" "$line" >response &&
1201 git fast-import --cat-blob-fd=3 3>backflow &&
1202 test_cmp expect.response response &&
1203 git rev-list read-empty |
1204 git diff-tree -r --root --stdin |
1205 sed "s/$_x40/OBJNAME/g" >actual &&
1206 test_cmp expect actual
1209 test_expect_success
'N: copy root directory by tree hash' '
1210 cat >expect <<-\EOF &&
1211 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1212 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1214 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1215 cat >input <<-INPUT_END &&
1216 commit refs/heads/N6
1217 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1219 copy root directory by tree hash
1222 from refs/heads/branch^0
1225 git fast-import <input &&
1226 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1227 compare_diff_raw expect actual
1230 test_expect_success
'N: copy root by path' '
1231 cat >expect <<-\EOF &&
1232 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1233 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1234 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1235 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1236 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1238 cat >input <<-INPUT_END &&
1239 commit refs/heads/N-copy-root-path
1240 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1242 copy root directory by (empty) path
1245 from refs/heads/branch^0
1248 git fast-import <input &&
1249 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1250 compare_diff_raw expect actual
1253 test_expect_success
'N: delete directory by copying' '
1254 cat >expect <<-\EOF &&
1256 :100644 000000 OBJID OBJID D foo/bar/qux
1258 :000000 100644 OBJID OBJID A foo/bar/baz
1259 :000000 100644 OBJID OBJID A foo/bar/qux
1261 empty_tree=$(git mktree </dev/null) &&
1262 cat >input <<-INPUT_END &&
1263 commit refs/heads/N-delete
1264 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1266 collect data to be deleted
1270 M 100644 inline foo/bar/baz
1274 C "foo/bar/baz" "foo/bar/qux"
1275 C "foo/bar/baz" "foo/bar/quux/1"
1276 C "foo/bar/baz" "foo/bar/quuux"
1277 M 040000 $empty_tree foo/bar/quux
1278 M 040000 $empty_tree foo/bar/quuux
1280 commit refs/heads/N-delete
1281 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1286 M 040000 $empty_tree foo/bar/qux
1288 git fast-import <input &&
1289 git rev-list N-delete |
1290 git diff-tree -r --stdin --root --always |
1291 sed -e "s/$_x40/OBJID/g" >actual &&
1292 test_cmp expect actual
1295 test_expect_success
'N: modify copied tree' '
1296 cat >expect <<-\EOF &&
1297 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1298 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1299 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1301 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1302 cat >input <<-INPUT_END &&
1303 commit refs/heads/N5
1304 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1309 from refs/heads/branch^0
1310 M 040000 $subdir file3
1312 commit refs/heads/N5
1313 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1315 modify directory copy
1318 M 644 inline file3/file5
1323 git fast-import <input &&
1324 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1325 compare_diff_raw expect actual
1328 test_expect_success
'N: reject foo/ syntax' '
1329 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1330 test_must_fail git fast-import <<-INPUT_END
1331 commit refs/heads/N5B
1332 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1334 copy with invalid syntax
1337 from refs/heads/branch^0
1338 M 040000 $subdir file3/
1342 test_expect_success
'N: reject foo/ syntax in copy source' '
1343 test_must_fail git fast-import <<-INPUT_END
1344 commit refs/heads/N5C
1345 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1347 copy with invalid syntax
1350 from refs/heads/branch^0
1355 test_expect_success
'N: reject foo/ syntax in rename source' '
1356 test_must_fail git fast-import <<-INPUT_END
1357 commit refs/heads/N5D
1358 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1360 rename with invalid syntax
1363 from refs/heads/branch^0
1368 test_expect_success
'N: reject foo/ syntax in ls argument' '
1369 test_must_fail git fast-import <<-INPUT_END
1370 commit refs/heads/N5E
1371 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1373 copy with invalid syntax
1376 from refs/heads/branch^0
1381 test_expect_success
'N: copy to root by id and modify' '
1382 echo "hello, world" >expect.foo &&
1383 echo hello >expect.bar &&
1384 git fast-import <<-SETUP_END &&
1385 commit refs/heads/N7
1386 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1392 M 644 inline foo/bar
1398 tree=$(git rev-parse --verify N7:) &&
1399 git fast-import <<-INPUT_END &&
1400 commit refs/heads/N8
1401 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1403 copy to root by id and modify
1407 M 644 inline foo/foo
1412 git show N8:foo/foo >actual.foo &&
1413 git show N8:foo/bar >actual.bar &&
1414 test_cmp expect.foo actual.foo &&
1415 test_cmp expect.bar actual.bar
1418 test_expect_success
'N: extract subtree' '
1419 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1420 cat >input <<-INPUT_END &&
1421 commit refs/heads/N9
1422 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1424 extract subtree branch:newdir
1430 git fast-import <input &&
1431 git diff --exit-code branch:newdir N9
1434 test_expect_success
'N: modify subtree, extract it, and modify again' '
1435 echo hello >expect.baz &&
1436 echo hello, world >expect.qux &&
1437 git fast-import <<-SETUP_END &&
1438 commit refs/heads/N10
1439 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1445 M 644 inline foo/bar/baz
1451 tree=$(git rev-parse --verify N10:) &&
1452 git fast-import <<-INPUT_END &&
1453 commit refs/heads/N11
1454 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1456 copy to root by id and modify
1460 M 100644 inline foo/bar/qux
1465 C "bar/qux" "bar/quux"
1467 git show N11:bar/baz >actual.baz &&
1468 git show N11:bar/qux >actual.qux &&
1469 git show N11:bar/quux >actual.quux &&
1470 test_cmp expect.baz actual.baz &&
1471 test_cmp expect.qux actual.qux &&
1472 test_cmp expect.qux actual.quux'
1478 test_expect_success
'O: comments are all skipped' '
1479 cat >input <<-INPUT_END &&
1481 commit refs/heads/O1
1482 # -- ignore all of this text
1483 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1484 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1486 dirty directory copy
1489 # do not forget the import blank line!
1491 # yes, we started from our usual base of branch^0.
1493 from refs/heads/branch^0
1494 # and we need to reuse file2/file5 from N3 above.
1495 M 644 inline file2/file5
1496 # otherwise the tree will be different
1501 # do not forget to copy file2 to file3
1504 # or to delete file5 from file2.
1510 git fast-import <input &&
1511 test $(git rev-parse N3) = $(git rev-parse O1)
1514 test_expect_success
'O: blank lines not necessary after data commands' '
1515 cat >input <<-INPUT_END &&
1516 commit refs/heads/O2
1517 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1519 dirty directory copy
1521 from refs/heads/branch^0
1522 M 644 inline file2/file5
1531 git fast-import <input &&
1532 test $(git rev-parse N3) = $(git rev-parse O2)
1535 test_expect_success
'O: repack before next test' '
1539 test_expect_success
'O: blank lines not necessary after other commands' '
1540 cat >input <<-INPUT_END &&
1541 commit refs/heads/O3
1542 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1546 commit refs/heads/O3
1547 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1552 commit refs/heads/O3
1554 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1559 commit refs/heads/O3
1560 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1564 reset refs/tags/O3-2nd
1566 reset refs/tags/O3-3rd
1570 cat >expect <<-INPUT_END &&
1577 git fast-import <input &&
1578 test 8 = $(find .git/objects/pack -type f | wc -l) &&
1579 test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
1580 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1581 test_cmp expect actual
1584 test_expect_success
'O: progress outputs as requested by input' '
1585 cat >input <<-INPUT_END &&
1586 commit refs/heads/O4
1587 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1591 commit refs/heads/O4
1592 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1596 progress Two commits down, 2 to go!
1597 commit refs/heads/O4
1598 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1602 progress Three commits down, 1 to go!
1603 commit refs/heads/O4
1604 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1610 git fast-import <input >actual &&
1611 grep "progress " <input >expect &&
1612 test_cmp expect actual
1616 ### series P (gitlinks)
1619 test_expect_success
'P: superproject & submodule mix' '
1620 cat >input <<-INPUT_END &&
1626 reset refs/heads/sub
1627 commit refs/heads/sub
1629 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1642 commit refs/heads/subuse1
1644 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1647 from refs/heads/master
1648 M 100644 :3 .gitmodules
1657 commit refs/heads/sub
1659 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1665 commit refs/heads/subuse1
1667 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1675 git fast-import <input &&
1676 git checkout subuse1 &&
1682 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1685 git submodule init &&
1686 git submodule update
1689 test_expect_success
'P: verbatim SHA gitlinks' '
1690 SUBLAST=$(git rev-parse --verify sub) &&
1691 SUBPREV=$(git rev-parse --verify sub^) &&
1693 cat >input <<-INPUT_END &&
1702 commit refs/heads/subuse2
1704 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1707 from refs/heads/master
1708 M 100644 :1 .gitmodules
1709 M 160000 $SUBPREV sub
1711 commit refs/heads/subuse2
1713 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1717 M 160000 $SUBLAST sub
1721 git branch -D sub &&
1724 git fast-import <input &&
1725 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1728 test_expect_success
'P: fail on inline gitlink' '
1730 cat >input <<-INPUT_END &&
1731 commit refs/heads/subuse3
1733 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1738 from refs/heads/subuse2
1746 test_must_fail git fast-import <input
1749 test_expect_success
'P: fail on blob mark in gitlink' '
1751 cat >input <<-INPUT_END &&
1758 commit refs/heads/subuse3
1760 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1765 from refs/heads/subuse2
1770 test_must_fail git fast-import <input
1774 ### series Q (notes)
1777 test_expect_success
'Q: commit notes' '
1778 note1_data="The first note for the first commit" &&
1779 note2_data="The first note for the second commit" &&
1780 note3_data="The first note for the third commit" &&
1781 note1b_data="The second note for the first commit" &&
1782 note1c_data="The third note for the first commit" &&
1783 note2b_data="The second note for the second commit" &&
1786 cat >input <<-INPUT_END &&
1793 commit refs/heads/notes-test
1795 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1806 commit refs/heads/notes-test
1808 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1815 commit refs/heads/notes-test
1817 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1844 commit refs/notes/foobar
1846 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
1870 commit refs/notes/foobar2
1872 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1882 commit refs/notes/foobar
1884 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1897 git fast-import <input &&
1898 git whatchanged notes-test
1901 test_expect_success
'Q: verify pack' '
1905 test_expect_success
'Q: verify first commit' '
1906 commit1=$(git rev-parse notes-test~2) &&
1907 commit2=$(git rev-parse notes-test^) &&
1908 commit3=$(git rev-parse notes-test) &&
1910 cat >expect <<-EOF &&
1911 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1912 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1916 git cat-file commit notes-test~2 | sed 1d >actual &&
1917 test_cmp expect actual
1920 test_expect_success
'Q: verify second commit' '
1921 cat >expect <<-EOF &&
1923 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1924 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1928 git cat-file commit notes-test^ | sed 1d >actual &&
1929 test_cmp expect actual
1932 test_expect_success
'Q: verify third commit' '
1933 cat >expect <<-EOF &&
1935 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1936 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1940 git cat-file commit notes-test | sed 1d >actual &&
1941 test_cmp expect actual
1944 test_expect_success
'Q: verify first notes commit' '
1945 cat >expect <<-EOF &&
1946 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1947 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1951 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1952 test_cmp expect actual
1955 test_expect_success
'Q: verify first notes tree' '
1956 cat >expect.unsorted <<-EOF &&
1957 100644 blob $commit1
1958 100644 blob $commit2
1959 100644 blob $commit3
1961 cat expect.unsorted | sort >expect &&
1962 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1963 test_cmp expect actual
1966 test_expect_success
'Q: verify first note for first commit' '
1967 echo "$note1_data" >expect &&
1968 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1969 test_cmp expect actual
1972 test_expect_success
'Q: verify first note for second commit' '
1973 echo "$note2_data" >expect &&
1974 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1975 test_cmp expect actual
1978 test_expect_success
'Q: verify first note for third commit' '
1979 echo "$note3_data" >expect &&
1980 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
1981 test_cmp expect actual
1984 test_expect_success
'Q: verify second notes commit' '
1985 cat >expect <<-EOF &&
1986 parent $(git rev-parse --verify refs/notes/foobar~2)
1987 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1988 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1992 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1993 test_cmp expect actual
1996 test_expect_success
'Q: verify second notes tree' '
1997 cat >expect.unsorted <<-EOF &&
1998 100644 blob $commit1
1999 100644 blob $commit2
2000 100644 blob $commit3
2002 cat expect.unsorted | sort >expect &&
2003 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2004 test_cmp expect actual
2007 test_expect_success
'Q: verify second note for first commit' '
2008 echo "$note1b_data" >expect &&
2009 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
2010 test_cmp expect actual
2013 test_expect_success
'Q: verify first note for second commit' '
2014 echo "$note2_data" >expect &&
2015 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
2016 test_cmp expect actual
2019 test_expect_success
'Q: verify first note for third commit' '
2020 echo "$note3_data" >expect &&
2021 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2022 test_cmp expect actual
2025 test_expect_success
'Q: verify third notes commit' '
2026 cat >expect <<-EOF &&
2027 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2028 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2032 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2033 test_cmp expect actual
2036 test_expect_success
'Q: verify third notes tree' '
2037 cat >expect.unsorted <<-EOF &&
2038 100644 blob $commit1
2040 cat expect.unsorted | sort >expect &&
2041 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2042 test_cmp expect actual
2045 test_expect_success
'Q: verify third note for first commit' '
2046 echo "$note1c_data" >expect &&
2047 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2048 test_cmp expect actual
2051 test_expect_success
'Q: verify fourth notes commit' '
2052 cat >expect <<-EOF &&
2053 parent $(git rev-parse --verify refs/notes/foobar^)
2054 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2055 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2059 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2060 test_cmp expect actual
2063 test_expect_success
'Q: verify fourth notes tree' '
2064 cat >expect.unsorted <<-EOF &&
2065 100644 blob $commit2
2067 cat expect.unsorted | sort >expect &&
2068 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2069 test_cmp expect actual
2072 test_expect_success
'Q: verify second note for second commit' '
2073 echo "$note2b_data" >expect &&
2074 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2075 test_cmp expect actual
2078 test_expect_success
'Q: deny note on empty branch' '
2079 cat >input <<-EOF &&
2082 commit refs/heads/note-Q0
2083 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2085 Note for an empty branch.
2088 N inline refs/heads/Q0
2093 test_must_fail git fast-import <input
2096 ### series R (feature and option)
2099 test_expect_success
'R: abort on unsupported feature' '
2100 cat >input <<-EOF &&
2101 feature no-such-feature-exists
2104 test_must_fail git fast-import <input
2107 test_expect_success
'R: supported feature is accepted' '
2108 cat >input <<-EOF &&
2109 feature date-format=now
2112 git fast-import <input
2115 test_expect_success
'R: abort on receiving feature after data command' '
2116 cat >input <<-EOF &&
2120 feature date-format=now
2123 test_must_fail git fast-import <input
2126 test_expect_success
'R: only one import-marks feature allowed per stream' '
2127 cat >input <<-EOF &&
2128 feature import-marks=git.marks
2129 feature import-marks=git2.marks
2132 test_must_fail git fast-import <input
2135 test_expect_success
'R: export-marks feature results in a marks file being created' '
2136 cat >input <<-EOF &&
2137 feature export-marks=git.marks
2145 cat input | git fast-import &&
2149 test_expect_success
'R: export-marks options can be overridden by commandline options' '
2150 cat input | git fast-import --export-marks=other.marks &&
2154 test_expect_success
'R: catch typo in marks file name' '
2155 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2156 echo "feature import-marks=nonexistent.marks" |
2157 test_must_fail git fast-import
2160 test_expect_success
'R: import and output marks can be the same file' '
2162 blob=$(echo hi | git hash-object --stdin) &&
2163 cat >expect <<-EOF &&
2167 git fast-import --export-marks=io.marks <<-\EOF &&
2174 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2181 test_cmp expect io.marks
2184 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
2186 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2195 test_expect_success
'R: --import-marks-if-exists' '
2197 blob=$(echo hi | git hash-object --stdin) &&
2198 echo ":1 $blob" >expect &&
2199 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2206 test_cmp expect io.marks
2209 test_expect_success
'R: feature import-marks-if-exists' '
2213 git fast-import --export-marks=io.marks <<-\EOF &&
2214 feature import-marks-if-exists=not_io.marks
2216 test_cmp expect io.marks &&
2218 blob=$(echo hi | git hash-object --stdin) &&
2220 echo ":1 $blob" >io.marks &&
2221 echo ":1 $blob" >expect &&
2222 echo ":2 $blob" >>expect &&
2224 git fast-import --export-marks=io.marks <<-\EOF &&
2225 feature import-marks-if-exists=io.marks
2232 test_cmp expect io.marks &&
2234 echo ":3 $blob" >>expect &&
2236 git fast-import --import-marks=io.marks \
2237 --export-marks=io.marks <<-\EOF &&
2238 feature import-marks-if-exists=not_io.marks
2245 test_cmp expect io.marks &&
2249 git fast-import --import-marks-if-exists=not_io.marks \
2250 --export-marks=io.marks <<-\EOF &&
2251 feature import-marks-if-exists=io.marks
2253 test_cmp expect io.marks
2256 test_expect_success
'R: import to output marks works without any content' '
2257 cat >input <<-EOF &&
2258 feature import-marks=marks.out
2259 feature export-marks=marks.new
2262 cat input | git fast-import &&
2263 test_cmp marks.out marks.new
2266 test_expect_success
'R: import marks prefers commandline marks file over the stream' '
2267 cat >input <<-EOF &&
2268 feature import-marks=nonexistent.marks
2269 feature export-marks=marks.new
2272 cat input | git fast-import --import-marks=marks.out &&
2273 test_cmp marks.out marks.new
2277 test_expect_success
'R: multiple --import-marks= should be honoured' '
2278 cat >input <<-EOF &&
2279 feature import-marks=nonexistent.marks
2280 feature export-marks=combined.marks
2283 head -n2 marks.out > one.marks &&
2284 tail -n +3 marks.out > two.marks &&
2285 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2286 test_cmp marks.out combined.marks
2289 test_expect_success
'R: feature relative-marks should be honoured' '
2290 cat >input <<-EOF &&
2291 feature relative-marks
2292 feature import-marks=relative.in
2293 feature export-marks=relative.out
2296 mkdir -p .git/info/fast-import/ &&
2297 cp marks.new .git/info/fast-import/relative.in &&
2298 git fast-import <input &&
2299 test_cmp marks.new .git/info/fast-import/relative.out
2302 test_expect_success
'R: feature no-relative-marks should be honoured' '
2303 cat >input <<-EOF &&
2304 feature relative-marks
2305 feature import-marks=relative.in
2306 feature no-relative-marks
2307 feature export-marks=non-relative.out
2310 git fast-import <input &&
2311 test_cmp marks.new non-relative.out
2314 test_expect_success
'R: feature ls supported' '
2319 test_expect_success
'R: feature cat-blob supported' '
2320 echo "feature cat-blob" |
2324 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
2325 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2328 test_expect_success
!MINGW
'R: print old blob' '
2329 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2330 cat >expect <<-EOF &&
2335 echo "cat-blob $blob" |
2336 git fast-import --cat-blob-fd=6 6>actual &&
2337 test_cmp expect actual
2340 test_expect_success
!MINGW
'R: in-stream cat-blob-fd not respected' '
2341 echo hello >greeting &&
2342 blob=$(git hash-object -w greeting) &&
2343 cat >expect <<-EOF &&
2348 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2351 test_cmp expect actual.3 &&
2352 test_must_be_empty actual.1 &&
2353 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2354 option cat-blob-fd=3
2357 test_must_be_empty actual.3 &&
2358 test_cmp expect actual.1
2361 test_expect_success
!MINGW
'R: print mark for new blob' '
2362 echo "effluentish" | git hash-object --stdin >expect &&
2363 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2371 test_cmp expect actual
2374 test_expect_success
!MINGW
'R: print new blob' '
2375 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2376 cat >expect <<-EOF &&
2381 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2389 test_cmp expect actual
2392 test_expect_success
!MINGW
'R: print new blob by sha1' '
2393 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2394 cat >expect <<-EOF &&
2396 a new blob named by sha1
2399 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2402 a new blob named by sha1
2406 test_cmp expect actual
2409 test_expect_success
'setup: big file' '
2411 echo "the quick brown fox jumps over the lazy dog" >big &&
2414 cat big big big big >bigger &&
2415 cat bigger bigger bigger bigger >big ||
2421 test_expect_success
'R: print two blobs to stdout' '
2422 blob1=$(git hash-object big) &&
2423 blob1_len=$(wc -c <big) &&
2424 blob2=$(echo hello | git hash-object --stdin) &&
2426 echo ${blob1} blob $blob1_len &&
2436 cat <<-\END_PART1 &&
2453 git fast-import >actual &&
2454 test_cmp expect actual
2457 test_expect_success PIPE
'R: copy using cat-file' '
2458 expect_id=$(git hash-object big) &&
2459 expect_len=$(wc -c <big) &&
2460 echo $expect_id blob $expect_len >expect.response &&
2463 cat >frontend <<-\FRONTEND_END &&
2469 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2482 read blob_id type size <&3 &&
2483 echo "$blob_id $type $size" >response &&
2484 head_c $size >blob <&3 &&
2488 commit refs/heads/copied
2489 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2491 copy big file as file3
2499 git fast-import --cat-blob-fd=3 3>blobs &&
2500 git show copied:file3 >actual &&
2501 test_cmp expect.response response &&
2505 test_expect_success PIPE
'R: print blob mid-commit' '
2507 echo "A blob from _before_ the commit." >expect &&
2516 A blob from _before_ the commit.
2518 commit refs/heads/temporary
2519 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2526 read blob_id type size <&3 &&
2527 head_c $size >actual <&3 &&
2532 git fast-import --cat-blob-fd=3 3>blobs &&
2533 test_cmp expect actual
2536 test_expect_success PIPE
'R: print staged blob within commit' '
2538 echo "A blob from _within_ the commit." >expect &&
2544 commit refs/heads/within
2545 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2551 A blob from _within_ the commit.
2556 echo "A blob from _within_ the commit." |
2557 git hash-object --stdin
2559 echo "cat-blob $to_get" &&
2561 read blob_id type size <&3 &&
2562 head_c $size >actual <&3 &&
2567 git fast-import --cat-blob-fd=3 3>blobs &&
2568 test_cmp expect actual
2571 test_expect_success
'R: quiet option results in no stats being output' '
2572 cat >input <<-EOF &&
2580 cat input | git fast-import 2> output &&
2581 test_must_be_empty output
2584 test_expect_success
'R: feature done means terminating "done" is mandatory' '
2585 echo feature done | test_must_fail git fast-import &&
2586 test_must_fail git fast-import --done </dev/null
2589 test_expect_success
'R: terminating "done" with trailing gibberish is ok' '
2590 git fast-import <<-\EOF &&
2595 git fast-import <<-\EOF
2597 more trailing gibberish
2601 test_expect_success
'R: terminating "done" within commit' '
2602 cat >expect <<-\EOF &&
2604 :000000 100644 OBJID OBJID A hello.c
2605 :000000 100644 OBJID OBJID A hello2.c
2607 git fast-import <<-EOF &&
2608 commit refs/heads/done-ends
2609 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2611 Commit terminated by "done" command
2613 M 100644 inline hello.c
2620 git rev-list done-ends |
2621 git diff-tree -r --stdin --root --always |
2622 sed -e "s/$_x40/OBJID/g" >actual &&
2623 test_cmp expect actual
2626 test_expect_success
'R: die on unknown option' '
2627 cat >input <<-EOF &&
2628 option git non-existing-option
2631 test_must_fail git fast-import <input
2634 test_expect_success
'R: unknown commandline options are rejected' '\
2635 test_must_fail git fast-import --non-existing-option < /dev/null
2638 test_expect_success
'R: die on invalid option argument' '
2639 echo "option git active-branches=-5" |
2640 test_must_fail git fast-import &&
2641 echo "option git depth=" |
2642 test_must_fail git fast-import &&
2643 test_must_fail git fast-import --depth="5 elephants" </dev/null
2646 test_expect_success
'R: ignore non-git options' '
2647 cat >input <<-EOF &&
2648 option non-existing-vcs non-existing-option
2651 git fast-import <input
2654 test_expect_success
'R: corrupt lines do not mess marks file' '
2656 blob=$(echo hi | git hash-object --stdin) &&
2657 cat >expect <<-EOF &&
2658 :3 0000000000000000000000000000000000000000
2662 cp expect io.marks &&
2663 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2666 test_cmp expect io.marks
2670 ## R: very large blobs
2672 test_expect_success
'R: blob bigger than threshold' '
2673 blobsize=$((2*1024*1024 + 53)) &&
2674 test-genrandom bar $blobsize >expect &&
2675 cat >input <<-INPUT_END &&
2676 commit refs/heads/big-file
2677 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2685 cat expect >>input &&
2686 cat >>input <<-INPUT_END &&
2690 cat expect >>input &&
2693 test_create_repo R &&
2694 git --git-dir=R/.git config fastimport.unpackLimit 0 &&
2695 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2698 test_expect_success
'R: verify created pack' '
2701 verify_packs -v > ../verify
2705 test_expect_success
'R: verify written objects' '
2706 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2707 test_cmp_bin expect actual &&
2708 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2709 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2713 test_expect_success
'R: blob appears only once' '
2714 n=$(grep $a verify | wc -l) &&
2722 # Make sure missing spaces and EOLs after mark references
2731 # commit marks: 301, 302, 303, 304
2732 # blob marks: 403, 404, resp.
2735 # The error message when a space is missing not at the
2736 # end of the line is:
2738 # Missing space after ..
2740 # or when extra characters come after the mark at the end
2745 # or when the dataref is neither "inline " or a known SHA1,
2747 # Invalid dataref ..
2749 test_expect_success
'S: initialize for S tests' '
2752 cat >input <<-INPUT_END &&
2755 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2759 M 100644 inline hello.c
2766 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2771 M 100644 inline hello.c
2789 git fast-import --export-marks=marks <input
2793 # filemodify, three datarefs
2795 test_expect_success
'S: filemodify with garbage after mark 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
2802 M 100644 :403x hello.c
2805 test_i18ngrep "space after mark" err
2808 # inline is misspelled; fast-import thinks it is some unknown dataref
2809 test_expect_success
'S: filemodify with garbage after inline must fail' '
2810 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2812 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2816 M 100644 inlineX hello.c
2822 test_i18ngrep "nvalid dataref" err
2825 test_expect_success
'S: filemodify with garbage after sha1 must fail' '
2826 sha1=$(grep :403 marks | cut -d\ -f2) &&
2827 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2829 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2833 M 100644 ${sha1}x hello.c
2836 test_i18ngrep "space after SHA1" err
2840 # notemodify, three ways to say dataref
2842 test_expect_success
'S: notemodify with garabge after mark dataref must fail' '
2843 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2845 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2847 commit S note dataref markref
2852 test_i18ngrep "space after mark" err
2855 test_expect_success
'S: notemodify with garbage after inline dataref must fail' '
2856 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2858 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2860 commit S note dataref inline
2868 test_i18ngrep "nvalid dataref" err
2871 test_expect_success
'S: notemodify with garbage after sha1 dataref must fail' '
2872 sha1=$(grep :202 marks | cut -d\ -f2) &&
2873 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2875 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2877 commit S note dataref sha1
2882 test_i18ngrep "space after SHA1" err
2886 # notemodify, mark in commit-ish
2888 test_expect_success
'S: notemodify with garbage after mark commit-ish must fail' '
2889 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2890 commit refs/heads/Snotes
2891 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2893 commit S note commit-ish
2898 test_i18ngrep "after mark" err
2904 test_expect_success
'S: from with garbage after mark must fail' '
2906 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2907 commit refs/heads/S2
2909 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2914 M 100644 :403 hello.c
2918 # go create the commit, need it for merge test
2919 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2920 commit refs/heads/S2
2922 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2927 M 100644 :403 hello.c
2930 # now evaluate the error
2932 test_i18ngrep "after mark" err
2939 test_expect_success
'S: merge with garbage after mark must fail' '
2940 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2943 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2949 M 100644 :403 hello.c
2952 test_i18ngrep "after mark" err
2958 test_expect_success
'S: tag with garbage after mark must fail' '
2959 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2962 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2968 test_i18ngrep "after mark" err
2974 test_expect_success
'S: cat-blob with garbage after mark must fail' '
2975 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2979 test_i18ngrep "after mark" err
2985 test_expect_success
'S: ls with garbage after mark must fail' '
2986 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2990 test_i18ngrep "space after mark" err
2993 test_expect_success
'S: ls with garbage after sha1 must fail' '
2994 sha1=$(grep :302 marks | cut -d\ -f2) &&
2995 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2999 test_i18ngrep "space after tree-ish" err
3005 # Setup is carried over from series S.
3007 test_expect_success
'T: ls root tree' '
3008 sed -e "s/Z\$//" >expect <<-EOF &&
3009 040000 tree $(git rev-parse S^{tree}) Z
3011 sha1=$(git rev-parse --verify S) &&
3012 git fast-import --import-marks=marks <<-EOF >actual &&
3015 test_cmp expect actual
3018 test_expect_success
'T: delete branch' '
3019 git branch to-delete &&
3020 git fast-import <<-EOF &&
3021 reset refs/heads/to-delete
3022 from 0000000000000000000000000000000000000000
3024 test_must_fail git rev-parse --verify refs/heads/to-delete
3027 test_expect_success
'T: empty reset doesnt delete branch' '
3028 git branch not-to-delete &&
3029 git fast-import <<-EOF &&
3030 reset refs/heads/not-to-delete
3033 git rev-parse --verify refs/heads/not-to-delete
3037 ### series U (filedelete)
3040 test_expect_success
'U: initialize for U tests' '
3041 cat >input <<-INPUT_END &&
3043 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3047 M 100644 inline hello.c
3051 M 100644 inline good/night.txt
3055 M 100644 inline good/bye.txt
3062 git fast-import <input
3065 test_expect_success
'U: filedelete file succeeds' '
3066 cat >input <<-INPUT_END &&
3068 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3070 delete good/night.txt
3077 git fast-import <input
3080 test_expect_success
'U: validate file delete result' '
3081 cat >expect <<-EOF &&
3082 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3085 git diff-tree -M -r U^1 U >actual &&
3087 compare_diff_raw expect actual
3090 test_expect_success
'U: filedelete directory succeeds' '
3091 cat >input <<-INPUT_END &&
3093 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3102 git fast-import <input
3105 test_expect_success
'U: validate directory delete result' '
3106 cat >expect <<-EOF &&
3107 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3110 git diff-tree -M -r U^1 U >actual &&
3112 compare_diff_raw expect actual
3115 test_expect_success
'U: filedelete root succeeds' '
3116 cat >input <<-INPUT_END &&
3118 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3127 git fast-import <input
3130 test_expect_success
'U: validate root delete result' '
3131 cat >expect <<-EOF &&
3132 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3135 git diff-tree -M -r U^1 U >actual &&
3137 compare_diff_raw expect actual