Skip tests that fail due to incomplete implementations, missing tools...
[git/mingw/j6t.git] / t / t9300-fast-import.sh
blob236efbdbf80f6fcd678a234a84192a3f4e3828a7
1 #!/bin/sh
3 # Copyright (c) 2007 Shawn Pearce
6 test_description='test git fast-import utility'
7 . ./test-lib.sh
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.
14 head_c () {
15 perl -e '
16 my $len = $ARGV[1];
17 while ($len > 0) {
18 my $s;
19 my $nread = sysread(STDIN, $s, $len);
20 die "cannot read: $!" unless defined($nread);
21 print $s;
22 $len -= $nread;
24 ' - "$1"
27 verify_packs () {
28 for p in .git/objects/pack/*.pack
30 git verify-pack "$@" "$p" || return
31 done
34 file2_data='file2
35 second line of EOF'
37 file3_data='EOF
38 in 3rd file
39 END'
41 file4_data=abcd
42 file4_len=4
44 file5_data='an inline file.
45 we should see it later.'
47 file6_data='#!/bin/sh
48 echo "$@"'
50 ###
51 ### series A
52 ###
54 test_expect_success 'empty stream succeeds' '
55 git fast-import </dev/null
58 test_expect_success 'A: create pack from stdin' '
59 test_tick &&
60 cat >input <<-INPUT_END &&
61 blob
62 mark :2
63 data <<EOF
64 $file2_data
65 EOF
67 blob
68 mark :3
69 data <<END
70 $file3_data
71 END
73 blob
74 mark :4
75 data $file4_len
76 $file4_data
77 commit refs/heads/master
78 mark :5
79 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
80 data <<COMMIT
81 initial
82 COMMIT
84 M 644 :2 file2
85 M 644 :3 file3
86 M 755 :4 file4
88 tag series-A
89 from :5
90 data <<EOF
91 An annotated tag without a tagger
92 EOF
94 tag series-A-blob
95 from :3
96 data <<EOF
97 An annotated tag that annotates a blob.
98 EOF
100 INPUT_END
101 git fast-import --export-marks=marks.out <input &&
102 git whatchanged master
105 test_expect_success 'A: verify pack' '
106 verify_packs
109 test_expect_success 'A: verify commit' '
110 cat >expect <<-EOF &&
111 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
112 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
114 initial
116 git cat-file commit master | sed 1d >actual &&
117 test_cmp expect actual
120 test_expect_success 'A: verify tree' '
121 cat >expect <<-\EOF &&
122 100644 blob file2
123 100644 blob file3
124 100755 blob file4
126 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
127 test_cmp expect actual
130 test_expect_success 'A: verify file2' '
131 echo "$file2_data" >expect &&
132 git cat-file blob master:file2 >actual &&
133 test_cmp expect actual
136 test_expect_success 'A: verify file3' '
137 echo "$file3_data" >expect &&
138 git cat-file blob master:file3 >actual &&
139 test_cmp expect actual
142 test_expect_success 'A: verify file4' '
143 printf "$file4_data" >expect &&
144 git cat-file blob master:file4 >actual &&
145 test_cmp expect actual
148 test_expect_success 'A: verify tag/series-A' '
149 cat >expect <<-EOF &&
150 object $(git rev-parse refs/heads/master)
151 type commit
152 tag series-A
154 An annotated tag without a tagger
156 git cat-file tag tags/series-A >actual &&
157 test_cmp expect actual
160 test_expect_success 'A: verify tag/series-A-blob' '
161 cat >expect <<-EOF &&
162 object $(git rev-parse refs/heads/master:file3)
163 type blob
164 tag series-A-blob
166 An annotated tag that annotates a blob.
168 git cat-file tag tags/series-A-blob >actual &&
169 test_cmp expect actual
172 test_expect_success 'A: verify marks output' '
173 cat >expect <<-EOF &&
174 :2 `git rev-parse --verify master:file2`
175 :3 `git rev-parse --verify master:file3`
176 :4 `git rev-parse --verify master:file4`
177 :5 `git rev-parse --verify master^0`
179 test_cmp expect marks.out
182 test_expect_success 'A: verify marks import' '
183 git fast-import \
184 --import-marks=marks.out \
185 --export-marks=marks.new \
186 </dev/null &&
187 test_cmp expect marks.new
190 test_expect_success 'A: tag blob by sha1' '
191 test_tick &&
192 new_blob=$(echo testing | git hash-object --stdin) &&
193 cat >input <<-INPUT_END &&
194 tag series-A-blob-2
195 from $(git rev-parse refs/heads/master:file3)
196 data <<EOF
197 Tag blob by sha1.
200 blob
201 mark :6
202 data <<EOF
203 testing
206 commit refs/heads/new_blob
207 committer <> 0 +0000
208 data 0
209 M 644 :6 new_blob
210 #pretend we got sha1 from fast-import
211 ls "new_blob"
213 tag series-A-blob-3
214 from $new_blob
215 data <<EOF
216 Tag new_blob.
218 INPUT_END
220 cat >expect <<-EOF &&
221 object $(git rev-parse refs/heads/master:file3)
222 type blob
223 tag series-A-blob-2
225 Tag blob by sha1.
226 object $new_blob
227 type blob
228 tag series-A-blob-3
230 Tag new_blob.
233 git fast-import <input &&
234 git cat-file tag tags/series-A-blob-2 >actual &&
235 git cat-file tag tags/series-A-blob-3 >>actual &&
236 test_cmp expect actual
239 test_expect_success 'A: verify marks import does not crash' '
240 test_tick &&
241 cat >input <<-INPUT_END &&
242 commit refs/heads/verify--import-marks
243 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
244 data <<COMMIT
245 recreate from :5
246 COMMIT
248 from :5
249 M 755 :2 copy-of-file2
251 INPUT_END
253 git fast-import --import-marks=marks.out <input &&
254 git whatchanged verify--import-marks
257 test_expect_success 'A: verify pack' '
258 verify_packs
261 test_expect_success 'A: verify diff' '
262 cat >expect <<-\EOF &&
263 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
265 git diff-tree -M -r master verify--import-marks >actual &&
266 compare_diff_raw expect actual &&
267 test `git rev-parse --verify master:file2` \
268 = `git rev-parse --verify verify--import-marks:copy-of-file2`
271 test_expect_success 'A: export marks with large values' '
272 test_tick &&
273 mt=$(git hash-object --stdin < /dev/null) &&
274 >input.blob &&
275 >marks.exp &&
276 >tree.exp &&
278 cat >input.commit <<-EOF &&
279 commit refs/heads/verify--dump-marks
280 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
281 data <<COMMIT
282 test the sparse array dumping routines with exponentially growing marks
283 COMMIT
286 i=0 l=4 m=6 n=7 &&
287 while test "$i" -lt 27
289 cat >>input.blob <<-EOF &&
290 blob
291 mark :$l
292 data 0
293 blob
294 mark :$m
295 data 0
296 blob
297 mark :$n
298 data 0
300 echo "M 100644 :$l l$i" >>input.commit &&
301 echo "M 100644 :$m m$i" >>input.commit &&
302 echo "M 100644 :$n n$i" >>input.commit &&
304 echo ":$l $mt" >>marks.exp &&
305 echo ":$m $mt" >>marks.exp &&
306 echo ":$n $mt" >>marks.exp &&
308 printf "100644 blob $mt\tl$i\n" >>tree.exp &&
309 printf "100644 blob $mt\tm$i\n" >>tree.exp &&
310 printf "100644 blob $mt\tn$i\n" >>tree.exp &&
312 l=$(($l + $l)) &&
313 m=$(($m + $m)) &&
314 n=$(($l + $n)) &&
316 i=$((1 + $i)) || return 1
317 done &&
319 sort tree.exp > tree.exp_s &&
321 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
322 git ls-tree refs/heads/verify--dump-marks >tree.out &&
323 test_cmp tree.exp_s tree.out &&
324 test_cmp marks.exp marks.large
328 ### series B
331 test_expect_success 'B: fail on invalid blob sha1' '
332 test_tick &&
333 cat >input <<-INPUT_END &&
334 commit refs/heads/branch
335 mark :1
336 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
337 data <<COMMIT
338 corrupt
339 COMMIT
341 from refs/heads/master
342 M 755 0000000000000000000000000000000000000001 zero1
344 INPUT_END
346 test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
347 test_must_fail git fast-import <input
350 test_expect_success 'B: accept branch name "TEMP_TAG"' '
351 cat >input <<-INPUT_END &&
352 commit TEMP_TAG
353 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
354 data <<COMMIT
355 tag base
356 COMMIT
358 from refs/heads/master
360 INPUT_END
362 test_when_finished "rm -f .git/TEMP_TAG
363 git gc
364 git prune" &&
365 git fast-import <input &&
366 test -f .git/TEMP_TAG &&
367 test `git rev-parse master` = `git rev-parse TEMP_TAG^`
370 test_expect_success 'B: accept empty committer' '
371 cat >input <<-INPUT_END &&
372 commit refs/heads/empty-committer-1
373 committer <> $GIT_COMMITTER_DATE
374 data <<COMMIT
375 empty commit
376 COMMIT
377 INPUT_END
379 test_when_finished "git update-ref -d refs/heads/empty-committer-1
380 git gc
381 git prune" &&
382 git fast-import <input &&
383 out=$(git fsck) &&
384 echo "$out" &&
385 test -z "$out"
388 test_expect_success 'B: accept and fixup committer with no name' '
389 cat >input <<-INPUT_END &&
390 commit refs/heads/empty-committer-2
391 committer <a@b.com> $GIT_COMMITTER_DATE
392 data <<COMMIT
393 empty commit
394 COMMIT
395 INPUT_END
397 test_when_finished "git update-ref -d refs/heads/empty-committer-2
398 git gc
399 git prune" &&
400 git fast-import <input &&
401 out=$(git fsck) &&
402 echo "$out" &&
403 test -z "$out"
406 test_expect_success 'B: fail on invalid committer (1)' '
407 cat >input <<-INPUT_END &&
408 commit refs/heads/invalid-committer
409 committer Name email> $GIT_COMMITTER_DATE
410 data <<COMMIT
411 empty commit
412 COMMIT
413 INPUT_END
415 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
416 test_must_fail git fast-import <input
419 test_expect_success 'B: fail on invalid committer (2)' '
420 cat >input <<-INPUT_END &&
421 commit refs/heads/invalid-committer
422 committer Name <e<mail> $GIT_COMMITTER_DATE
423 data <<COMMIT
424 empty commit
425 COMMIT
426 INPUT_END
428 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
429 test_must_fail git fast-import <input
432 test_expect_success 'B: fail on invalid committer (3)' '
433 cat >input <<-INPUT_END &&
434 commit refs/heads/invalid-committer
435 committer Name <email>> $GIT_COMMITTER_DATE
436 data <<COMMIT
437 empty commit
438 COMMIT
439 INPUT_END
441 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
442 test_must_fail git fast-import <input
445 test_expect_success 'B: fail on invalid committer (4)' '
446 cat >input <<-INPUT_END &&
447 commit refs/heads/invalid-committer
448 committer Name <email $GIT_COMMITTER_DATE
449 data <<COMMIT
450 empty commit
451 COMMIT
452 INPUT_END
454 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
455 test_must_fail git fast-import <input
458 test_expect_success 'B: fail on invalid committer (5)' '
459 cat >input <<-INPUT_END &&
460 commit refs/heads/invalid-committer
461 committer Name<email> $GIT_COMMITTER_DATE
462 data <<COMMIT
463 empty commit
464 COMMIT
465 INPUT_END
467 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
468 test_must_fail git fast-import <input
472 ### series C
475 test_expect_success 'C: incremental import create pack from stdin' '
476 newf=`echo hi newf | git hash-object -w --stdin` &&
477 oldf=`git rev-parse --verify master:file2` &&
478 test_tick &&
479 cat >input <<-INPUT_END &&
480 commit refs/heads/branch
481 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
482 data <<COMMIT
483 second
484 COMMIT
486 from refs/heads/master
487 M 644 $oldf file2/oldf
488 M 755 $newf file2/newf
489 D file3
491 INPUT_END
493 git fast-import <input &&
494 git whatchanged branch
497 test_expect_success 'C: verify pack' '
498 verify_packs
501 test_expect_success 'C: validate reuse existing blob' '
502 test $newf = `git rev-parse --verify branch:file2/newf` &&
503 test $oldf = `git rev-parse --verify branch:file2/oldf`
506 test_expect_success 'C: verify commit' '
507 cat >expect <<-EOF &&
508 parent `git rev-parse --verify master^0`
509 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
510 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
512 second
515 git cat-file commit branch | sed 1d >actual &&
516 test_cmp expect actual
519 test_expect_success 'C: validate rename result' '
520 cat >expect <<-\EOF &&
521 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
522 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
523 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
525 git diff-tree -M -r master branch >actual &&
526 compare_diff_raw expect actual
530 ### series D
533 test_expect_success 'D: inline data in commit' '
534 test_tick &&
535 cat >input <<-INPUT_END &&
536 commit refs/heads/branch
537 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
538 data <<COMMIT
539 third
540 COMMIT
542 from refs/heads/branch^0
543 M 644 inline newdir/interesting
544 data <<EOF
545 $file5_data
548 M 755 inline newdir/exec.sh
549 data <<EOF
550 $file6_data
553 INPUT_END
555 git fast-import <input &&
556 git whatchanged branch
559 test_expect_success 'D: verify pack' '
560 verify_packs
563 test_expect_success 'D: validate new files added' '
564 cat >expect <<-\EOF &&
565 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
566 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
568 git diff-tree -M -r branch^ branch >actual &&
569 compare_diff_raw expect actual
572 test_expect_success 'D: verify file5' '
573 echo "$file5_data" >expect &&
574 git cat-file blob branch:newdir/interesting >actual &&
575 test_cmp expect actual
578 test_expect_success 'D: verify file6' '
579 echo "$file6_data" >expect &&
580 git cat-file blob branch:newdir/exec.sh >actual &&
581 test_cmp expect actual
585 ### series E
588 test_expect_success 'E: rfc2822 date, --date-format=raw' '
589 cat >input <<-INPUT_END &&
590 commit refs/heads/branch
591 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
592 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
593 data <<COMMIT
594 RFC 2822 type date
595 COMMIT
597 from refs/heads/branch^0
599 INPUT_END
601 test_must_fail git fast-import --date-format=raw <input
603 test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
604 git fast-import --date-format=rfc2822 <input
607 test_expect_success 'E: verify pack' '
608 verify_packs
611 test_expect_success 'E: verify commit' '
612 cat >expect <<-EOF &&
613 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
614 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
616 RFC 2822 type date
618 git cat-file commit branch | sed 1,2d >actual &&
619 test_cmp expect actual
623 ### series F
626 test_expect_success 'F: non-fast-forward update skips' '
627 old_branch=`git rev-parse --verify branch^0` &&
628 test_tick &&
629 cat >input <<-INPUT_END &&
630 commit refs/heads/branch
631 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
632 data <<COMMIT
633 losing things already?
634 COMMIT
636 from refs/heads/branch~1
638 reset refs/heads/other
639 from refs/heads/branch
641 INPUT_END
643 test_must_fail git fast-import <input &&
644 # branch must remain unaffected
645 test $old_branch = `git rev-parse --verify branch^0`
648 test_expect_success 'F: verify pack' '
649 verify_packs
652 test_expect_success 'F: verify other commit' '
653 cat >expect <<-EOF &&
654 tree `git rev-parse branch~1^{tree}`
655 parent `git rev-parse branch~1`
656 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
657 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
659 losing things already?
661 git cat-file commit other >actual &&
662 test_cmp expect actual
666 ### series G
669 old_branch=`git rev-parse --verify branch^0`
670 test_tick
671 cat >input <<INPUT_END
672 commit refs/heads/branch
673 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
674 data <<COMMIT
675 losing things already?
676 COMMIT
678 from refs/heads/branch~1
680 INPUT_END
681 test_expect_success 'G: non-fast-forward update forced' '
682 git fast-import --force <input
685 test_expect_success 'G: verify pack' '
686 verify_packs
689 test_expect_success 'G: branch changed, but logged' '
690 test $old_branch != `git rev-parse --verify branch^0` &&
691 test $old_branch = `git rev-parse --verify branch@{1}`
695 ### series H
698 test_tick
699 cat >input <<INPUT_END
700 commit refs/heads/H
701 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
702 data <<COMMIT
703 third
704 COMMIT
706 from refs/heads/branch^0
707 M 644 inline i-will-die
708 data <<EOF
709 this file will never exist.
712 deleteall
713 M 644 inline h/e/l/lo
714 data <<EOF
715 $file5_data
718 INPUT_END
719 test_expect_success 'H: deletall, add 1' '
720 git fast-import <input &&
721 git whatchanged H
724 test_expect_success 'H: verify pack' '
725 verify_packs
728 cat >expect <<EOF
729 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
730 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
731 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
732 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
733 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
735 git diff-tree -M -r H^ H >actual
736 test_expect_success 'H: validate old files removed, new files added' '
737 compare_diff_raw expect actual
740 echo "$file5_data" >expect
741 test_expect_success 'H: verify file' '
742 git cat-file blob H:h/e/l/lo >actual &&
743 test_cmp expect actual
747 ### series I
750 cat >input <<INPUT_END
751 commit refs/heads/export-boundary
752 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
753 data <<COMMIT
754 we have a border. its only 40 characters wide.
755 COMMIT
757 from refs/heads/branch
759 INPUT_END
760 test_expect_success 'I: export-pack-edges' '
761 git fast-import --export-pack-edges=edges.list <input
764 cat >expect <<EOF
765 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
767 test_expect_success 'I: verify edge list' '
768 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
769 test_cmp expect actual
773 ### series J
776 cat >input <<INPUT_END
777 commit refs/heads/J
778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
779 data <<COMMIT
780 create J
781 COMMIT
783 from refs/heads/branch
785 reset refs/heads/J
787 commit refs/heads/J
788 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
789 data <<COMMIT
790 initialize J
791 COMMIT
793 INPUT_END
794 test_expect_success 'J: reset existing branch creates empty commit' '
795 git fast-import <input
797 test_expect_success 'J: branch has 1 commit, empty tree' '
798 test 1 = `git rev-list J | wc -l` &&
799 test 0 = `git ls-tree J | wc -l`
802 cat >input <<INPUT_END
803 reset refs/heads/J2
805 tag wrong_tag
806 from refs/heads/J2
807 data <<EOF
808 Tag branch that was reset.
810 INPUT_END
811 test_expect_success 'J: tag must fail on empty branch' '
812 test_must_fail git fast-import <input
815 ### series K
818 cat >input <<INPUT_END
819 commit refs/heads/K
820 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
821 data <<COMMIT
822 create K
823 COMMIT
825 from refs/heads/branch
827 commit refs/heads/K
828 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
829 data <<COMMIT
830 redo K
831 COMMIT
833 from refs/heads/branch^1
835 INPUT_END
836 test_expect_success 'K: reinit branch with from' '
837 git fast-import <input
839 test_expect_success 'K: verify K^1 = branch^1' '
840 test `git rev-parse --verify branch^1` \
841 = `git rev-parse --verify K^1`
845 ### series L
848 cat >input <<INPUT_END
849 blob
850 mark :1
851 data <<EOF
852 some data
855 blob
856 mark :2
857 data <<EOF
858 other data
861 commit refs/heads/L
862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
863 data <<COMMIT
864 create L
865 COMMIT
867 M 644 :1 b.
868 M 644 :1 b/other
869 M 644 :1 ba
871 commit refs/heads/L
872 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
873 data <<COMMIT
874 update L
875 COMMIT
877 M 644 :2 b.
878 M 644 :2 b/other
879 M 644 :2 ba
880 INPUT_END
882 cat >expect <<EXPECT_END
883 :100644 100644 4268632... 55d3a52... M b.
884 :040000 040000 0ae5cac... 443c768... M b
885 :100644 100644 4268632... 55d3a52... M ba
886 EXPECT_END
888 test_expect_success 'L: verify internal tree sorting' '
889 git fast-import <input &&
890 git diff-tree --abbrev --raw L^ L >output &&
891 test_cmp expect output
894 cat >input <<INPUT_END
895 blob
896 mark :1
897 data <<EOF
898 the data
901 commit refs/heads/L2
902 committer C O Mitter <committer@example.com> 1112912473 -0700
903 data <<COMMIT
904 init L2
905 COMMIT
906 M 644 :1 a/b/c
907 M 644 :1 a/b/d
908 M 644 :1 a/e/f
910 commit refs/heads/L2
911 committer C O Mitter <committer@example.com> 1112912473 -0700
912 data <<COMMIT
913 update L2
914 COMMIT
915 C a g
916 C a/e g/b
917 M 644 :1 g/b/h
918 INPUT_END
920 cat <<EOF >expect
921 g/b/f
922 g/b/h
925 test_expect_success 'L: nested tree copy does not corrupt deltas' '
926 test_when_finished "git update-ref -d refs/heads/L2" &&
927 git fast-import <input &&
928 git ls-tree L2 g/b/ >tmp &&
929 cat tmp | cut -f 2 >actual &&
930 test_cmp expect actual &&
931 git fsck `git rev-parse L2`
935 ### series M
938 test_tick
939 cat >input <<INPUT_END
940 commit refs/heads/M1
941 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
942 data <<COMMIT
943 file rename
944 COMMIT
946 from refs/heads/branch^0
947 R file2/newf file2/n.e.w.f
949 INPUT_END
951 cat >expect <<EOF
952 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
954 test_expect_success 'M: rename file in same subdirectory' '
955 git fast-import <input &&
956 git diff-tree -M -r M1^ M1 >actual &&
957 compare_diff_raw expect actual
960 cat >input <<INPUT_END
961 commit refs/heads/M2
962 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
963 data <<COMMIT
964 file rename
965 COMMIT
967 from refs/heads/branch^0
968 R file2/newf i/am/new/to/you
970 INPUT_END
972 cat >expect <<EOF
973 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
975 test_expect_success 'M: rename file to new subdirectory' '
976 git fast-import <input &&
977 git diff-tree -M -r M2^ M2 >actual &&
978 compare_diff_raw expect actual
981 cat >input <<INPUT_END
982 commit refs/heads/M3
983 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
984 data <<COMMIT
985 file rename
986 COMMIT
988 from refs/heads/M2^0
989 R i other/sub
991 INPUT_END
993 cat >expect <<EOF
994 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
996 test_expect_success 'M: rename subdirectory to new subdirectory' '
997 git fast-import <input &&
998 git diff-tree -M -r M3^ M3 >actual &&
999 compare_diff_raw expect actual
1002 cat >input <<INPUT_END
1003 commit refs/heads/M4
1004 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1005 data <<COMMIT
1006 rename root
1007 COMMIT
1009 from refs/heads/M2^0
1010 R "" sub
1012 INPUT_END
1014 cat >expect <<EOF
1015 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1016 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1017 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1018 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1019 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1021 test_expect_success 'M: rename root to subdirectory' '
1022 git fast-import <input &&
1023 git diff-tree -M -r M4^ M4 >actual &&
1024 cat actual &&
1025 compare_diff_raw expect actual
1029 ### series N
1032 test_tick
1033 cat >input <<INPUT_END
1034 commit refs/heads/N1
1035 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1036 data <<COMMIT
1037 file copy
1038 COMMIT
1040 from refs/heads/branch^0
1041 C file2/newf file2/n.e.w.f
1043 INPUT_END
1045 cat >expect <<EOF
1046 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1048 test_expect_success 'N: copy file in same subdirectory' '
1049 git fast-import <input &&
1050 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1051 compare_diff_raw expect actual
1054 cat >input <<INPUT_END
1055 commit refs/heads/N2
1056 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1057 data <<COMMIT
1058 clean directory copy
1059 COMMIT
1061 from refs/heads/branch^0
1062 C file2 file3
1064 commit refs/heads/N2
1065 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1066 data <<COMMIT
1067 modify directory copy
1068 COMMIT
1070 M 644 inline file3/file5
1071 data <<EOF
1072 $file5_data
1075 INPUT_END
1077 cat >expect <<EOF
1078 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1079 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1080 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1082 test_expect_success 'N: copy then modify subdirectory' '
1083 git fast-import <input &&
1084 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1085 compare_diff_raw expect actual
1088 cat >input <<INPUT_END
1089 commit refs/heads/N3
1090 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1091 data <<COMMIT
1092 dirty directory copy
1093 COMMIT
1095 from refs/heads/branch^0
1096 M 644 inline file2/file5
1097 data <<EOF
1098 $file5_data
1101 C file2 file3
1102 D file2/file5
1104 INPUT_END
1106 test_expect_success 'N: copy dirty subdirectory' '
1107 git fast-import <input &&
1108 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`
1111 test_expect_success 'N: copy directory by id' '
1112 cat >expect <<-\EOF &&
1113 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1114 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1116 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1117 cat >input <<-INPUT_END &&
1118 commit refs/heads/N4
1119 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1120 data <<COMMIT
1121 copy by tree hash
1122 COMMIT
1124 from refs/heads/branch^0
1125 M 040000 $subdir file3
1126 INPUT_END
1127 git fast-import <input &&
1128 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1129 compare_diff_raw expect actual
1132 test_expect_success PIPE 'N: read and copy directory' '
1133 cat >expect <<-\EOF &&
1134 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1135 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1137 git update-ref -d refs/heads/N4 &&
1138 rm -f backflow &&
1139 mkfifo backflow &&
1141 exec <backflow &&
1142 cat <<-EOF &&
1143 commit refs/heads/N4
1144 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1145 data <<COMMIT
1146 copy by tree hash, part 2
1147 COMMIT
1149 from refs/heads/branch^0
1150 ls "file2"
1152 read mode type tree filename &&
1153 echo "M 040000 $tree file3"
1155 git fast-import --cat-blob-fd=3 3>backflow &&
1156 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1157 compare_diff_raw expect actual
1160 test_expect_success PIPE 'N: empty directory reads as missing' '
1161 cat <<-\EOF >expect &&
1162 OBJNAME
1163 :000000 100644 OBJNAME OBJNAME A unrelated
1165 echo "missing src" >expect.response &&
1166 git update-ref -d refs/heads/read-empty &&
1167 rm -f backflow &&
1168 mkfifo backflow &&
1170 exec <backflow &&
1171 cat <<-EOF &&
1172 commit refs/heads/read-empty
1173 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1174 data <<COMMIT
1175 read "empty" (missing) directory
1176 COMMIT
1178 M 100644 inline src/greeting
1179 data <<BLOB
1180 hello
1181 BLOB
1182 C src/greeting dst1/non-greeting
1183 C src/greeting unrelated
1184 # leave behind "empty" src directory
1185 D src/greeting
1186 ls "src"
1188 read -r line &&
1189 printf "%s\n" "$line" >response &&
1190 cat <<-\EOF
1191 D dst1
1192 D dst2
1195 git fast-import --cat-blob-fd=3 3>backflow &&
1196 test_cmp expect.response response &&
1197 git rev-list read-empty |
1198 git diff-tree -r --root --stdin |
1199 sed "s/$_x40/OBJNAME/g" >actual &&
1200 test_cmp expect actual
1203 test_expect_success 'N: copy root directory by tree hash' '
1204 cat >expect <<-\EOF &&
1205 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1206 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1208 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1209 cat >input <<-INPUT_END &&
1210 commit refs/heads/N6
1211 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1212 data <<COMMIT
1213 copy root directory by tree hash
1214 COMMIT
1216 from refs/heads/branch^0
1217 M 040000 $root ""
1218 INPUT_END
1219 git fast-import <input &&
1220 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1221 compare_diff_raw expect actual
1224 test_expect_success 'N: copy root by path' '
1225 cat >expect <<-\EOF &&
1226 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1227 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1228 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1229 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1230 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1232 cat >input <<-INPUT_END &&
1233 commit refs/heads/N-copy-root-path
1234 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1235 data <<COMMIT
1236 copy root directory by (empty) path
1237 COMMIT
1239 from refs/heads/branch^0
1240 C "" oldroot
1241 INPUT_END
1242 git fast-import <input &&
1243 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1244 compare_diff_raw expect actual
1247 test_expect_success 'N: delete directory by copying' '
1248 cat >expect <<-\EOF &&
1249 OBJID
1250 :100644 000000 OBJID OBJID D foo/bar/qux
1251 OBJID
1252 :000000 100644 OBJID OBJID A foo/bar/baz
1253 :000000 100644 OBJID OBJID A foo/bar/qux
1255 empty_tree=$(git mktree </dev/null) &&
1256 cat >input <<-INPUT_END &&
1257 commit refs/heads/N-delete
1258 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1259 data <<COMMIT
1260 collect data to be deleted
1261 COMMIT
1263 deleteall
1264 M 100644 inline foo/bar/baz
1265 data <<DATA_END
1266 hello
1267 DATA_END
1268 C "foo/bar/baz" "foo/bar/qux"
1269 C "foo/bar/baz" "foo/bar/quux/1"
1270 C "foo/bar/baz" "foo/bar/quuux"
1271 M 040000 $empty_tree foo/bar/quux
1272 M 040000 $empty_tree foo/bar/quuux
1274 commit refs/heads/N-delete
1275 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1276 data <<COMMIT
1277 delete subdirectory
1278 COMMIT
1280 M 040000 $empty_tree foo/bar/qux
1281 INPUT_END
1282 git fast-import <input &&
1283 git rev-list N-delete |
1284 git diff-tree -r --stdin --root --always |
1285 sed -e "s/$_x40/OBJID/g" >actual &&
1286 test_cmp expect actual
1289 test_expect_success 'N: modify copied tree' '
1290 cat >expect <<-\EOF &&
1291 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1292 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1293 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1295 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1296 cat >input <<-INPUT_END &&
1297 commit refs/heads/N5
1298 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1299 data <<COMMIT
1300 copy by tree hash
1301 COMMIT
1303 from refs/heads/branch^0
1304 M 040000 $subdir file3
1306 commit refs/heads/N5
1307 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1308 data <<COMMIT
1309 modify directory copy
1310 COMMIT
1312 M 644 inline file3/file5
1313 data <<EOF
1314 $file5_data
1316 INPUT_END
1317 git fast-import <input &&
1318 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1319 compare_diff_raw expect actual
1322 test_expect_success 'N: reject foo/ syntax' '
1323 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1324 test_must_fail git fast-import <<-INPUT_END
1325 commit refs/heads/N5B
1326 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1327 data <<COMMIT
1328 copy with invalid syntax
1329 COMMIT
1331 from refs/heads/branch^0
1332 M 040000 $subdir file3/
1333 INPUT_END
1336 test_expect_success 'N: reject foo/ syntax in copy source' '
1337 test_must_fail git fast-import <<-INPUT_END
1338 commit refs/heads/N5C
1339 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1340 data <<COMMIT
1341 copy with invalid syntax
1342 COMMIT
1344 from refs/heads/branch^0
1345 C file2/ file3
1346 INPUT_END
1349 test_expect_success 'N: reject foo/ syntax in rename source' '
1350 test_must_fail git fast-import <<-INPUT_END
1351 commit refs/heads/N5D
1352 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1353 data <<COMMIT
1354 rename with invalid syntax
1355 COMMIT
1357 from refs/heads/branch^0
1358 R file2/ file3
1359 INPUT_END
1362 test_expect_success 'N: reject foo/ syntax in ls argument' '
1363 test_must_fail git fast-import <<-INPUT_END
1364 commit refs/heads/N5E
1365 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1366 data <<COMMIT
1367 copy with invalid syntax
1368 COMMIT
1370 from refs/heads/branch^0
1371 ls "file2/"
1372 INPUT_END
1375 test_expect_success 'N: copy to root by id and modify' '
1376 echo "hello, world" >expect.foo &&
1377 echo hello >expect.bar &&
1378 git fast-import <<-SETUP_END &&
1379 commit refs/heads/N7
1380 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1381 data <<COMMIT
1382 hello, tree
1383 COMMIT
1385 deleteall
1386 M 644 inline foo/bar
1387 data <<EOF
1388 hello
1390 SETUP_END
1392 tree=$(git rev-parse --verify N7:) &&
1393 git fast-import <<-INPUT_END &&
1394 commit refs/heads/N8
1395 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1396 data <<COMMIT
1397 copy to root by id and modify
1398 COMMIT
1400 M 040000 $tree ""
1401 M 644 inline foo/foo
1402 data <<EOF
1403 hello, world
1405 INPUT_END
1406 git show N8:foo/foo >actual.foo &&
1407 git show N8:foo/bar >actual.bar &&
1408 test_cmp expect.foo actual.foo &&
1409 test_cmp expect.bar actual.bar
1412 test_expect_success 'N: extract subtree' '
1413 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1414 cat >input <<-INPUT_END &&
1415 commit refs/heads/N9
1416 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1417 data <<COMMIT
1418 extract subtree branch:newdir
1419 COMMIT
1421 M 040000 $branch ""
1422 C "newdir" ""
1423 INPUT_END
1424 git fast-import <input &&
1425 git diff --exit-code branch:newdir N9
1428 test_expect_success 'N: modify subtree, extract it, and modify again' '
1429 echo hello >expect.baz &&
1430 echo hello, world >expect.qux &&
1431 git fast-import <<-SETUP_END &&
1432 commit refs/heads/N10
1433 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1434 data <<COMMIT
1435 hello, tree
1436 COMMIT
1438 deleteall
1439 M 644 inline foo/bar/baz
1440 data <<EOF
1441 hello
1443 SETUP_END
1445 tree=$(git rev-parse --verify N10:) &&
1446 git fast-import <<-INPUT_END &&
1447 commit refs/heads/N11
1448 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1449 data <<COMMIT
1450 copy to root by id and modify
1451 COMMIT
1453 M 040000 $tree ""
1454 M 100644 inline foo/bar/qux
1455 data <<EOF
1456 hello, world
1458 R "foo" ""
1459 C "bar/qux" "bar/quux"
1460 INPUT_END
1461 git show N11:bar/baz >actual.baz &&
1462 git show N11:bar/qux >actual.qux &&
1463 git show N11:bar/quux >actual.quux &&
1464 test_cmp expect.baz actual.baz &&
1465 test_cmp expect.qux actual.qux &&
1466 test_cmp expect.qux actual.quux'
1469 ### series O
1472 cat >input <<INPUT_END
1473 #we will
1474 commit refs/heads/O1
1475 # -- ignore all of this text
1476 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1477 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1478 data <<COMMIT
1479 dirty directory copy
1480 COMMIT
1482 # don't forget the import blank line!
1484 # yes, we started from our usual base of branch^0.
1485 # i like branch^0.
1486 from refs/heads/branch^0
1487 # and we need to reuse file2/file5 from N3 above.
1488 M 644 inline file2/file5
1489 # otherwise the tree will be different
1490 data <<EOF
1491 $file5_data
1494 # don't forget to copy file2 to file3
1495 C file2 file3
1497 # or to delete file5 from file2.
1498 D file2/file5
1499 # are we done yet?
1501 INPUT_END
1503 test_expect_success 'O: comments are all skipped' '
1504 git fast-import <input &&
1505 test `git rev-parse N3` = `git rev-parse O1`
1508 cat >input <<INPUT_END
1509 commit refs/heads/O2
1510 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1511 data <<COMMIT
1512 dirty directory copy
1513 COMMIT
1514 from refs/heads/branch^0
1515 M 644 inline file2/file5
1516 data <<EOF
1517 $file5_data
1519 C file2 file3
1520 D file2/file5
1522 INPUT_END
1524 test_expect_success 'O: blank lines not necessary after data commands' '
1525 git fast-import <input &&
1526 test `git rev-parse N3` = `git rev-parse O2`
1529 test_expect_success 'O: repack before next test' '
1530 git repack -a -d
1533 cat >input <<INPUT_END
1534 commit refs/heads/O3
1535 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1536 data <<COMMIT
1537 zstring
1538 COMMIT
1539 commit refs/heads/O3
1540 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1541 data <<COMMIT
1543 COMMIT
1544 checkpoint
1545 commit refs/heads/O3
1546 mark :5
1547 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1548 data <<COMMIT
1549 zempty
1550 COMMIT
1551 checkpoint
1552 commit refs/heads/O3
1553 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1554 data <<COMMIT
1555 zcommits
1556 COMMIT
1557 reset refs/tags/O3-2nd
1558 from :5
1559 reset refs/tags/O3-3rd
1560 from :5
1561 INPUT_END
1563 cat >expect <<INPUT_END
1564 string
1566 empty
1567 commits
1568 INPUT_END
1569 test_expect_success 'O: blank lines not necessary after other commands' '
1570 git fast-import <input &&
1571 test 8 = `find .git/objects/pack -type f | wc -l` &&
1572 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1573 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1574 test_cmp expect actual
1577 cat >input <<INPUT_END
1578 commit refs/heads/O4
1579 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1580 data <<COMMIT
1581 zstring
1582 COMMIT
1583 commit refs/heads/O4
1584 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1585 data <<COMMIT
1587 COMMIT
1588 progress Two commits down, 2 to go!
1589 commit refs/heads/O4
1590 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1591 data <<COMMIT
1592 zempty
1593 COMMIT
1594 progress Three commits down, 1 to go!
1595 commit refs/heads/O4
1596 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1597 data <<COMMIT
1598 zcommits
1599 COMMIT
1600 progress I'm done!
1601 INPUT_END
1602 test_expect_success 'O: progress outputs as requested by input' '
1603 git fast-import <input >actual &&
1604 grep "progress " <input >expect &&
1605 test_cmp expect actual
1609 ### series P (gitlinks)
1612 cat >input <<INPUT_END
1613 blob
1614 mark :1
1615 data 10
1616 test file
1618 reset refs/heads/sub
1619 commit refs/heads/sub
1620 mark :2
1621 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1622 data 12
1623 sub_initial
1624 M 100644 :1 file
1626 blob
1627 mark :3
1628 data <<DATAEND
1629 [submodule "sub"]
1630 path = sub
1631 url = "`pwd`/sub"
1632 DATAEND
1634 commit refs/heads/subuse1
1635 mark :4
1636 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1637 data 8
1638 initial
1639 from refs/heads/master
1640 M 100644 :3 .gitmodules
1641 M 160000 :2 sub
1643 blob
1644 mark :5
1645 data 20
1646 test file
1647 more data
1649 commit refs/heads/sub
1650 mark :6
1651 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1652 data 11
1653 sub_second
1654 from :2
1655 M 100644 :5 file
1657 commit refs/heads/subuse1
1658 mark :7
1659 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1660 data 7
1661 second
1662 from :4
1663 M 160000 :6 sub
1665 INPUT_END
1667 test_expect_success 'P: superproject & submodule mix' '
1668 git fast-import <input &&
1669 git checkout subuse1 &&
1670 rm -rf sub &&
1671 mkdir sub &&
1673 cd sub &&
1674 git init &&
1675 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1676 git checkout master
1677 ) &&
1678 git submodule init &&
1679 git submodule update
1682 SUBLAST=$(git rev-parse --verify sub)
1683 SUBPREV=$(git rev-parse --verify sub^)
1685 cat >input <<INPUT_END
1686 blob
1687 mark :1
1688 data <<DATAEND
1689 [submodule "sub"]
1690 path = sub
1691 url = "`pwd`/sub"
1692 DATAEND
1694 commit refs/heads/subuse2
1695 mark :2
1696 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1697 data 8
1698 initial
1699 from refs/heads/master
1700 M 100644 :1 .gitmodules
1701 M 160000 $SUBPREV sub
1703 commit refs/heads/subuse2
1704 mark :3
1705 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1706 data 7
1707 second
1708 from :2
1709 M 160000 $SUBLAST sub
1711 INPUT_END
1713 test_expect_success 'P: verbatim SHA gitlinks' '
1714 git branch -D sub &&
1715 git gc &&
1716 git prune &&
1717 git fast-import <input &&
1718 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1721 test_tick
1722 cat >input <<INPUT_END
1723 commit refs/heads/subuse3
1724 mark :1
1725 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1726 data <<COMMIT
1727 corrupt
1728 COMMIT
1730 from refs/heads/subuse2
1731 M 160000 inline sub
1732 data <<DATA
1733 $SUBPREV
1734 DATA
1736 INPUT_END
1738 test_expect_success 'P: fail on inline gitlink' '
1739 test_must_fail git fast-import <input
1742 test_tick
1743 cat >input <<INPUT_END
1744 blob
1745 mark :1
1746 data <<DATA
1747 $SUBPREV
1748 DATA
1750 commit refs/heads/subuse3
1751 mark :2
1752 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1753 data <<COMMIT
1754 corrupt
1755 COMMIT
1757 from refs/heads/subuse2
1758 M 160000 :1 sub
1760 INPUT_END
1762 test_expect_success 'P: fail on blob mark in gitlink' '
1763 test_must_fail git fast-import <input
1767 ### series Q (notes)
1770 note1_data="The first note for the first commit"
1771 note2_data="The first note for the second commit"
1772 note3_data="The first note for the third commit"
1773 note1b_data="The second note for the first commit"
1774 note1c_data="The third note for the first commit"
1775 note2b_data="The second note for the second commit"
1777 test_tick
1778 cat >input <<INPUT_END
1779 blob
1780 mark :2
1781 data <<EOF
1782 $file2_data
1785 commit refs/heads/notes-test
1786 mark :3
1787 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1788 data <<COMMIT
1789 first (:3)
1790 COMMIT
1792 M 644 :2 file2
1794 blob
1795 mark :4
1796 data $file4_len
1797 $file4_data
1798 commit refs/heads/notes-test
1799 mark :5
1800 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1801 data <<COMMIT
1802 second (:5)
1803 COMMIT
1805 M 644 :4 file4
1807 commit refs/heads/notes-test
1808 mark :6
1809 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1810 data <<COMMIT
1811 third (:6)
1812 COMMIT
1814 M 644 inline file5
1815 data <<EOF
1816 $file5_data
1819 M 755 inline file6
1820 data <<EOF
1821 $file6_data
1824 blob
1825 mark :7
1826 data <<EOF
1827 $note1_data
1830 blob
1831 mark :8
1832 data <<EOF
1833 $note2_data
1836 commit refs/notes/foobar
1837 mark :9
1838 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1839 data <<COMMIT
1840 notes (:9)
1841 COMMIT
1843 N :7 :3
1844 N :8 :5
1845 N inline :6
1846 data <<EOF
1847 $note3_data
1850 commit refs/notes/foobar
1851 mark :10
1852 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1853 data <<COMMIT
1854 notes (:10)
1855 COMMIT
1857 N inline :3
1858 data <<EOF
1859 $note1b_data
1862 commit refs/notes/foobar2
1863 mark :11
1864 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1865 data <<COMMIT
1866 notes (:11)
1867 COMMIT
1869 N inline :3
1870 data <<EOF
1871 $note1c_data
1874 commit refs/notes/foobar
1875 mark :12
1876 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1877 data <<COMMIT
1878 notes (:12)
1879 COMMIT
1881 deleteall
1882 N inline :5
1883 data <<EOF
1884 $note2b_data
1887 INPUT_END
1889 test_expect_success 'Q: commit notes' '
1890 git fast-import <input &&
1891 git whatchanged notes-test
1894 test_expect_success 'Q: verify pack' '
1895 verify_packs
1898 commit1=$(git rev-parse notes-test~2)
1899 commit2=$(git rev-parse notes-test^)
1900 commit3=$(git rev-parse notes-test)
1902 cat >expect <<EOF
1903 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1904 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1906 first (:3)
1908 test_expect_success 'Q: verify first commit' '
1909 git cat-file commit notes-test~2 | sed 1d >actual &&
1910 test_cmp expect actual
1913 cat >expect <<EOF
1914 parent $commit1
1915 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1916 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1918 second (:5)
1920 test_expect_success 'Q: verify second commit' '
1921 git cat-file commit notes-test^ | sed 1d >actual &&
1922 test_cmp expect actual
1925 cat >expect <<EOF
1926 parent $commit2
1927 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1928 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1930 third (:6)
1932 test_expect_success 'Q: verify third commit' '
1933 git cat-file commit notes-test | sed 1d >actual &&
1934 test_cmp expect actual
1937 cat >expect <<EOF
1938 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1939 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1941 notes (:9)
1943 test_expect_success 'Q: verify first notes commit' '
1944 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1945 test_cmp expect actual
1948 cat >expect.unsorted <<EOF
1949 100644 blob $commit1
1950 100644 blob $commit2
1951 100644 blob $commit3
1953 cat expect.unsorted | sort >expect
1954 test_expect_success 'Q: verify first notes tree' '
1955 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1956 test_cmp expect actual
1959 echo "$note1_data" >expect
1960 test_expect_success 'Q: verify first note for first commit' '
1961 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1962 test_cmp expect actual
1965 echo "$note2_data" >expect
1966 test_expect_success 'Q: verify first note for second commit' '
1967 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1968 test_cmp expect actual
1971 echo "$note3_data" >expect
1972 test_expect_success 'Q: verify first note for third commit' '
1973 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
1974 test_cmp expect actual
1977 cat >expect <<EOF
1978 parent `git rev-parse --verify refs/notes/foobar~2`
1979 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1980 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1982 notes (:10)
1984 test_expect_success 'Q: verify second notes commit' '
1985 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1986 test_cmp expect actual
1989 cat >expect.unsorted <<EOF
1990 100644 blob $commit1
1991 100644 blob $commit2
1992 100644 blob $commit3
1994 cat expect.unsorted | sort >expect
1995 test_expect_success 'Q: verify second notes tree' '
1996 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1997 test_cmp expect actual
2000 echo "$note1b_data" >expect
2001 test_expect_success 'Q: verify second note for first commit' '
2002 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
2003 test_cmp expect actual
2006 echo "$note2_data" >expect
2007 test_expect_success 'Q: verify first note for second commit' '
2008 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
2009 test_cmp expect actual
2012 echo "$note3_data" >expect
2013 test_expect_success 'Q: verify first note for third commit' '
2014 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2015 test_cmp expect actual
2018 cat >expect <<EOF
2019 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2020 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2022 notes (:11)
2024 test_expect_success 'Q: verify third notes commit' '
2025 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2026 test_cmp expect actual
2029 cat >expect.unsorted <<EOF
2030 100644 blob $commit1
2032 cat expect.unsorted | sort >expect
2033 test_expect_success 'Q: verify third notes tree' '
2034 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2035 test_cmp expect actual
2038 echo "$note1c_data" >expect
2039 test_expect_success 'Q: verify third note for first commit' '
2040 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2041 test_cmp expect actual
2044 cat >expect <<EOF
2045 parent `git rev-parse --verify refs/notes/foobar^`
2046 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2047 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2049 notes (:12)
2051 test_expect_success 'Q: verify fourth notes commit' '
2052 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2053 test_cmp expect actual
2056 cat >expect.unsorted <<EOF
2057 100644 blob $commit2
2059 cat expect.unsorted | sort >expect
2060 test_expect_success 'Q: verify fourth notes tree' '
2061 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2062 test_cmp expect actual
2065 echo "$note2b_data" >expect
2066 test_expect_success 'Q: verify second note for second commit' '
2067 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2068 test_cmp expect actual
2071 cat >input <<EOF
2072 reset refs/heads/Q0
2074 commit refs/heads/note-Q0
2075 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2076 data <<COMMIT
2077 Note for an empty branch.
2078 COMMIT
2080 N inline refs/heads/Q0
2081 data <<NOTE
2082 some note
2083 NOTE
2085 test_expect_success 'Q: deny note on empty branch' '
2086 test_must_fail git fast-import <input
2089 ### series R (feature and option)
2092 cat >input <<EOF
2093 feature no-such-feature-exists
2096 test_expect_success 'R: abort on unsupported feature' '
2097 test_must_fail git fast-import <input
2100 cat >input <<EOF
2101 feature date-format=now
2104 test_expect_success 'R: supported feature is accepted' '
2105 git fast-import <input
2108 cat >input << EOF
2109 blob
2110 data 3
2112 feature date-format=now
2115 test_expect_success 'R: abort on receiving feature after data command' '
2116 test_must_fail git fast-import <input
2119 cat >input << EOF
2120 feature import-marks=git.marks
2121 feature import-marks=git2.marks
2124 test_expect_success 'R: only one import-marks feature allowed per stream' '
2125 test_must_fail git fast-import <input
2128 cat >input << EOF
2129 feature export-marks=git.marks
2130 blob
2131 mark :1
2132 data 3
2137 test_expect_success 'R: export-marks feature results in a marks file being created' '
2138 cat input | git fast-import &&
2139 grep :1 git.marks
2142 test_expect_success 'R: export-marks options can be overridden by commandline options' '
2143 cat input | git fast-import --export-marks=other.marks &&
2144 grep :1 other.marks
2147 test_expect_success 'R: catch typo in marks file name' '
2148 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2149 echo "feature import-marks=nonexistent.marks" |
2150 test_must_fail git fast-import
2153 test_expect_success 'R: import and output marks can be the same file' '
2154 rm -f io.marks &&
2155 blob=$(echo hi | git hash-object --stdin) &&
2156 cat >expect <<-EOF &&
2157 :1 $blob
2158 :2 $blob
2160 git fast-import --export-marks=io.marks <<-\EOF &&
2161 blob
2162 mark :1
2163 data 3
2167 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2168 blob
2169 mark :2
2170 data 3
2174 test_cmp expect io.marks
2177 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2178 rm -f io.marks &&
2179 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2180 blob
2181 mark :1
2182 data 3
2188 test_expect_success 'R: --import-marks-if-exists' '
2189 rm -f io.marks &&
2190 blob=$(echo hi | git hash-object --stdin) &&
2191 echo ":1 $blob" >expect &&
2192 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2193 blob
2194 mark :1
2195 data 3
2199 test_cmp expect io.marks
2202 test_expect_success 'R: feature import-marks-if-exists' '
2203 rm -f io.marks &&
2204 >expect &&
2206 git fast-import --export-marks=io.marks <<-\EOF &&
2207 feature import-marks-if-exists=not_io.marks
2209 test_cmp expect io.marks &&
2211 blob=$(echo hi | git hash-object --stdin) &&
2213 echo ":1 $blob" >io.marks &&
2214 echo ":1 $blob" >expect &&
2215 echo ":2 $blob" >>expect &&
2217 git fast-import --export-marks=io.marks <<-\EOF &&
2218 feature import-marks-if-exists=io.marks
2219 blob
2220 mark :2
2221 data 3
2225 test_cmp expect io.marks &&
2227 echo ":3 $blob" >>expect &&
2229 git fast-import --import-marks=io.marks \
2230 --export-marks=io.marks <<-\EOF &&
2231 feature import-marks-if-exists=not_io.marks
2232 blob
2233 mark :3
2234 data 3
2238 test_cmp expect io.marks &&
2240 >expect &&
2242 git fast-import --import-marks-if-exists=not_io.marks \
2243 --export-marks=io.marks <<-\EOF &&
2244 feature import-marks-if-exists=io.marks
2246 test_cmp expect io.marks
2249 cat >input << EOF
2250 feature import-marks=marks.out
2251 feature export-marks=marks.new
2254 test_expect_success 'R: import to output marks works without any content' '
2255 cat input | git fast-import &&
2256 test_cmp marks.out marks.new
2259 cat >input <<EOF
2260 feature import-marks=nonexistent.marks
2261 feature export-marks=marks.new
2264 test_expect_success 'R: import marks prefers commandline marks file over the stream' '
2265 cat input | git fast-import --import-marks=marks.out &&
2266 test_cmp marks.out marks.new
2270 cat >input <<EOF
2271 feature import-marks=nonexistent.marks
2272 feature export-marks=combined.marks
2275 test_expect_success 'R: multiple --import-marks= should be honoured' '
2276 head -n2 marks.out > one.marks &&
2277 tail -n +3 marks.out > two.marks &&
2278 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
2279 test_cmp marks.out combined.marks
2282 cat >input <<EOF
2283 feature relative-marks
2284 feature import-marks=relative.in
2285 feature export-marks=relative.out
2288 test_expect_success 'R: feature relative-marks should be honoured' '
2289 mkdir -p .git/info/fast-import/ &&
2290 cp marks.new .git/info/fast-import/relative.in &&
2291 git fast-import <input &&
2292 test_cmp marks.new .git/info/fast-import/relative.out
2295 cat >input <<EOF
2296 feature relative-marks
2297 feature import-marks=relative.in
2298 feature no-relative-marks
2299 feature export-marks=non-relative.out
2302 test_expect_success 'R: feature no-relative-marks should be honoured' '
2303 git fast-import <input &&
2304 test_cmp marks.new non-relative.out
2307 test_expect_success 'R: feature ls supported' '
2308 echo "feature ls" |
2309 git fast-import
2312 test_expect_success 'R: feature cat-blob supported' '
2313 echo "feature cat-blob" |
2314 git fast-import
2317 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2318 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2321 test_expect_success !MINGW 'R: print old blob' '
2322 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2323 cat >expect <<-EOF &&
2324 ${blob} blob 11
2325 yes it can
2328 echo "cat-blob $blob" |
2329 git fast-import --cat-blob-fd=6 6>actual &&
2330 test_cmp expect actual
2333 test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
2334 echo hello >greeting &&
2335 blob=$(git hash-object -w greeting) &&
2336 cat >expect <<-EOF &&
2337 ${blob} blob 6
2338 hello
2341 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2342 cat-blob $blob
2344 test_cmp expect actual.3 &&
2345 test_must_be_empty actual.1 &&
2346 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2347 option cat-blob-fd=3
2348 cat-blob $blob
2350 test_must_be_empty actual.3 &&
2351 test_cmp expect actual.1
2354 test_expect_success !MINGW 'R: print mark for new blob' '
2355 echo "effluentish" | git hash-object --stdin >expect &&
2356 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2357 blob
2358 mark :1
2359 data <<BLOB_END
2360 effluentish
2361 BLOB_END
2362 get-mark :1
2364 test_cmp expect actual
2367 test_expect_success !MINGW 'R: print new blob' '
2368 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2369 cat >expect <<-EOF &&
2370 ${blob} blob 12
2371 yep yep yep
2374 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2375 blob
2376 mark :1
2377 data <<BLOB_END
2378 yep yep yep
2379 BLOB_END
2380 cat-blob :1
2382 test_cmp expect actual
2385 test_expect_success !MINGW 'R: print new blob by sha1' '
2386 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2387 cat >expect <<-EOF &&
2388 ${blob} blob 25
2389 a new blob named by sha1
2392 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2393 blob
2394 data <<BLOB_END
2395 a new blob named by sha1
2396 BLOB_END
2397 cat-blob $blob
2399 test_cmp expect actual
2402 test_expect_success 'setup: big file' '
2404 echo "the quick brown fox jumps over the lazy dog" >big &&
2405 for i in 1 2 3
2407 cat big big big big >bigger &&
2408 cat bigger bigger bigger bigger >big ||
2409 exit
2410 done
2414 test_expect_success 'R: print two blobs to stdout' '
2415 blob1=$(git hash-object big) &&
2416 blob1_len=$(wc -c <big) &&
2417 blob2=$(echo hello | git hash-object --stdin) &&
2419 echo ${blob1} blob $blob1_len &&
2420 cat big &&
2421 cat <<-EOF
2423 ${blob2} blob 6
2424 hello
2427 } >expect &&
2429 cat <<-\END_PART1 &&
2430 blob
2431 mark :1
2432 data <<data_end
2433 END_PART1
2434 cat big &&
2435 cat <<-\EOF
2436 data_end
2437 blob
2438 mark :2
2439 data <<data_end
2440 hello
2441 data_end
2442 cat-blob :1
2443 cat-blob :2
2446 git fast-import >actual &&
2447 test_cmp expect actual
2450 test_expect_success PIPE 'R: copy using cat-file' '
2451 expect_id=$(git hash-object big) &&
2452 expect_len=$(wc -c <big) &&
2453 echo $expect_id blob $expect_len >expect.response &&
2455 rm -f blobs &&
2456 cat >frontend <<-\FRONTEND_END &&
2457 #!/bin/sh
2458 FRONTEND_END
2460 mkfifo blobs &&
2462 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2463 cat <<-\EOF &&
2464 feature cat-blob
2465 blob
2466 mark :1
2467 data <<BLOB
2469 cat big &&
2470 cat <<-\EOF &&
2471 BLOB
2472 cat-blob :1
2475 read blob_id type size <&3 &&
2476 echo "$blob_id $type $size" >response &&
2477 head_c $size >blob <&3 &&
2478 read newline <&3 &&
2480 cat <<-EOF &&
2481 commit refs/heads/copied
2482 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2483 data <<COMMIT
2484 copy big file as file3
2485 COMMIT
2486 M 644 inline file3
2487 data <<BLOB
2489 cat blob &&
2490 echo BLOB
2491 ) 3<blobs |
2492 git fast-import --cat-blob-fd=3 3>blobs &&
2493 git show copied:file3 >actual &&
2494 test_cmp expect.response response &&
2495 test_cmp big actual
2498 test_expect_success PIPE 'R: print blob mid-commit' '
2499 rm -f blobs &&
2500 echo "A blob from _before_ the commit." >expect &&
2501 mkfifo blobs &&
2503 exec 3<blobs &&
2504 cat <<-EOF &&
2505 feature cat-blob
2506 blob
2507 mark :1
2508 data <<BLOB
2509 A blob from _before_ the commit.
2510 BLOB
2511 commit refs/heads/temporary
2512 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2513 data <<COMMIT
2514 Empty commit
2515 COMMIT
2516 cat-blob :1
2519 read blob_id type size <&3 &&
2520 head_c $size >actual <&3 &&
2521 read newline <&3 &&
2523 echo
2525 git fast-import --cat-blob-fd=3 3>blobs &&
2526 test_cmp expect actual
2529 test_expect_success PIPE 'R: print staged blob within commit' '
2530 rm -f blobs &&
2531 echo "A blob from _within_ the commit." >expect &&
2532 mkfifo blobs &&
2534 exec 3<blobs &&
2535 cat <<-EOF &&
2536 feature cat-blob
2537 commit refs/heads/within
2538 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2539 data <<COMMIT
2540 Empty commit
2541 COMMIT
2542 M 644 inline within
2543 data <<BLOB
2544 A blob from _within_ the commit.
2545 BLOB
2548 to_get=$(
2549 echo "A blob from _within_ the commit." |
2550 git hash-object --stdin
2551 ) &&
2552 echo "cat-blob $to_get" &&
2554 read blob_id type size <&3 &&
2555 head_c $size >actual <&3 &&
2556 read newline <&3 &&
2558 echo deleteall
2560 git fast-import --cat-blob-fd=3 3>blobs &&
2561 test_cmp expect actual
2564 cat >input << EOF
2565 option git quiet
2566 blob
2567 data 3
2572 test_expect_success 'R: quiet option results in no stats being output' '
2573 cat input | git fast-import 2> output &&
2574 test_must_be_empty output
2577 test_expect_success 'R: feature done means terminating "done" is mandatory' '
2578 echo feature done | test_must_fail git fast-import &&
2579 test_must_fail git fast-import --done </dev/null
2582 test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2583 git fast-import <<-\EOF &&
2584 feature done
2585 done
2586 trailing gibberish
2588 git fast-import <<-\EOF
2589 done
2590 more trailing gibberish
2594 test_expect_success 'R: terminating "done" within commit' '
2595 cat >expect <<-\EOF &&
2596 OBJID
2597 :000000 100644 OBJID OBJID A hello.c
2598 :000000 100644 OBJID OBJID A hello2.c
2600 git fast-import <<-EOF &&
2601 commit refs/heads/done-ends
2602 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2603 data <<EOT
2604 Commit terminated by "done" command
2606 M 100644 inline hello.c
2607 data <<EOT
2608 Hello, world.
2610 C hello.c hello2.c
2611 done
2613 git rev-list done-ends |
2614 git diff-tree -r --stdin --root --always |
2615 sed -e "s/$_x40/OBJID/g" >actual &&
2616 test_cmp expect actual
2619 cat >input <<EOF
2620 option git non-existing-option
2623 test_expect_success 'R: die on unknown option' '
2624 test_must_fail git fast-import <input
2627 test_expect_success 'R: unknown commandline options are rejected' '\
2628 test_must_fail git fast-import --non-existing-option < /dev/null
2631 test_expect_success 'R: die on invalid option argument' '
2632 echo "option git active-branches=-5" |
2633 test_must_fail git fast-import &&
2634 echo "option git depth=" |
2635 test_must_fail git fast-import &&
2636 test_must_fail git fast-import --depth="5 elephants" </dev/null
2639 cat >input <<EOF
2640 option non-existing-vcs non-existing-option
2643 test_expect_success 'R: ignore non-git options' '
2644 git fast-import <input
2648 ## R: very large blobs
2650 blobsize=$((2*1024*1024 + 53))
2651 test-genrandom bar $blobsize >expect
2652 cat >input <<INPUT_END
2653 commit refs/heads/big-file
2654 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2655 data <<COMMIT
2656 R - big file
2657 COMMIT
2659 M 644 inline big1
2660 data $blobsize
2661 INPUT_END
2662 cat expect >>input
2663 cat >>input <<INPUT_END
2664 M 644 inline big2
2665 data $blobsize
2666 INPUT_END
2667 cat expect >>input
2668 echo >>input
2670 test_expect_success 'R: blob bigger than threshold' '
2671 test_create_repo R &&
2672 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2675 test_expect_success 'R: verify created pack' '
2677 cd R &&
2678 verify_packs -v > ../verify
2682 test_expect_success 'R: verify written objects' '
2683 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2684 test_cmp_bin expect actual &&
2685 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2686 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2687 test $a = $b
2690 test_expect_success 'R: blob appears only once' '
2691 n=$(grep $a verify | wc -l) &&
2692 test 1 = $n
2696 ### series S
2699 # Make sure missing spaces and EOLs after mark references
2700 # cause errors.
2702 # Setup:
2704 # 1--2--4
2705 # \ /
2706 # -3-
2708 # commit marks: 301, 302, 303, 304
2709 # blob marks: 403, 404, resp.
2710 # note mark: 202
2712 # The error message when a space is missing not at the
2713 # end of the line is:
2715 # Missing space after ..
2717 # or when extra characters come after the mark at the end
2718 # of the line:
2720 # Garbage after ..
2722 # or when the dataref is neither "inline " or a known SHA1,
2724 # Invalid dataref ..
2726 test_tick
2728 cat >input <<INPUT_END
2729 commit refs/heads/S
2730 mark :301
2731 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2732 data <<COMMIT
2733 commit 1
2734 COMMIT
2735 M 100644 inline hello.c
2736 data <<BLOB
2737 blob 1
2738 BLOB
2740 commit refs/heads/S
2741 mark :302
2742 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2743 data <<COMMIT
2744 commit 2
2745 COMMIT
2746 from :301
2747 M 100644 inline hello.c
2748 data <<BLOB
2749 blob 2
2750 BLOB
2752 blob
2753 mark :403
2754 data <<BLOB
2755 blob 3
2756 BLOB
2758 blob
2759 mark :202
2760 data <<BLOB
2761 note 2
2762 BLOB
2763 INPUT_END
2765 test_expect_success 'S: initialize for S tests' '
2766 git fast-import --export-marks=marks <input
2770 # filemodify, three datarefs
2772 test_expect_success 'S: filemodify with garbage after mark must fail' '
2773 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2774 commit refs/heads/S
2775 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2776 data <<COMMIT
2777 commit N
2778 COMMIT
2779 M 100644 :403x hello.c
2781 cat err &&
2782 test_i18ngrep "space after mark" err
2785 # inline is misspelled; fast-import thinks it is some unknown dataref
2786 test_expect_success 'S: filemodify with garbage after inline must fail' '
2787 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2788 commit refs/heads/S
2789 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2790 data <<COMMIT
2791 commit N
2792 COMMIT
2793 M 100644 inlineX hello.c
2794 data <<BLOB
2795 inline
2796 BLOB
2798 cat err &&
2799 test_i18ngrep "nvalid dataref" err
2802 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2803 sha1=$(grep :403 marks | cut -d\ -f2) &&
2804 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2805 commit refs/heads/S
2806 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2807 data <<COMMIT
2808 commit N
2809 COMMIT
2810 M 100644 ${sha1}x hello.c
2812 cat err &&
2813 test_i18ngrep "space after SHA1" err
2817 # notemodify, three ways to say dataref
2819 test_expect_success 'S: notemodify with garabge after mark dataref must fail' '
2820 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2821 commit refs/heads/S
2822 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2823 data <<COMMIT
2824 commit S note dataref markref
2825 COMMIT
2826 N :202x :302
2828 cat err &&
2829 test_i18ngrep "space after mark" err
2832 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2833 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2834 commit refs/heads/S
2835 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2836 data <<COMMIT
2837 commit S note dataref inline
2838 COMMIT
2839 N inlineX :302
2840 data <<BLOB
2841 note blob
2842 BLOB
2844 cat err &&
2845 test_i18ngrep "nvalid dataref" err
2848 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2849 sha1=$(grep :202 marks | cut -d\ -f2) &&
2850 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2851 commit refs/heads/S
2852 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2853 data <<COMMIT
2854 commit S note dataref sha1
2855 COMMIT
2856 N ${sha1}x :302
2858 cat err &&
2859 test_i18ngrep "space after SHA1" err
2863 # notemodify, mark in commit-ish
2865 test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
2866 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2867 commit refs/heads/Snotes
2868 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2869 data <<COMMIT
2870 commit S note commit-ish
2871 COMMIT
2872 N :202 :302x
2874 cat err &&
2875 test_i18ngrep "after mark" err
2879 # from
2881 test_expect_success 'S: from with garbage after mark must fail' '
2882 test_must_fail \
2883 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
2884 commit refs/heads/S2
2885 mark :303
2886 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2887 data <<COMMIT
2888 commit 3
2889 COMMIT
2890 from :301x
2891 M 100644 :403 hello.c
2895 # go create the commit, need it for merge test
2896 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2897 commit refs/heads/S2
2898 mark :303
2899 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2900 data <<COMMIT
2901 commit 3
2902 COMMIT
2903 from :301
2904 M 100644 :403 hello.c
2907 # now evaluate the error
2908 cat err &&
2909 test_i18ngrep "after mark" err
2914 # merge
2916 test_expect_success 'S: merge with garbage after mark must fail' '
2917 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2918 commit refs/heads/S
2919 mark :304
2920 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2921 data <<COMMIT
2922 merge 4
2923 COMMIT
2924 from :302
2925 merge :303x
2926 M 100644 :403 hello.c
2928 cat err &&
2929 test_i18ngrep "after mark" err
2933 # tag, from markref
2935 test_expect_success 'S: tag with garbage after mark must fail' '
2936 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2937 tag refs/tags/Stag
2938 from :302x
2939 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2940 data <<TAG
2941 tag S
2944 cat err &&
2945 test_i18ngrep "after mark" err
2949 # cat-blob markref
2951 test_expect_success 'S: cat-blob with garbage after mark must fail' '
2952 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2953 cat-blob :403x
2955 cat err &&
2956 test_i18ngrep "after mark" err
2960 # ls markref
2962 test_expect_success 'S: ls with garbage after mark must fail' '
2963 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2964 ls :302x hello.c
2966 cat err &&
2967 test_i18ngrep "space after mark" err
2970 test_expect_success 'S: ls with garbage after sha1 must fail' '
2971 sha1=$(grep :302 marks | cut -d\ -f2) &&
2972 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2973 ls ${sha1}x hello.c
2975 cat err &&
2976 test_i18ngrep "space after tree-ish" err
2980 ### series T (ls)
2982 # Setup is carried over from series S.
2984 test_expect_success 'T: ls root tree' '
2985 sed -e "s/Z\$//" >expect <<-EOF &&
2986 040000 tree $(git rev-parse S^{tree}) Z
2988 sha1=$(git rev-parse --verify S) &&
2989 git fast-import --import-marks=marks <<-EOF >actual &&
2990 ls $sha1 ""
2992 test_cmp expect actual
2995 test_expect_success 'T: delete branch' '
2996 git branch to-delete &&
2997 git fast-import <<-EOF &&
2998 reset refs/heads/to-delete
2999 from 0000000000000000000000000000000000000000
3001 test_must_fail git rev-parse --verify refs/heads/to-delete
3004 test_expect_success 'T: empty reset doesnt delete branch' '
3005 git branch not-to-delete &&
3006 git fast-import <<-EOF &&
3007 reset refs/heads/not-to-delete
3009 git show-ref &&
3010 git rev-parse --verify refs/heads/not-to-delete
3014 ### series U (filedelete)
3017 cat >input <<INPUT_END
3018 commit refs/heads/U
3019 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3020 data <<COMMIT
3021 test setup
3022 COMMIT
3023 M 100644 inline hello.c
3024 data <<BLOB
3025 blob 1
3026 BLOB
3027 M 100644 inline good/night.txt
3028 data <<BLOB
3029 sleep well
3030 BLOB
3031 M 100644 inline good/bye.txt
3032 data <<BLOB
3033 au revoir
3034 BLOB
3036 INPUT_END
3038 test_expect_success 'U: initialize for U tests' '
3039 git fast-import <input
3042 cat >input <<INPUT_END
3043 commit refs/heads/U
3044 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3045 data <<COMMIT
3046 delete good/night.txt
3047 COMMIT
3048 from refs/heads/U^0
3049 D good/night.txt
3051 INPUT_END
3053 test_expect_success 'U: filedelete file succeeds' '
3054 git fast-import <input
3057 cat >expect <<EOF
3058 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3061 git diff-tree -M -r U^1 U >actual
3063 test_expect_success 'U: validate file delete result' '
3064 compare_diff_raw expect actual
3067 cat >input <<INPUT_END
3068 commit refs/heads/U
3069 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3070 data <<COMMIT
3071 delete good dir
3072 COMMIT
3073 from refs/heads/U^0
3074 D good
3076 INPUT_END
3078 test_expect_success 'U: filedelete directory succeeds' '
3079 git fast-import <input
3082 cat >expect <<EOF
3083 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3086 git diff-tree -M -r U^1 U >actual
3088 test_expect_success 'U: validate directory delete result' '
3089 compare_diff_raw expect actual
3092 cat >input <<INPUT_END
3093 commit refs/heads/U
3094 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3095 data <<COMMIT
3096 must succeed
3097 COMMIT
3098 from refs/heads/U^0
3099 D ""
3101 INPUT_END
3103 test_expect_success 'U: filedelete root succeeds' '
3104 git fast-import <input
3107 cat >expect <<EOF
3108 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3111 git diff-tree -M -r U^1 U >actual
3113 test_expect_success 'U: validate root delete result' '
3114 compare_diff_raw expect actual
3117 test_done