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 fast-import </dev/null
58 test_expect_success
'truncated stream complains' '
59 echo "tag foo" | test_must_fail git fast-import
62 test_expect_success
'A: create pack from stdin' '
64 cat >input <<-INPUT_END &&
81 commit refs/heads/master
83 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
95 An annotated tag without a tagger
101 An annotated tag that annotates a blob.
105 git fast-import --export-marks=marks.out <input &&
106 git whatchanged master
109 test_expect_success
'A: verify pack' '
113 test_expect_success
'A: verify commit' '
114 cat >expect <<-EOF &&
115 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
116 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
120 git cat-file commit master | sed 1d >actual &&
121 test_cmp expect actual
124 test_expect_success
'A: verify tree' '
125 cat >expect <<-EOF &&
130 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
131 test_cmp expect actual
134 test_expect_success
'A: verify file2' '
135 echo "$file2_data" >expect &&
136 git cat-file blob master:file2 >actual &&
137 test_cmp expect actual
140 test_expect_success
'A: verify file3' '
141 echo "$file3_data" >expect &&
142 git cat-file blob master:file3 >actual &&
143 test_cmp expect actual
146 test_expect_success
'A: verify file4' '
147 printf "$file4_data" >expect &&
148 git cat-file blob master:file4 >actual &&
149 test_cmp expect actual
152 test_expect_success
'A: verify tag/series-A' '
153 cat >expect <<-EOF &&
154 object $(git rev-parse refs/heads/master)
158 An annotated tag without a tagger
160 git cat-file tag tags/series-A >actual &&
161 test_cmp expect actual
164 test_expect_success
'A: verify tag/series-A-blob' '
165 cat >expect <<-EOF &&
166 object $(git rev-parse refs/heads/master:file3)
170 An annotated tag that annotates a blob.
172 git cat-file tag tags/series-A-blob >actual &&
173 test_cmp expect actual
176 test_expect_success
'A: verify marks output' '
177 cat >expect <<-EOF &&
178 :2 $(git rev-parse --verify master:file2)
179 :3 $(git rev-parse --verify master:file3)
180 :4 $(git rev-parse --verify master:file4)
181 :5 $(git rev-parse --verify master^0)
183 test_cmp expect marks.out
186 test_expect_success
'A: verify marks import' '
188 --import-marks=marks.out \
189 --export-marks=marks.new \
191 test_cmp expect marks.new
194 test_expect_success
'A: tag blob by sha1' '
196 new_blob=$(echo testing | git hash-object --stdin) &&
197 cat >input <<-INPUT_END &&
199 from $(git rev-parse refs/heads/master:file3)
210 commit refs/heads/new_blob
214 #pretend we got sha1 from fast-import
224 cat >expect <<-EOF &&
225 object $(git rev-parse refs/heads/master:file3)
237 git fast-import <input &&
238 git cat-file tag tags/series-A-blob-2 >actual &&
239 git cat-file tag tags/series-A-blob-3 >>actual &&
240 test_cmp expect actual
243 test_expect_success
'A: verify marks import does not crash' '
245 cat >input <<-INPUT_END &&
246 commit refs/heads/verify--import-marks
247 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
253 M 755 :2 copy-of-file2
257 git fast-import --import-marks=marks.out <input &&
258 git whatchanged verify--import-marks
261 test_expect_success
'A: verify pack' '
265 test_expect_success
'A: verify diff' '
266 cat >expect <<-EOF &&
267 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
269 git diff-tree -M -r master verify--import-marks >actual &&
270 compare_diff_raw expect actual &&
271 test $(git rev-parse --verify master:file2) \
272 = $(git rev-parse --verify verify--import-marks:copy-of-file2)
275 test_expect_success
'A: export marks with large values' '
277 mt=$(git hash-object --stdin < /dev/null) &&
282 cat >input.commit <<-EOF &&
283 commit refs/heads/verify--dump-marks
284 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
286 test the sparse array dumping routines with exponentially growing marks
291 while test "$i" -lt 27
293 cat >>input.blob <<-EOF &&
304 echo "M 100644 :$l l$i" >>input.commit &&
305 echo "M 100644 :$m m$i" >>input.commit &&
306 echo "M 100644 :$n n$i" >>input.commit &&
308 echo ":$l $mt" >>marks.exp &&
309 echo ":$m $mt" >>marks.exp &&
310 echo ":$n $mt" >>marks.exp &&
312 printf "100644 blob $mt\tl$i\n" >>tree.exp &&
313 printf "100644 blob $mt\tm$i\n" >>tree.exp &&
314 printf "100644 blob $mt\tn$i\n" >>tree.exp &&
320 i=$((1 + $i)) || return 1
323 sort tree.exp > tree.exp_s &&
325 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
326 git ls-tree refs/heads/verify--dump-marks >tree.out &&
327 test_cmp tree.exp_s tree.out &&
328 test_cmp marks.exp marks.large
335 test_expect_success
'B: fail on invalid blob sha1' '
337 cat >input <<-INPUT_END &&
338 commit refs/heads/branch
340 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
345 from refs/heads/master
346 M 755 0000000000000000000000000000000000000001 zero1
350 test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
351 test_must_fail git fast-import <input
354 test_expect_success
'B: accept branch name "TEMP_TAG"' '
355 cat >input <<-INPUT_END &&
357 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
362 from refs/heads/master
366 test_when_finished "rm -f .git/TEMP_TAG
369 git fast-import <input &&
370 test -f .git/TEMP_TAG &&
371 test $(git rev-parse master) = $(git rev-parse TEMP_TAG^)
374 test_expect_success
'B: accept empty committer' '
375 cat >input <<-INPUT_END &&
376 commit refs/heads/empty-committer-1
377 committer <> $GIT_COMMITTER_DATE
383 test_when_finished "git update-ref -d refs/heads/empty-committer-1
386 git fast-import <input &&
392 test_expect_success
'B: accept and fixup committer with no name' '
393 cat >input <<-INPUT_END &&
394 commit refs/heads/empty-committer-2
395 committer <a@b.com> $GIT_COMMITTER_DATE
401 test_when_finished "git update-ref -d refs/heads/empty-committer-2
404 git fast-import <input &&
410 test_expect_success
'B: fail on invalid committer (1)' '
411 cat >input <<-INPUT_END &&
412 commit refs/heads/invalid-committer
413 committer Name email> $GIT_COMMITTER_DATE
419 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
420 test_must_fail git fast-import <input
423 test_expect_success
'B: fail on invalid committer (2)' '
424 cat >input <<-INPUT_END &&
425 commit refs/heads/invalid-committer
426 committer Name <e<mail> $GIT_COMMITTER_DATE
432 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
433 test_must_fail git fast-import <input
436 test_expect_success
'B: fail on invalid committer (3)' '
437 cat >input <<-INPUT_END &&
438 commit refs/heads/invalid-committer
439 committer Name <email>> $GIT_COMMITTER_DATE
445 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
446 test_must_fail git fast-import <input
449 test_expect_success
'B: fail on invalid committer (4)' '
450 cat >input <<-INPUT_END &&
451 commit refs/heads/invalid-committer
452 committer Name <email $GIT_COMMITTER_DATE
458 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
459 test_must_fail git fast-import <input
462 test_expect_success
'B: fail on invalid committer (5)' '
463 cat >input <<-INPUT_END &&
464 commit refs/heads/invalid-committer
465 committer Name<email> $GIT_COMMITTER_DATE
471 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
472 test_must_fail git fast-import <input
479 test_expect_success
'C: incremental import create pack from stdin' '
480 newf=$(echo hi newf | git hash-object -w --stdin) &&
481 oldf=$(git rev-parse --verify master:file2) &&
483 cat >input <<-INPUT_END &&
484 commit refs/heads/branch
485 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
490 from refs/heads/master
491 M 644 $oldf file2/oldf
492 M 755 $newf file2/newf
497 git fast-import <input &&
498 git whatchanged branch
501 test_expect_success
'C: verify pack' '
505 test_expect_success
'C: validate reuse existing blob' '
506 test $newf = $(git rev-parse --verify branch:file2/newf) &&
507 test $oldf = $(git rev-parse --verify branch:file2/oldf)
510 test_expect_success
'C: verify commit' '
511 cat >expect <<-EOF &&
512 parent $(git rev-parse --verify master^0)
513 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
514 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
519 git cat-file commit branch | sed 1d >actual &&
520 test_cmp expect actual
523 test_expect_success
'C: validate rename result' '
524 cat >expect <<-EOF &&
525 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
526 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
527 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
529 git diff-tree -M -r master branch >actual &&
530 compare_diff_raw expect actual
537 test_expect_success
'D: inline data in commit' '
539 cat >input <<-INPUT_END &&
540 commit refs/heads/branch
541 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
546 from refs/heads/branch^0
547 M 644 inline newdir/interesting
552 M 755 inline newdir/exec.sh
559 git fast-import <input &&
560 git whatchanged branch
563 test_expect_success
'D: verify pack' '
567 test_expect_success
'D: validate new files added' '
568 cat >expect <<-EOF &&
569 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
570 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
572 git diff-tree -M -r branch^ branch >actual &&
573 compare_diff_raw expect actual
576 test_expect_success
'D: verify file5' '
577 echo "$file5_data" >expect &&
578 git cat-file blob branch:newdir/interesting >actual &&
579 test_cmp expect actual
582 test_expect_success
'D: verify file6' '
583 echo "$file6_data" >expect &&
584 git cat-file blob branch:newdir/exec.sh >actual &&
585 test_cmp expect actual
592 test_expect_success
'E: rfc2822 date, --date-format=raw' '
593 cat >input <<-INPUT_END &&
594 commit refs/heads/branch
595 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
596 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
601 from refs/heads/branch^0
605 test_must_fail git fast-import --date-format=raw <input
607 test_expect_success
'E: rfc2822 date, --date-format=rfc2822' '
608 git fast-import --date-format=rfc2822 <input
611 test_expect_success
'E: verify pack' '
615 test_expect_success
'E: verify commit' '
616 cat >expect <<-EOF &&
617 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
618 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
622 git cat-file commit branch | sed 1,2d >actual &&
623 test_cmp expect actual
630 test_expect_success
'F: non-fast-forward update skips' '
631 old_branch=$(git rev-parse --verify branch^0) &&
633 cat >input <<-INPUT_END &&
634 commit refs/heads/branch
635 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
637 losing things already?
640 from refs/heads/branch~1
642 reset refs/heads/other
643 from refs/heads/branch
647 test_must_fail git fast-import <input &&
648 # branch must remain unaffected
649 test $old_branch = $(git rev-parse --verify branch^0)
652 test_expect_success
'F: verify pack' '
656 test_expect_success
'F: verify other commit' '
657 cat >expect <<-EOF &&
658 tree $(git rev-parse branch~1^{tree})
659 parent $(git rev-parse branch~1)
660 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
661 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
663 losing things already?
665 git cat-file commit other >actual &&
666 test_cmp expect actual
673 test_expect_success
'G: non-fast-forward update forced' '
674 old_branch=$(git rev-parse --verify branch^0) &&
676 cat >input <<-INPUT_END &&
677 commit refs/heads/branch
678 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
680 losing things already?
683 from refs/heads/branch~1
686 git fast-import --force <input
689 test_expect_success
'G: verify pack' '
693 test_expect_success
'G: branch changed, but logged' '
694 test $old_branch != $(git rev-parse --verify branch^0) &&
695 test $old_branch = $(git rev-parse --verify branch@{1})
702 test_expect_success
'H: deletall, add 1' '
704 cat >input <<-INPUT_END &&
706 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
711 from refs/heads/branch^0
712 M 644 inline i-will-die
714 this file will never exist.
718 M 644 inline h/e/l/lo
724 git fast-import <input &&
728 test_expect_success
'H: verify pack' '
732 test_expect_success
'H: validate old files removed, new files added' '
733 cat >expect <<-EOF &&
734 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
735 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
736 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
737 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
738 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
740 git diff-tree -M -r H^ H >actual &&
741 compare_diff_raw expect actual
744 test_expect_success
'H: verify file' '
745 echo "$file5_data" >expect &&
746 git cat-file blob H:h/e/l/lo >actual &&
747 test_cmp expect actual
754 test_expect_success
'I: export-pack-edges' '
755 cat >input <<-INPUT_END &&
756 commit refs/heads/export-boundary
757 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
759 we have a border. its only 40 characters wide.
762 from refs/heads/branch
765 git fast-import --export-pack-edges=edges.list <input
768 test_expect_success
'I: verify edge list' '
769 cat >expect <<-EOF &&
770 .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
772 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
773 test_cmp expect actual
780 test_expect_success
'J: reset existing branch creates empty commit' '
781 cat >input <<-INPUT_END &&
783 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
788 from refs/heads/branch
793 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
799 git fast-import <input
801 test_expect_success
'J: branch has 1 commit, empty tree' '
802 test 1 = $(git rev-list J | wc -l) &&
803 test 0 = $(git ls-tree J | wc -l)
806 test_expect_success
'J: tag must fail on empty branch' '
807 cat >input <<-INPUT_END &&
813 Tag branch that was reset.
816 test_must_fail git fast-import <input
823 test_expect_success
'K: reinit branch with from' '
824 cat >input <<-INPUT_END &&
826 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
831 from refs/heads/branch
834 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
839 from refs/heads/branch^1
842 git fast-import <input
844 test_expect_success
'K: verify K^1 = branch^1' '
845 test $(git rev-parse --verify branch^1) \
846 = $(git rev-parse --verify K^1)
853 test_expect_success
'L: verify internal tree sorting' '
854 cat >input <<-INPUT_END &&
868 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
878 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
888 cat >expect <<-EXPECT_END &&
889 :100644 100644 4268632... 55d3a52... M b.
890 :040000 040000 0ae5cac... 443c768... M b
891 :100644 100644 4268632... 55d3a52... M ba
894 git fast-import <input &&
895 git diff-tree --abbrev --raw L^ L >output &&
896 test_cmp expect output
899 test_expect_success
'L: nested tree copy does not corrupt deltas' '
900 cat >input <<-INPUT_END &&
908 committer C O Mitter <committer@example.com> 1112912473 -0700
917 committer C O Mitter <committer@example.com> 1112912473 -0700
926 cat >expect <<-\EOF &&
931 test_when_finished "git update-ref -d refs/heads/L2" &&
932 git fast-import <input &&
933 git ls-tree L2 g/b/ >tmp &&
934 cat tmp | cut -f 2 >actual &&
935 test_cmp expect actual &&
936 git fsck $(git rev-parse L2)
943 test_expect_success
'M: rename file in same subdirectory' '
945 cat >input <<-INPUT_END &&
947 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
952 from refs/heads/branch^0
953 R file2/newf file2/n.e.w.f
957 cat >expect <<-EOF &&
958 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
960 git fast-import <input &&
961 git diff-tree -M -r M1^ M1 >actual &&
962 compare_diff_raw expect actual
965 test_expect_success
'M: rename file to new subdirectory' '
966 cat >input <<-INPUT_END &&
968 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
973 from refs/heads/branch^0
974 R file2/newf i/am/new/to/you
978 cat >expect <<-EOF &&
979 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
981 git fast-import <input &&
982 git diff-tree -M -r M2^ M2 >actual &&
983 compare_diff_raw expect actual
986 test_expect_success
'M: rename subdirectory to new subdirectory' '
987 cat >input <<-INPUT_END &&
989 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
999 cat >expect <<-EOF &&
1000 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
1002 git fast-import <input &&
1003 git diff-tree -M -r M3^ M3 >actual &&
1004 compare_diff_raw expect actual
1007 test_expect_success
'M: rename root to subdirectory' '
1008 cat >input <<-INPUT_END &&
1009 commit refs/heads/M4
1010 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1015 from refs/heads/M2^0
1020 cat >expect <<-EOF &&
1021 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1022 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1023 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1024 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1025 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1027 git fast-import <input &&
1028 git diff-tree -M -r M4^ M4 >actual &&
1030 compare_diff_raw expect actual
1037 test_expect_success
'N: copy file in same subdirectory' '
1039 cat >input <<-INPUT_END &&
1040 commit refs/heads/N1
1041 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1046 from refs/heads/branch^0
1047 C file2/newf file2/n.e.w.f
1051 cat >expect <<-EOF &&
1052 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1054 git fast-import <input &&
1055 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1056 compare_diff_raw expect actual
1059 test_expect_success
'N: copy then modify subdirectory' '
1060 cat >input <<-INPUT_END &&
1061 commit refs/heads/N2
1062 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1064 clean directory copy
1067 from refs/heads/branch^0
1070 commit refs/heads/N2
1071 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1073 modify directory copy
1076 M 644 inline file3/file5
1083 cat >expect <<-EOF &&
1084 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1085 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1086 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1088 git fast-import <input &&
1089 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1090 compare_diff_raw expect actual
1093 test_expect_success
'N: copy dirty subdirectory' '
1094 cat >input <<-INPUT_END &&
1095 commit refs/heads/N3
1096 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1098 dirty directory copy
1101 from refs/heads/branch^0
1102 M 644 inline file2/file5
1112 git fast-import <input &&
1113 test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})
1116 test_expect_success
'N: copy directory by id' '
1117 cat >expect <<-\EOF &&
1118 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1119 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1121 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1122 cat >input <<-INPUT_END &&
1123 commit refs/heads/N4
1124 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1129 from refs/heads/branch^0
1130 M 040000 $subdir file3
1132 git fast-import <input &&
1133 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1134 compare_diff_raw expect actual
1137 test_expect_success PIPE
'N: read and copy directory' '
1138 cat >expect <<-\EOF &&
1139 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1140 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1142 git update-ref -d refs/heads/N4 &&
1148 commit refs/heads/N4
1149 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1151 copy by tree hash, part 2
1154 from refs/heads/branch^0
1157 read mode type tree filename &&
1158 echo "M 040000 $tree file3"
1160 git fast-import --cat-blob-fd=3 3>backflow &&
1161 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1162 compare_diff_raw expect actual
1165 test_expect_success PIPE
'N: empty directory reads as missing' '
1166 cat <<-\EOF >expect &&
1168 :000000 100644 OBJNAME OBJNAME A unrelated
1170 echo "missing src" >expect.response &&
1171 git update-ref -d refs/heads/read-empty &&
1177 commit refs/heads/read-empty
1178 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1180 read "empty" (missing) directory
1183 M 100644 inline src/greeting
1187 C src/greeting dst1/non-greeting
1188 C src/greeting unrelated
1189 # leave behind "empty" src directory
1194 printf "%s\n" "$line" >response &&
1200 git fast-import --cat-blob-fd=3 3>backflow &&
1201 test_cmp expect.response response &&
1202 git rev-list read-empty |
1203 git diff-tree -r --root --stdin |
1204 sed "s/$_x40/OBJNAME/g" >actual &&
1205 test_cmp expect actual
1208 test_expect_success
'N: copy root directory by tree hash' '
1209 cat >expect <<-\EOF &&
1210 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1211 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1213 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1214 cat >input <<-INPUT_END &&
1215 commit refs/heads/N6
1216 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1218 copy root directory by tree hash
1221 from refs/heads/branch^0
1224 git fast-import <input &&
1225 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1226 compare_diff_raw expect actual
1229 test_expect_success
'N: copy root by path' '
1230 cat >expect <<-\EOF &&
1231 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1232 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1233 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1234 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1235 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1237 cat >input <<-INPUT_END &&
1238 commit refs/heads/N-copy-root-path
1239 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1241 copy root directory by (empty) path
1244 from refs/heads/branch^0
1247 git fast-import <input &&
1248 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1249 compare_diff_raw expect actual
1252 test_expect_success
'N: delete directory by copying' '
1253 cat >expect <<-\EOF &&
1255 :100644 000000 OBJID OBJID D foo/bar/qux
1257 :000000 100644 OBJID OBJID A foo/bar/baz
1258 :000000 100644 OBJID OBJID A foo/bar/qux
1260 empty_tree=$(git mktree </dev/null) &&
1261 cat >input <<-INPUT_END &&
1262 commit refs/heads/N-delete
1263 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1265 collect data to be deleted
1269 M 100644 inline foo/bar/baz
1273 C "foo/bar/baz" "foo/bar/qux"
1274 C "foo/bar/baz" "foo/bar/quux/1"
1275 C "foo/bar/baz" "foo/bar/quuux"
1276 M 040000 $empty_tree foo/bar/quux
1277 M 040000 $empty_tree foo/bar/quuux
1279 commit refs/heads/N-delete
1280 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1285 M 040000 $empty_tree foo/bar/qux
1287 git fast-import <input &&
1288 git rev-list N-delete |
1289 git diff-tree -r --stdin --root --always |
1290 sed -e "s/$_x40/OBJID/g" >actual &&
1291 test_cmp expect actual
1294 test_expect_success
'N: modify copied tree' '
1295 cat >expect <<-\EOF &&
1296 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1297 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1298 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1300 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1301 cat >input <<-INPUT_END &&
1302 commit refs/heads/N5
1303 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1308 from refs/heads/branch^0
1309 M 040000 $subdir file3
1311 commit refs/heads/N5
1312 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1314 modify directory copy
1317 M 644 inline file3/file5
1322 git fast-import <input &&
1323 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1324 compare_diff_raw expect actual
1327 test_expect_success
'N: reject foo/ syntax' '
1328 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1329 test_must_fail git fast-import <<-INPUT_END
1330 commit refs/heads/N5B
1331 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1333 copy with invalid syntax
1336 from refs/heads/branch^0
1337 M 040000 $subdir file3/
1341 test_expect_success
'N: reject foo/ syntax in copy source' '
1342 test_must_fail git fast-import <<-INPUT_END
1343 commit refs/heads/N5C
1344 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1346 copy with invalid syntax
1349 from refs/heads/branch^0
1354 test_expect_success
'N: reject foo/ syntax in rename source' '
1355 test_must_fail git fast-import <<-INPUT_END
1356 commit refs/heads/N5D
1357 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1359 rename with invalid syntax
1362 from refs/heads/branch^0
1367 test_expect_success
'N: reject foo/ syntax in ls argument' '
1368 test_must_fail git fast-import <<-INPUT_END
1369 commit refs/heads/N5E
1370 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1372 copy with invalid syntax
1375 from refs/heads/branch^0
1380 test_expect_success
'N: copy to root by id and modify' '
1381 echo "hello, world" >expect.foo &&
1382 echo hello >expect.bar &&
1383 git fast-import <<-SETUP_END &&
1384 commit refs/heads/N7
1385 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1391 M 644 inline foo/bar
1397 tree=$(git rev-parse --verify N7:) &&
1398 git fast-import <<-INPUT_END &&
1399 commit refs/heads/N8
1400 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1402 copy to root by id and modify
1406 M 644 inline foo/foo
1411 git show N8:foo/foo >actual.foo &&
1412 git show N8:foo/bar >actual.bar &&
1413 test_cmp expect.foo actual.foo &&
1414 test_cmp expect.bar actual.bar
1417 test_expect_success
'N: extract subtree' '
1418 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1419 cat >input <<-INPUT_END &&
1420 commit refs/heads/N9
1421 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1423 extract subtree branch:newdir
1429 git fast-import <input &&
1430 git diff --exit-code branch:newdir N9
1433 test_expect_success
'N: modify subtree, extract it, and modify again' '
1434 echo hello >expect.baz &&
1435 echo hello, world >expect.qux &&
1436 git fast-import <<-SETUP_END &&
1437 commit refs/heads/N10
1438 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1444 M 644 inline foo/bar/baz
1450 tree=$(git rev-parse --verify N10:) &&
1451 git fast-import <<-INPUT_END &&
1452 commit refs/heads/N11
1453 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1455 copy to root by id and modify
1459 M 100644 inline foo/bar/qux
1464 C "bar/qux" "bar/quux"
1466 git show N11:bar/baz >actual.baz &&
1467 git show N11:bar/qux >actual.qux &&
1468 git show N11:bar/quux >actual.quux &&
1469 test_cmp expect.baz actual.baz &&
1470 test_cmp expect.qux actual.qux &&
1471 test_cmp expect.qux actual.quux'
1477 test_expect_success
'O: comments are all skipped' '
1478 cat >input <<-INPUT_END &&
1480 commit refs/heads/O1
1481 # -- ignore all of this text
1482 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1483 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1485 dirty directory copy
1488 # do not forget the import blank line!
1490 # yes, we started from our usual base of branch^0.
1492 from refs/heads/branch^0
1493 # and we need to reuse file2/file5 from N3 above.
1494 M 644 inline file2/file5
1495 # otherwise the tree will be different
1500 # do not forget to copy file2 to file3
1503 # or to delete file5 from file2.
1509 git fast-import <input &&
1510 test $(git rev-parse N3) = $(git rev-parse O1)
1513 test_expect_success
'O: blank lines not necessary after data commands' '
1514 cat >input <<-INPUT_END &&
1515 commit refs/heads/O2
1516 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1518 dirty directory copy
1520 from refs/heads/branch^0
1521 M 644 inline file2/file5
1530 git fast-import <input &&
1531 test $(git rev-parse N3) = $(git rev-parse O2)
1534 test_expect_success
'O: repack before next test' '
1538 test_expect_success
'O: blank lines not necessary after other commands' '
1539 cat >input <<-INPUT_END &&
1540 commit refs/heads/O3
1541 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1545 commit refs/heads/O3
1546 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1551 commit refs/heads/O3
1553 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1558 commit refs/heads/O3
1559 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1563 reset refs/tags/O3-2nd
1565 reset refs/tags/O3-3rd
1569 cat >expect <<-INPUT_END &&
1576 git fast-import <input &&
1577 test 8 = $(find .git/objects/pack -type f | wc -l) &&
1578 test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
1579 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1580 test_cmp expect actual
1583 test_expect_success
'O: progress outputs as requested by input' '
1584 cat >input <<-INPUT_END &&
1585 commit refs/heads/O4
1586 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1590 commit refs/heads/O4
1591 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1595 progress Two commits down, 2 to go!
1596 commit refs/heads/O4
1597 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1601 progress Three commits down, 1 to go!
1602 commit refs/heads/O4
1603 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1609 git fast-import <input >actual &&
1610 grep "progress " <input >expect &&
1611 test_cmp expect actual
1615 ### series P (gitlinks)
1618 test_expect_success
'P: superproject & submodule mix' '
1619 cat >input <<-INPUT_END &&
1625 reset refs/heads/sub
1626 commit refs/heads/sub
1628 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1641 commit refs/heads/subuse1
1643 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1646 from refs/heads/master
1647 M 100644 :3 .gitmodules
1656 commit refs/heads/sub
1658 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1664 commit refs/heads/subuse1
1666 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1674 git fast-import <input &&
1675 git checkout subuse1 &&
1681 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1684 git submodule init &&
1685 git submodule update
1688 test_expect_success
'P: verbatim SHA gitlinks' '
1689 SUBLAST=$(git rev-parse --verify sub) &&
1690 SUBPREV=$(git rev-parse --verify sub^) &&
1692 cat >input <<-INPUT_END &&
1701 commit refs/heads/subuse2
1703 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1706 from refs/heads/master
1707 M 100644 :1 .gitmodules
1708 M 160000 $SUBPREV sub
1710 commit refs/heads/subuse2
1712 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1716 M 160000 $SUBLAST sub
1720 git branch -D sub &&
1723 git fast-import <input &&
1724 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1727 test_expect_success
'P: fail on inline gitlink' '
1729 cat >input <<-INPUT_END &&
1730 commit refs/heads/subuse3
1732 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1737 from refs/heads/subuse2
1745 test_must_fail git fast-import <input
1748 test_expect_success
'P: fail on blob mark in gitlink' '
1750 cat >input <<-INPUT_END &&
1757 commit refs/heads/subuse3
1759 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1764 from refs/heads/subuse2
1769 test_must_fail git fast-import <input
1773 ### series Q (notes)
1776 test_expect_success
'Q: commit notes' '
1777 note1_data="The first note for the first commit" &&
1778 note2_data="The first note for the second commit" &&
1779 note3_data="The first note for the third commit" &&
1780 note1b_data="The second note for the first commit" &&
1781 note1c_data="The third note for the first commit" &&
1782 note2b_data="The second note for the second commit" &&
1785 cat >input <<-INPUT_END &&
1792 commit refs/heads/notes-test
1794 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1805 commit refs/heads/notes-test
1807 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1814 commit refs/heads/notes-test
1816 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1843 commit refs/notes/foobar
1845 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1857 commit refs/notes/foobar
1859 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1869 commit refs/notes/foobar2
1871 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1881 commit refs/notes/foobar
1883 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1896 git fast-import <input &&
1897 git whatchanged notes-test
1900 test_expect_success
'Q: verify pack' '
1904 test_expect_success
'Q: verify first commit' '
1905 commit1=$(git rev-parse notes-test~2) &&
1906 commit2=$(git rev-parse notes-test^) &&
1907 commit3=$(git rev-parse notes-test) &&
1909 cat >expect <<-EOF &&
1910 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1911 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1915 git cat-file commit notes-test~2 | sed 1d >actual &&
1916 test_cmp expect actual
1919 test_expect_success
'Q: verify second commit' '
1920 cat >expect <<-EOF &&
1922 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1923 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1927 git cat-file commit notes-test^ | sed 1d >actual &&
1928 test_cmp expect actual
1931 test_expect_success
'Q: verify third commit' '
1932 cat >expect <<-EOF &&
1934 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1935 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1939 git cat-file commit notes-test | sed 1d >actual &&
1940 test_cmp expect actual
1943 test_expect_success
'Q: verify first notes commit' '
1944 cat >expect <<-EOF &&
1945 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1946 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1950 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1951 test_cmp expect actual
1954 test_expect_success
'Q: verify first notes tree' '
1955 cat >expect.unsorted <<-EOF &&
1956 100644 blob $commit1
1957 100644 blob $commit2
1958 100644 blob $commit3
1960 cat expect.unsorted | sort >expect &&
1961 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1962 test_cmp expect actual
1965 test_expect_success
'Q: verify first note for first commit' '
1966 echo "$note1_data" >expect &&
1967 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1968 test_cmp expect actual
1971 test_expect_success
'Q: verify first note for second commit' '
1972 echo "$note2_data" >expect &&
1973 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1974 test_cmp expect actual
1977 test_expect_success
'Q: verify first note for third commit' '
1978 echo "$note3_data" >expect &&
1979 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
1980 test_cmp expect actual
1983 test_expect_success
'Q: verify second notes commit' '
1984 cat >expect <<-EOF &&
1985 parent $(git rev-parse --verify refs/notes/foobar~2)
1986 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1987 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1991 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1992 test_cmp expect actual
1995 test_expect_success
'Q: verify second notes tree' '
1996 cat >expect.unsorted <<-EOF &&
1997 100644 blob $commit1
1998 100644 blob $commit2
1999 100644 blob $commit3
2001 cat expect.unsorted | sort >expect &&
2002 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2003 test_cmp expect actual
2006 test_expect_success
'Q: verify second note for first commit' '
2007 echo "$note1b_data" >expect &&
2008 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
2009 test_cmp expect actual
2012 test_expect_success
'Q: verify first note for second commit' '
2013 echo "$note2_data" >expect &&
2014 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
2015 test_cmp expect actual
2018 test_expect_success
'Q: verify first note for third commit' '
2019 echo "$note3_data" >expect &&
2020 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2021 test_cmp expect actual
2024 test_expect_success
'Q: verify third notes commit' '
2025 cat >expect <<-EOF &&
2026 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2027 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2031 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2032 test_cmp expect actual
2035 test_expect_success
'Q: verify third notes tree' '
2036 cat >expect.unsorted <<-EOF &&
2037 100644 blob $commit1
2039 cat expect.unsorted | sort >expect &&
2040 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2041 test_cmp expect actual
2044 test_expect_success
'Q: verify third note for first commit' '
2045 echo "$note1c_data" >expect &&
2046 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2047 test_cmp expect actual
2050 test_expect_success
'Q: verify fourth notes commit' '
2051 cat >expect <<-EOF &&
2052 parent $(git rev-parse --verify refs/notes/foobar^)
2053 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2054 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2058 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2059 test_cmp expect actual
2062 test_expect_success
'Q: verify fourth notes tree' '
2063 cat >expect.unsorted <<-EOF &&
2064 100644 blob $commit2
2066 cat expect.unsorted | sort >expect &&
2067 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2068 test_cmp expect actual
2071 test_expect_success
'Q: verify second note for second commit' '
2072 echo "$note2b_data" >expect &&
2073 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2074 test_cmp expect actual
2077 test_expect_success
'Q: deny note on empty branch' '
2078 cat >input <<-EOF &&
2081 commit refs/heads/note-Q0
2082 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2084 Note for an empty branch.
2087 N inline refs/heads/Q0
2092 test_must_fail git fast-import <input
2095 ### series R (feature and option)
2098 test_expect_success
'R: abort on unsupported feature' '
2099 cat >input <<-EOF &&
2100 feature no-such-feature-exists
2103 test_must_fail git fast-import <input
2106 test_expect_success
'R: supported feature is accepted' '
2107 cat >input <<-EOF &&
2108 feature date-format=now
2111 git fast-import <input
2114 test_expect_success
'R: abort on receiving feature after data command' '
2115 cat >input <<-EOF &&
2119 feature date-format=now
2122 test_must_fail git fast-import <input
2125 test_expect_success
'R: only one import-marks feature allowed per stream' '
2126 cat >input <<-EOF &&
2127 feature import-marks=git.marks
2128 feature import-marks=git2.marks
2131 test_must_fail git fast-import <input
2134 test_expect_success
'R: export-marks feature results in a marks file being created' '
2135 cat >input <<-EOF &&
2136 feature export-marks=git.marks
2144 cat input | git fast-import &&
2148 test_expect_success
'R: export-marks options can be overridden by commandline options' '
2149 cat input | git fast-import --export-marks=other.marks &&
2153 test_expect_success
'R: catch typo in marks file name' '
2154 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2155 echo "feature import-marks=nonexistent.marks" |
2156 test_must_fail git fast-import
2159 test_expect_success
'R: import and output marks can be the same file' '
2161 blob=$(echo hi | git hash-object --stdin) &&
2162 cat >expect <<-EOF &&
2166 git fast-import --export-marks=io.marks <<-\EOF &&
2173 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2180 test_cmp expect io.marks
2183 test_expect_success
'R: --import-marks=foo --output-marks=foo to create foo fails' '
2185 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2194 test_expect_success
'R: --import-marks-if-exists' '
2196 blob=$(echo hi | git hash-object --stdin) &&
2197 echo ":1 $blob" >expect &&
2198 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2205 test_cmp expect io.marks
2208 test_expect_success
'R: feature import-marks-if-exists' '
2212 git fast-import --export-marks=io.marks <<-\EOF &&
2213 feature import-marks-if-exists=not_io.marks
2215 test_cmp expect io.marks &&
2217 blob=$(echo hi | git hash-object --stdin) &&
2219 echo ":1 $blob" >io.marks &&
2220 echo ":1 $blob" >expect &&
2221 echo ":2 $blob" >>expect &&
2223 git fast-import --export-marks=io.marks <<-\EOF &&
2224 feature import-marks-if-exists=io.marks
2231 test_cmp expect io.marks &&
2233 echo ":3 $blob" >>expect &&
2235 git fast-import --import-marks=io.marks \
2236 --export-marks=io.marks <<-\EOF &&
2237 feature import-marks-if-exists=not_io.marks
2244 test_cmp expect io.marks &&
2248 git fast-import --import-marks-if-exists=not_io.marks \
2249 --export-marks=io.marks <<-\EOF &&
2250 feature import-marks-if-exists=io.marks
2252 test_cmp expect io.marks
2255 test_expect_success
'R: import to output marks works without any content' '
2256 cat >input <<-EOF &&
2257 feature import-marks=marks.out
2258 feature export-marks=marks.new
2261 cat input | git fast-import &&
2262 test_cmp marks.out marks.new
2265 test_expect_success
'R: import marks prefers commandline marks file over the stream' '
2266 cat >input <<-EOF &&
2267 feature import-marks=nonexistent.marks
2268 feature export-marks=marks.new
2271 cat input | git fast-import --import-marks=marks.out &&
2272 test_cmp marks.out marks.new
2276 test_expect_success
'R: multiple --import-marks= should be honoured' '
2277 cat >input <<-EOF &&
2278 feature import-marks=nonexistent.marks
2279 feature export-marks=combined.marks
2282 head -n2 marks.out > one.marks &&
2283 tail -n +3 marks.out > two.marks &&
2284 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2285 test_cmp marks.out combined.marks
2288 test_expect_success
'R: feature relative-marks should be honoured' '
2289 cat >input <<-EOF &&
2290 feature relative-marks
2291 feature import-marks=relative.in
2292 feature export-marks=relative.out
2295 mkdir -p .git/info/fast-import/ &&
2296 cp marks.new .git/info/fast-import/relative.in &&
2297 git fast-import <input &&
2298 test_cmp marks.new .git/info/fast-import/relative.out
2301 test_expect_success
'R: feature no-relative-marks should be honoured' '
2302 cat >input <<-EOF &&
2303 feature relative-marks
2304 feature import-marks=relative.in
2305 feature no-relative-marks
2306 feature export-marks=non-relative.out
2309 git fast-import <input &&
2310 test_cmp marks.new non-relative.out
2313 test_expect_success
'R: feature ls supported' '
2318 test_expect_success
'R: feature cat-blob supported' '
2319 echo "feature cat-blob" |
2323 test_expect_success
'R: cat-blob-fd must be a nonnegative integer' '
2324 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2327 test_expect_success
!MINGW
'R: print old blob' '
2328 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2329 cat >expect <<-EOF &&
2334 echo "cat-blob $blob" |
2335 git fast-import --cat-blob-fd=6 6>actual &&
2336 test_cmp expect actual
2339 test_expect_success
!MINGW
'R: in-stream cat-blob-fd not respected' '
2340 echo hello >greeting &&
2341 blob=$(git hash-object -w greeting) &&
2342 cat >expect <<-EOF &&
2347 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2350 test_cmp expect actual.3 &&
2351 test_must_be_empty actual.1 &&
2352 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2353 option cat-blob-fd=3
2356 test_must_be_empty actual.3 &&
2357 test_cmp expect actual.1
2360 test_expect_success
!MINGW
'R: print mark for new blob' '
2361 echo "effluentish" | git hash-object --stdin >expect &&
2362 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2370 test_cmp expect actual
2373 test_expect_success
!MINGW
'R: print new blob' '
2374 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2375 cat >expect <<-EOF &&
2380 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2388 test_cmp expect actual
2391 test_expect_success
!MINGW
'R: print new blob by sha1' '
2392 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2393 cat >expect <<-EOF &&
2395 a new blob named by sha1
2398 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2401 a new blob named by sha1
2405 test_cmp expect actual
2408 test_expect_success
'setup: big file' '
2410 echo "the quick brown fox jumps over the lazy dog" >big &&
2413 cat big big big big >bigger &&
2414 cat bigger bigger bigger bigger >big ||
2420 test_expect_success
'R: print two blobs to stdout' '
2421 blob1=$(git hash-object big) &&
2422 blob1_len=$(wc -c <big) &&
2423 blob2=$(echo hello | git hash-object --stdin) &&
2425 echo ${blob1} blob $blob1_len &&
2435 cat <<-\END_PART1 &&
2452 git fast-import >actual &&
2453 test_cmp expect actual
2456 test_expect_success PIPE
'R: copy using cat-file' '
2457 expect_id=$(git hash-object big) &&
2458 expect_len=$(wc -c <big) &&
2459 echo $expect_id blob $expect_len >expect.response &&
2462 cat >frontend <<-\FRONTEND_END &&
2468 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2481 read blob_id type size <&3 &&
2482 echo "$blob_id $type $size" >response &&
2483 head_c $size >blob <&3 &&
2487 commit refs/heads/copied
2488 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2490 copy big file as file3
2498 git fast-import --cat-blob-fd=3 3>blobs &&
2499 git show copied:file3 >actual &&
2500 test_cmp expect.response response &&
2504 test_expect_success PIPE
'R: print blob mid-commit' '
2506 echo "A blob from _before_ the commit." >expect &&
2515 A blob from _before_ the commit.
2517 commit refs/heads/temporary
2518 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2525 read blob_id type size <&3 &&
2526 head_c $size >actual <&3 &&
2531 git fast-import --cat-blob-fd=3 3>blobs &&
2532 test_cmp expect actual
2535 test_expect_success PIPE
'R: print staged blob within commit' '
2537 echo "A blob from _within_ the commit." >expect &&
2543 commit refs/heads/within
2544 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2550 A blob from _within_ the commit.
2555 echo "A blob from _within_ the commit." |
2556 git hash-object --stdin
2558 echo "cat-blob $to_get" &&
2560 read blob_id type size <&3 &&
2561 head_c $size >actual <&3 &&
2566 git fast-import --cat-blob-fd=3 3>blobs &&
2567 test_cmp expect actual
2570 test_expect_success
'R: quiet option results in no stats being output' '
2571 cat >input <<-EOF &&
2579 cat input | git fast-import 2> output &&
2580 test_must_be_empty output
2583 test_expect_success
'R: feature done means terminating "done" is mandatory' '
2584 echo feature done | test_must_fail git fast-import &&
2585 test_must_fail git fast-import --done </dev/null
2588 test_expect_success
'R: terminating "done" with trailing gibberish is ok' '
2589 git fast-import <<-\EOF &&
2594 git fast-import <<-\EOF
2596 more trailing gibberish
2600 test_expect_success
'R: terminating "done" within commit' '
2601 cat >expect <<-\EOF &&
2603 :000000 100644 OBJID OBJID A hello.c
2604 :000000 100644 OBJID OBJID A hello2.c
2606 git fast-import <<-EOF &&
2607 commit refs/heads/done-ends
2608 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2610 Commit terminated by "done" command
2612 M 100644 inline hello.c
2619 git rev-list done-ends |
2620 git diff-tree -r --stdin --root --always |
2621 sed -e "s/$_x40/OBJID/g" >actual &&
2622 test_cmp expect actual
2625 test_expect_success
'R: die on unknown option' '
2626 cat >input <<-EOF &&
2627 option git non-existing-option
2630 test_must_fail git fast-import <input
2633 test_expect_success
'R: unknown commandline options are rejected' '\
2634 test_must_fail git fast-import --non-existing-option < /dev/null
2637 test_expect_success
'R: die on invalid option argument' '
2638 echo "option git active-branches=-5" |
2639 test_must_fail git fast-import &&
2640 echo "option git depth=" |
2641 test_must_fail git fast-import &&
2642 test_must_fail git fast-import --depth="5 elephants" </dev/null
2645 test_expect_success
'R: ignore non-git options' '
2646 cat >input <<-EOF &&
2647 option non-existing-vcs non-existing-option
2650 git fast-import <input
2653 test_expect_success
'R: corrupt lines do not mess marks file' '
2655 blob=$(echo hi | git hash-object --stdin) &&
2656 cat >expect <<-EOF &&
2657 :3 0000000000000000000000000000000000000000
2661 cp expect io.marks &&
2662 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2665 test_cmp expect io.marks
2669 ## R: very large blobs
2671 test_expect_success
'R: blob bigger than threshold' '
2672 blobsize=$((2*1024*1024 + 53)) &&
2673 test-genrandom bar $blobsize >expect &&
2674 cat >input <<-INPUT_END &&
2675 commit refs/heads/big-file
2676 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2684 cat expect >>input &&
2685 cat >>input <<-INPUT_END &&
2689 cat expect >>input &&
2692 test_create_repo R &&
2693 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2696 test_expect_success
'R: verify created pack' '
2699 verify_packs -v > ../verify
2703 test_expect_success
'R: verify written objects' '
2704 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2705 test_cmp_bin expect actual &&
2706 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2707 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2711 test_expect_success
'R: blob appears only once' '
2712 n=$(grep $a verify | wc -l) &&
2720 # Make sure missing spaces and EOLs after mark references
2729 # commit marks: 301, 302, 303, 304
2730 # blob marks: 403, 404, resp.
2733 # The error message when a space is missing not at the
2734 # end of the line is:
2736 # Missing space after ..
2738 # or when extra characters come after the mark at the end
2743 # or when the dataref is neither "inline " or a known SHA1,
2745 # Invalid dataref ..
2747 test_expect_success
'S: initialize for S tests' '
2750 cat >input <<-INPUT_END &&
2753 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2757 M 100644 inline hello.c
2764 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2769 M 100644 inline hello.c
2787 git fast-import --export-marks=marks <input
2791 # filemodify, three datarefs
2793 test_expect_success
'S: filemodify with garbage after mark must fail' '
2794 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2796 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2800 M 100644 :403x hello.c
2803 test_i18ngrep "space after mark" err
2806 # inline is misspelled; fast-import thinks it is some unknown dataref
2807 test_expect_success
'S: filemodify with garbage after inline must fail' '
2808 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2814 M 100644 inlineX hello.c
2820 test_i18ngrep "nvalid dataref" err
2823 test_expect_success
'S: filemodify with garbage after sha1 must fail' '
2824 sha1=$(grep :403 marks | cut -d\ -f2) &&
2825 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2827 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2831 M 100644 ${sha1}x hello.c
2834 test_i18ngrep "space after SHA1" err
2838 # notemodify, three ways to say dataref
2840 test_expect_success
'S: notemodify with garabge after mark dataref must fail' '
2841 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2843 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2845 commit S note dataref markref
2850 test_i18ngrep "space after mark" err
2853 test_expect_success
'S: notemodify with garbage after inline dataref must fail' '
2854 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2856 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2858 commit S note dataref inline
2866 test_i18ngrep "nvalid dataref" err
2869 test_expect_success
'S: notemodify with garbage after sha1 dataref must fail' '
2870 sha1=$(grep :202 marks | cut -d\ -f2) &&
2871 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2873 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2875 commit S note dataref sha1
2880 test_i18ngrep "space after SHA1" err
2884 # notemodify, mark in commit-ish
2886 test_expect_success
'S: notemodify with garbage after mark commit-ish must fail' '
2887 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2888 commit refs/heads/Snotes
2889 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2891 commit S note commit-ish
2896 test_i18ngrep "after mark" err
2902 test_expect_success
'S: from with garbage after mark must fail' '
2904 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2905 commit refs/heads/S2
2907 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2912 M 100644 :403 hello.c
2916 # go create the commit, need it for merge test
2917 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2918 commit refs/heads/S2
2920 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2925 M 100644 :403 hello.c
2928 # now evaluate the error
2930 test_i18ngrep "after mark" err
2937 test_expect_success
'S: merge with garbage after mark must fail' '
2938 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2941 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2947 M 100644 :403 hello.c
2950 test_i18ngrep "after mark" err
2956 test_expect_success
'S: tag with garbage after mark must fail' '
2957 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2960 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2966 test_i18ngrep "after mark" err
2972 test_expect_success
'S: cat-blob with garbage after mark must fail' '
2973 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2977 test_i18ngrep "after mark" err
2983 test_expect_success
'S: ls with garbage after mark must fail' '
2984 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2988 test_i18ngrep "space after mark" err
2991 test_expect_success
'S: ls with garbage after sha1 must fail' '
2992 sha1=$(grep :302 marks | cut -d\ -f2) &&
2993 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2997 test_i18ngrep "space after tree-ish" err
3003 # Setup is carried over from series S.
3005 test_expect_success
'T: ls root tree' '
3006 sed -e "s/Z\$//" >expect <<-EOF &&
3007 040000 tree $(git rev-parse S^{tree}) Z
3009 sha1=$(git rev-parse --verify S) &&
3010 git fast-import --import-marks=marks <<-EOF >actual &&
3013 test_cmp expect actual
3016 test_expect_success
'T: delete branch' '
3017 git branch to-delete &&
3018 git fast-import <<-EOF &&
3019 reset refs/heads/to-delete
3020 from 0000000000000000000000000000000000000000
3022 test_must_fail git rev-parse --verify refs/heads/to-delete
3025 test_expect_success
'T: empty reset doesnt delete branch' '
3026 git branch not-to-delete &&
3027 git fast-import <<-EOF &&
3028 reset refs/heads/not-to-delete
3031 git rev-parse --verify refs/heads/not-to-delete
3035 ### series U (filedelete)
3038 test_expect_success
'U: initialize for U tests' '
3039 cat >input <<-INPUT_END &&
3041 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3045 M 100644 inline hello.c
3049 M 100644 inline good/night.txt
3053 M 100644 inline good/bye.txt
3060 git fast-import <input
3063 test_expect_success
'U: filedelete file succeeds' '
3064 cat >input <<-INPUT_END &&
3066 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3068 delete good/night.txt
3075 git fast-import <input
3078 test_expect_success
'U: validate file delete result' '
3079 cat >expect <<-EOF &&
3080 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3083 git diff-tree -M -r U^1 U >actual &&
3085 compare_diff_raw expect actual
3088 test_expect_success
'U: filedelete directory succeeds' '
3089 cat >input <<-INPUT_END &&
3091 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3100 git fast-import <input
3103 test_expect_success
'U: validate directory delete result' '
3104 cat >expect <<-EOF &&
3105 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3108 git diff-tree -M -r U^1 U >actual &&
3110 compare_diff_raw expect actual
3113 test_expect_success
'U: filedelete root succeeds' '
3114 cat >input <<-INPUT_END &&
3116 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3125 git fast-import <input
3128 test_expect_success
'U: validate root delete result' '
3129 cat >expect <<-EOF &&
3130 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3133 git diff-tree -M -r U^1 U >actual &&
3135 compare_diff_raw expect actual