ab9493478cdaf4036bf1b79988cc2fac0fa22f4b
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Shawn Pearce
4 #
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.
11 #
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;
23 }
24 ' - "$1"
25 }
27 file2_data='file2
28 second line of EOF'
30 file3_data='EOF
31 in 3rd file
32 END'
34 file4_data=abcd
35 file4_len=4
37 file5_data='an inline file.
38 we should see it later.'
40 file6_data='#!/bin/sh
41 echo "$@"'
43 >empty
45 test_expect_success 'setup: have pipes?' '
46 rm -f frob &&
47 if mkfifo frob
48 then
49 test_set_prereq PIPE
50 fi
51 '
53 ###
54 ### series A
55 ###
57 test_tick
59 test_expect_success 'empty stream succeeds' '
60 git fast-import </dev/null
61 '
63 cat >input <<INPUT_END
64 blob
65 mark :2
66 data <<EOF
67 $file2_data
68 EOF
70 blob
71 mark :3
72 data <<END
73 $file3_data
74 END
76 blob
77 mark :4
78 data $file4_len
79 $file4_data
80 commit refs/heads/master
81 mark :5
82 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
83 data <<COMMIT
84 initial
85 COMMIT
87 M 644 :2 file2
88 M 644 :3 file3
89 M 755 :4 file4
91 tag series-A
92 from :5
93 data <<EOF
94 An annotated tag without a tagger
95 EOF
97 tag series-A-blob
98 from :3
99 data <<EOF
100 An annotated tag that annotates a blob.
101 EOF
103 INPUT_END
104 test_expect_success \
105 'A: create pack from stdin' \
106 'git fast-import --export-marks=marks.out <input &&
107 git whatchanged master'
108 test_expect_success \
109 'A: verify pack' \
110 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
112 cat >expect <<EOF
113 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
114 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
116 initial
117 EOF
118 test_expect_success \
119 'A: verify commit' \
120 'git cat-file commit master | sed 1d >actual &&
121 test_cmp expect actual'
123 cat >expect <<EOF
124 100644 blob file2
125 100644 blob file3
126 100755 blob file4
127 EOF
128 test_expect_success \
129 'A: verify tree' \
130 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
131 test_cmp expect actual'
133 echo "$file2_data" >expect
134 test_expect_success \
135 'A: verify file2' \
136 'git cat-file blob master:file2 >actual && test_cmp expect actual'
138 echo "$file3_data" >expect
139 test_expect_success \
140 'A: verify file3' \
141 'git cat-file blob master:file3 >actual && test_cmp expect actual'
143 printf "$file4_data" >expect
144 test_expect_success \
145 'A: verify file4' \
146 'git cat-file blob master:file4 >actual && test_cmp expect actual'
148 cat >expect <<EOF
149 object $(git rev-parse refs/heads/master)
150 type commit
151 tag series-A
153 An annotated tag without a tagger
154 EOF
155 test_expect_success 'A: verify tag/series-A' '
156 git cat-file tag tags/series-A >actual &&
157 test_cmp expect actual
158 '
160 cat >expect <<EOF
161 object $(git rev-parse refs/heads/master:file3)
162 type blob
163 tag series-A-blob
165 An annotated tag that annotates a blob.
166 EOF
167 test_expect_success 'A: verify tag/series-A-blob' '
168 git cat-file tag tags/series-A-blob >actual &&
169 test_cmp expect actual
170 '
172 cat >expect <<EOF
173 :2 `git rev-parse --verify master:file2`
174 :3 `git rev-parse --verify master:file3`
175 :4 `git rev-parse --verify master:file4`
176 :5 `git rev-parse --verify master^0`
177 EOF
178 test_expect_success \
179 'A: verify marks output' \
180 'test_cmp expect marks.out'
182 test_expect_success \
183 'A: verify marks import' \
184 'git fast-import \
185 --import-marks=marks.out \
186 --export-marks=marks.new \
187 </dev/null &&
188 test_cmp expect marks.new'
190 test_tick
191 new_blob=$(echo testing | git hash-object --stdin)
192 cat >input <<INPUT_END
193 tag series-A-blob-2
194 from $(git rev-parse refs/heads/master:file3)
195 data <<EOF
196 Tag blob by sha1.
197 EOF
199 blob
200 mark :6
201 data <<EOF
202 testing
203 EOF
205 commit refs/heads/new_blob
206 committer <> 0 +0000
207 data 0
208 M 644 :6 new_blob
209 #pretend we got sha1 from fast-import
210 ls "new_blob"
212 tag series-A-blob-3
213 from $new_blob
214 data <<EOF
215 Tag new_blob.
216 EOF
217 INPUT_END
219 cat >expect <<EOF
220 object $(git rev-parse refs/heads/master:file3)
221 type blob
222 tag series-A-blob-2
224 Tag blob by sha1.
225 object $new_blob
226 type blob
227 tag series-A-blob-3
229 Tag new_blob.
230 EOF
232 test_expect_success \
233 'A: tag blob by sha1' \
234 'git fast-import <input &&
235 git cat-file tag tags/series-A-blob-2 >actual &&
236 git cat-file tag tags/series-A-blob-3 >>actual &&
237 test_cmp expect actual'
239 test_tick
240 cat >input <<INPUT_END
241 commit refs/heads/verify--import-marks
242 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
243 data <<COMMIT
244 recreate from :5
245 COMMIT
247 from :5
248 M 755 :2 copy-of-file2
250 INPUT_END
251 test_expect_success \
252 'A: verify marks import does not crash' \
253 'git fast-import --import-marks=marks.out <input &&
254 git whatchanged verify--import-marks'
255 test_expect_success \
256 'A: verify pack' \
257 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
258 cat >expect <<EOF
259 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
260 EOF
261 git diff-tree -M -r master verify--import-marks >actual
262 test_expect_success \
263 'A: verify diff' \
264 'compare_diff_raw expect actual &&
265 test `git rev-parse --verify master:file2` \
266 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
268 test_tick
269 mt=$(git hash-object --stdin < /dev/null)
270 : >input.blob
271 : >marks.exp
272 : >tree.exp
274 cat >input.commit <<EOF
275 commit refs/heads/verify--dump-marks
276 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
277 data <<COMMIT
278 test the sparse array dumping routines with exponentially growing marks
279 COMMIT
280 EOF
282 i=0
283 l=4
284 m=6
285 n=7
286 while test "$i" -lt 27; do
287 cat >>input.blob <<EOF
288 blob
289 mark :$l
290 data 0
291 blob
292 mark :$m
293 data 0
294 blob
295 mark :$n
296 data 0
297 EOF
298 echo "M 100644 :$l l$i" >>input.commit
299 echo "M 100644 :$m m$i" >>input.commit
300 echo "M 100644 :$n n$i" >>input.commit
302 echo ":$l $mt" >>marks.exp
303 echo ":$m $mt" >>marks.exp
304 echo ":$n $mt" >>marks.exp
306 printf "100644 blob $mt\tl$i\n" >>tree.exp
307 printf "100644 blob $mt\tm$i\n" >>tree.exp
308 printf "100644 blob $mt\tn$i\n" >>tree.exp
310 l=$(($l + $l))
311 m=$(($m + $m))
312 n=$(($l + $n))
314 i=$((1 + $i))
315 done
317 sort tree.exp > tree.exp_s
319 test_expect_success 'A: export marks with large values' '
320 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
321 git ls-tree refs/heads/verify--dump-marks >tree.out &&
322 test_cmp tree.exp_s tree.out &&
323 test_cmp marks.exp marks.large'
325 ###
326 ### series B
327 ###
329 test_tick
330 cat >input <<INPUT_END
331 commit refs/heads/branch
332 mark :1
333 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
334 data <<COMMIT
335 corrupt
336 COMMIT
338 from refs/heads/master
339 M 755 0000000000000000000000000000000000000001 zero1
341 INPUT_END
342 test_expect_success 'B: fail on invalid blob sha1' '
343 test_must_fail git fast-import <input
344 '
345 rm -f .git/objects/pack_* .git/objects/index_*
347 cat >input <<INPUT_END
348 commit .badbranchname
349 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
350 data <<COMMIT
351 corrupt
352 COMMIT
354 from refs/heads/master
356 INPUT_END
357 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
358 test_must_fail git fast-import <input
359 '
360 rm -f .git/objects/pack_* .git/objects/index_*
362 cat >input <<INPUT_END
363 commit bad[branch]name
364 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
365 data <<COMMIT
366 corrupt
367 COMMIT
369 from refs/heads/master
371 INPUT_END
372 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
373 test_must_fail git fast-import <input
374 '
375 rm -f .git/objects/pack_* .git/objects/index_*
377 cat >input <<INPUT_END
378 commit TEMP_TAG
379 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
380 data <<COMMIT
381 tag base
382 COMMIT
384 from refs/heads/master
386 INPUT_END
387 test_expect_success \
388 'B: accept branch name "TEMP_TAG"' \
389 'git fast-import <input &&
390 test -f .git/TEMP_TAG &&
391 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
392 rm -f .git/TEMP_TAG
394 ###
395 ### series C
396 ###
398 newf=`echo hi newf | git hash-object -w --stdin`
399 oldf=`git rev-parse --verify master:file2`
400 test_tick
401 cat >input <<INPUT_END
402 commit refs/heads/branch
403 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
404 data <<COMMIT
405 second
406 COMMIT
408 from refs/heads/master
409 M 644 $oldf file2/oldf
410 M 755 $newf file2/newf
411 D file3
413 INPUT_END
414 test_expect_success \
415 'C: incremental import create pack from stdin' \
416 'git fast-import <input &&
417 git whatchanged branch'
418 test_expect_success \
419 'C: verify pack' \
420 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
421 test_expect_success \
422 'C: validate reuse existing blob' \
423 'test $newf = `git rev-parse --verify branch:file2/newf` &&
424 test $oldf = `git rev-parse --verify branch:file2/oldf`'
426 cat >expect <<EOF
427 parent `git rev-parse --verify master^0`
428 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
429 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
431 second
432 EOF
433 test_expect_success \
434 'C: verify commit' \
435 'git cat-file commit branch | sed 1d >actual &&
436 test_cmp expect actual'
438 cat >expect <<EOF
439 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
440 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
441 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
442 EOF
443 git diff-tree -M -r master branch >actual
444 test_expect_success \
445 'C: validate rename result' \
446 'compare_diff_raw expect actual'
448 ###
449 ### series D
450 ###
452 test_tick
453 cat >input <<INPUT_END
454 commit refs/heads/branch
455 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
456 data <<COMMIT
457 third
458 COMMIT
460 from refs/heads/branch^0
461 M 644 inline newdir/interesting
462 data <<EOF
463 $file5_data
464 EOF
466 M 755 inline newdir/exec.sh
467 data <<EOF
468 $file6_data
469 EOF
471 INPUT_END
472 test_expect_success \
473 'D: inline data in commit' \
474 'git fast-import <input &&
475 git whatchanged branch'
476 test_expect_success \
477 'D: verify pack' \
478 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
480 cat >expect <<EOF
481 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
482 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
483 EOF
484 git diff-tree -M -r branch^ branch >actual
485 test_expect_success \
486 'D: validate new files added' \
487 'compare_diff_raw expect actual'
489 echo "$file5_data" >expect
490 test_expect_success \
491 'D: verify file5' \
492 'git cat-file blob branch:newdir/interesting >actual &&
493 test_cmp expect actual'
495 echo "$file6_data" >expect
496 test_expect_success \
497 'D: verify file6' \
498 'git cat-file blob branch:newdir/exec.sh >actual &&
499 test_cmp expect actual'
501 ###
502 ### series E
503 ###
505 cat >input <<INPUT_END
506 commit refs/heads/branch
507 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
508 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
509 data <<COMMIT
510 RFC 2822 type date
511 COMMIT
513 from refs/heads/branch^0
515 INPUT_END
516 test_expect_success 'E: rfc2822 date, --date-format=raw' '
517 test_must_fail git fast-import --date-format=raw <input
518 '
519 test_expect_success \
520 'E: rfc2822 date, --date-format=rfc2822' \
521 'git fast-import --date-format=rfc2822 <input'
522 test_expect_success \
523 'E: verify pack' \
524 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
526 cat >expect <<EOF
527 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
528 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
530 RFC 2822 type date
531 EOF
532 test_expect_success \
533 'E: verify commit' \
534 'git cat-file commit branch | sed 1,2d >actual &&
535 test_cmp expect actual'
537 ###
538 ### series F
539 ###
541 old_branch=`git rev-parse --verify branch^0`
542 test_tick
543 cat >input <<INPUT_END
544 commit refs/heads/branch
545 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
546 data <<COMMIT
547 losing things already?
548 COMMIT
550 from refs/heads/branch~1
552 reset refs/heads/other
553 from refs/heads/branch
555 INPUT_END
556 test_expect_success \
557 'F: non-fast-forward update skips' \
558 'if git fast-import <input
559 then
560 echo BAD gfi did not fail
561 return 1
562 else
563 if test $old_branch = `git rev-parse --verify branch^0`
564 then
565 : branch unaffected and failure returned
566 return 0
567 else
568 echo BAD gfi changed branch $old_branch
569 return 1
570 fi
571 fi
572 '
573 test_expect_success \
574 'F: verify pack' \
575 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
577 cat >expect <<EOF
578 tree `git rev-parse branch~1^{tree}`
579 parent `git rev-parse branch~1`
580 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
581 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
583 losing things already?
584 EOF
585 test_expect_success \
586 'F: verify other commit' \
587 'git cat-file commit other >actual &&
588 test_cmp expect actual'
590 ###
591 ### series G
592 ###
594 old_branch=`git rev-parse --verify branch^0`
595 test_tick
596 cat >input <<INPUT_END
597 commit refs/heads/branch
598 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
599 data <<COMMIT
600 losing things already?
601 COMMIT
603 from refs/heads/branch~1
605 INPUT_END
606 test_expect_success \
607 'G: non-fast-forward update forced' \
608 'git fast-import --force <input'
609 test_expect_success \
610 'G: verify pack' \
611 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
612 test_expect_success \
613 'G: branch changed, but logged' \
614 'test $old_branch != `git rev-parse --verify branch^0` &&
615 test $old_branch = `git rev-parse --verify branch@{1}`'
617 ###
618 ### series H
619 ###
621 test_tick
622 cat >input <<INPUT_END
623 commit refs/heads/H
624 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
625 data <<COMMIT
626 third
627 COMMIT
629 from refs/heads/branch^0
630 M 644 inline i-will-die
631 data <<EOF
632 this file will never exist.
633 EOF
635 deleteall
636 M 644 inline h/e/l/lo
637 data <<EOF
638 $file5_data
639 EOF
641 INPUT_END
642 test_expect_success \
643 'H: deletall, add 1' \
644 'git fast-import <input &&
645 git whatchanged H'
646 test_expect_success \
647 'H: verify pack' \
648 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
650 cat >expect <<EOF
651 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
652 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
653 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
654 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
655 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
656 EOF
657 git diff-tree -M -r H^ H >actual
658 test_expect_success \
659 'H: validate old files removed, new files added' \
660 'compare_diff_raw expect actual'
662 echo "$file5_data" >expect
663 test_expect_success \
664 'H: verify file' \
665 'git cat-file blob H:h/e/l/lo >actual &&
666 test_cmp expect actual'
668 ###
669 ### series I
670 ###
672 cat >input <<INPUT_END
673 commit refs/heads/export-boundary
674 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
675 data <<COMMIT
676 we have a border. its only 40 characters wide.
677 COMMIT
679 from refs/heads/branch
681 INPUT_END
682 test_expect_success \
683 'I: export-pack-edges' \
684 'git fast-import --export-pack-edges=edges.list <input'
686 cat >expect <<EOF
687 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
688 EOF
689 test_expect_success \
690 'I: verify edge list' \
691 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
692 test_cmp expect actual'
694 ###
695 ### series J
696 ###
698 cat >input <<INPUT_END
699 commit refs/heads/J
700 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
701 data <<COMMIT
702 create J
703 COMMIT
705 from refs/heads/branch
707 reset refs/heads/J
709 commit refs/heads/J
710 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
711 data <<COMMIT
712 initialize J
713 COMMIT
715 INPUT_END
716 test_expect_success \
717 'J: reset existing branch creates empty commit' \
718 'git fast-import <input'
719 test_expect_success \
720 'J: branch has 1 commit, empty tree' \
721 'test 1 = `git rev-list J | wc -l` &&
722 test 0 = `git ls-tree J | wc -l`'
724 ###
725 ### series K
726 ###
728 cat >input <<INPUT_END
729 commit refs/heads/K
730 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
731 data <<COMMIT
732 create K
733 COMMIT
735 from refs/heads/branch
737 commit refs/heads/K
738 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
739 data <<COMMIT
740 redo K
741 COMMIT
743 from refs/heads/branch^1
745 INPUT_END
746 test_expect_success \
747 'K: reinit branch with from' \
748 'git fast-import <input'
749 test_expect_success \
750 'K: verify K^1 = branch^1' \
751 'test `git rev-parse --verify branch^1` \
752 = `git rev-parse --verify K^1`'
754 ###
755 ### series L
756 ###
758 cat >input <<INPUT_END
759 blob
760 mark :1
761 data <<EOF
762 some data
763 EOF
765 blob
766 mark :2
767 data <<EOF
768 other data
769 EOF
771 commit refs/heads/L
772 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
773 data <<COMMIT
774 create L
775 COMMIT
777 M 644 :1 b.
778 M 644 :1 b/other
779 M 644 :1 ba
781 commit refs/heads/L
782 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
783 data <<COMMIT
784 update L
785 COMMIT
787 M 644 :2 b.
788 M 644 :2 b/other
789 M 644 :2 ba
790 INPUT_END
792 cat >expect <<EXPECT_END
793 :100644 100644 4268632... 55d3a52... M b.
794 :040000 040000 0ae5cac... 443c768... M b
795 :100644 100644 4268632... 55d3a52... M ba
796 EXPECT_END
798 test_expect_success \
799 'L: verify internal tree sorting' \
800 'git fast-import <input &&
801 git diff-tree --abbrev --raw L^ L >output &&
802 test_cmp expect output'
804 ###
805 ### series M
806 ###
808 test_tick
809 cat >input <<INPUT_END
810 commit refs/heads/M1
811 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
812 data <<COMMIT
813 file rename
814 COMMIT
816 from refs/heads/branch^0
817 R file2/newf file2/n.e.w.f
819 INPUT_END
821 cat >expect <<EOF
822 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
823 EOF
824 test_expect_success \
825 'M: rename file in same subdirectory' \
826 'git fast-import <input &&
827 git diff-tree -M -r M1^ M1 >actual &&
828 compare_diff_raw expect actual'
830 cat >input <<INPUT_END
831 commit refs/heads/M2
832 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
833 data <<COMMIT
834 file rename
835 COMMIT
837 from refs/heads/branch^0
838 R file2/newf i/am/new/to/you
840 INPUT_END
842 cat >expect <<EOF
843 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
844 EOF
845 test_expect_success \
846 'M: rename file to new subdirectory' \
847 'git fast-import <input &&
848 git diff-tree -M -r M2^ M2 >actual &&
849 compare_diff_raw expect actual'
851 cat >input <<INPUT_END
852 commit refs/heads/M3
853 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
854 data <<COMMIT
855 file rename
856 COMMIT
858 from refs/heads/M2^0
859 R i other/sub
861 INPUT_END
863 cat >expect <<EOF
864 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
865 EOF
866 test_expect_success \
867 'M: rename subdirectory to new subdirectory' \
868 'git fast-import <input &&
869 git diff-tree -M -r M3^ M3 >actual &&
870 compare_diff_raw expect actual'
872 ###
873 ### series N
874 ###
876 test_tick
877 cat >input <<INPUT_END
878 commit refs/heads/N1
879 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
880 data <<COMMIT
881 file copy
882 COMMIT
884 from refs/heads/branch^0
885 C file2/newf file2/n.e.w.f
887 INPUT_END
889 cat >expect <<EOF
890 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
891 EOF
892 test_expect_success \
893 'N: copy file in same subdirectory' \
894 'git fast-import <input &&
895 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
896 compare_diff_raw expect actual'
898 cat >input <<INPUT_END
899 commit refs/heads/N2
900 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
901 data <<COMMIT
902 clean directory copy
903 COMMIT
905 from refs/heads/branch^0
906 C file2 file3
908 commit refs/heads/N2
909 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
910 data <<COMMIT
911 modify directory copy
912 COMMIT
914 M 644 inline file3/file5
915 data <<EOF
916 $file5_data
917 EOF
919 INPUT_END
921 cat >expect <<EOF
922 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
923 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
924 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
925 EOF
926 test_expect_success \
927 'N: copy then modify subdirectory' \
928 'git fast-import <input &&
929 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
930 compare_diff_raw expect actual'
932 cat >input <<INPUT_END
933 commit refs/heads/N3
934 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
935 data <<COMMIT
936 dirty directory copy
937 COMMIT
939 from refs/heads/branch^0
940 M 644 inline file2/file5
941 data <<EOF
942 $file5_data
943 EOF
945 C file2 file3
946 D file2/file5
948 INPUT_END
950 test_expect_success \
951 'N: copy dirty subdirectory' \
952 'git fast-import <input &&
953 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
955 test_expect_success \
956 'N: copy directory by id' \
957 'cat >expect <<-\EOF &&
958 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
959 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
960 EOF
961 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
962 cat >input <<-INPUT_END &&
963 commit refs/heads/N4
964 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
965 data <<COMMIT
966 copy by tree hash
967 COMMIT
969 from refs/heads/branch^0
970 M 040000 $subdir file3
971 INPUT_END
972 git fast-import <input &&
973 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
974 compare_diff_raw expect actual'
976 test_expect_success PIPE 'N: read and copy directory' '
977 cat >expect <<-\EOF
978 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
979 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
980 EOF
981 git update-ref -d refs/heads/N4 &&
982 rm -f backflow &&
983 mkfifo backflow &&
984 (
985 exec <backflow &&
986 cat <<-EOF &&
987 commit refs/heads/N4
988 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
989 data <<COMMIT
990 copy by tree hash, part 2
991 COMMIT
993 from refs/heads/branch^0
994 ls "file2"
995 EOF
996 read mode type tree filename &&
997 echo "M 040000 $tree file3"
998 ) |
999 git fast-import --cat-blob-fd=3 3>backflow &&
1000 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1001 compare_diff_raw expect actual
1002 '
1004 test_expect_success PIPE 'N: empty directory reads as missing' '
1005 cat <<-\EOF >expect &&
1006 OBJNAME
1007 :000000 100644 OBJNAME OBJNAME A unrelated
1008 EOF
1009 echo "missing src" >expect.response &&
1010 git update-ref -d refs/heads/read-empty &&
1011 rm -f backflow &&
1012 mkfifo backflow &&
1013 (
1014 exec <backflow &&
1015 cat <<-EOF &&
1016 commit refs/heads/read-empty
1017 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1018 data <<COMMIT
1019 read "empty" (missing) directory
1020 COMMIT
1022 M 100644 inline src/greeting
1023 data <<BLOB
1024 hello
1025 BLOB
1026 C src/greeting dst1/non-greeting
1027 C src/greeting unrelated
1028 # leave behind "empty" src directory
1029 D src/greeting
1030 ls "src"
1031 EOF
1032 read -r line &&
1033 printf "%s\n" "$line" >response &&
1034 cat <<-\EOF
1035 D dst1
1036 D dst2
1037 EOF
1038 ) |
1039 git fast-import --cat-blob-fd=3 3>backflow &&
1040 test_cmp expect.response response &&
1041 git rev-list read-empty |
1042 git diff-tree -r --root --stdin |
1043 sed "s/$_x40/OBJNAME/g" >actual &&
1044 test_cmp expect actual
1045 '
1047 test_expect_success \
1048 'N: copy root directory by tree hash' \
1049 'cat >expect <<-\EOF &&
1050 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1051 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1052 EOF
1053 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1054 cat >input <<-INPUT_END &&
1055 commit refs/heads/N6
1056 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1057 data <<COMMIT
1058 copy root directory by tree hash
1059 COMMIT
1061 from refs/heads/branch^0
1062 M 040000 $root ""
1063 INPUT_END
1064 git fast-import <input &&
1065 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1066 compare_diff_raw expect actual'
1068 test_expect_success \
1069 'N: delete directory by copying' \
1070 'cat >expect <<-\EOF &&
1071 OBJID
1072 :100644 000000 OBJID OBJID D foo/bar/qux
1073 OBJID
1074 :000000 100644 OBJID OBJID A foo/bar/baz
1075 :000000 100644 OBJID OBJID A foo/bar/qux
1076 EOF
1077 empty_tree=$(git mktree </dev/null) &&
1078 cat >input <<-INPUT_END &&
1079 commit refs/heads/N-delete
1080 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1081 data <<COMMIT
1082 collect data to be deleted
1083 COMMIT
1085 deleteall
1086 M 100644 inline foo/bar/baz
1087 data <<DATA_END
1088 hello
1089 DATA_END
1090 C "foo/bar/baz" "foo/bar/qux"
1091 C "foo/bar/baz" "foo/bar/quux/1"
1092 C "foo/bar/baz" "foo/bar/quuux"
1093 M 040000 $empty_tree foo/bar/quux
1094 M 040000 $empty_tree foo/bar/quuux
1096 commit refs/heads/N-delete
1097 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1098 data <<COMMIT
1099 delete subdirectory
1100 COMMIT
1102 M 040000 $empty_tree foo/bar/qux
1103 INPUT_END
1104 git fast-import <input &&
1105 git rev-list N-delete |
1106 git diff-tree -r --stdin --root --always |
1107 sed -e "s/$_x40/OBJID/g" >actual &&
1108 test_cmp expect actual'
1110 test_expect_success \
1111 'N: modify copied tree' \
1112 'cat >expect <<-\EOF &&
1113 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1114 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1115 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1116 EOF
1117 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1118 cat >input <<-INPUT_END &&
1119 commit refs/heads/N5
1120 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1121 data <<COMMIT
1122 copy by tree hash
1123 COMMIT
1125 from refs/heads/branch^0
1126 M 040000 $subdir file3
1128 commit refs/heads/N5
1129 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1130 data <<COMMIT
1131 modify directory copy
1132 COMMIT
1134 M 644 inline file3/file5
1135 data <<EOF
1136 $file5_data
1137 EOF
1138 INPUT_END
1139 git fast-import <input &&
1140 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1141 compare_diff_raw expect actual'
1143 test_expect_success \
1144 'N: reject foo/ syntax' \
1145 'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1146 test_must_fail git fast-import <<-INPUT_END
1147 commit refs/heads/N5B
1148 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1149 data <<COMMIT
1150 copy with invalid syntax
1151 COMMIT
1153 from refs/heads/branch^0
1154 M 040000 $subdir file3/
1155 INPUT_END'
1157 test_expect_success \
1158 'N: copy to root by id and modify' \
1159 'echo "hello, world" >expect.foo &&
1160 echo hello >expect.bar &&
1161 git fast-import <<-SETUP_END &&
1162 commit refs/heads/N7
1163 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1164 data <<COMMIT
1165 hello, tree
1166 COMMIT
1168 deleteall
1169 M 644 inline foo/bar
1170 data <<EOF
1171 hello
1172 EOF
1173 SETUP_END
1175 tree=$(git rev-parse --verify N7:) &&
1176 git fast-import <<-INPUT_END &&
1177 commit refs/heads/N8
1178 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1179 data <<COMMIT
1180 copy to root by id and modify
1181 COMMIT
1183 M 040000 $tree ""
1184 M 644 inline foo/foo
1185 data <<EOF
1186 hello, world
1187 EOF
1188 INPUT_END
1189 git show N8:foo/foo >actual.foo &&
1190 git show N8:foo/bar >actual.bar &&
1191 test_cmp expect.foo actual.foo &&
1192 test_cmp expect.bar actual.bar'
1194 test_expect_success \
1195 'N: extract subtree' \
1196 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1197 cat >input <<-INPUT_END &&
1198 commit refs/heads/N9
1199 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1200 data <<COMMIT
1201 extract subtree branch:newdir
1202 COMMIT
1204 M 040000 $branch ""
1205 C "newdir" ""
1206 INPUT_END
1207 git fast-import <input &&
1208 git diff --exit-code branch:newdir N9'
1210 test_expect_success \
1211 'N: modify subtree, extract it, and modify again' \
1212 'echo hello >expect.baz &&
1213 echo hello, world >expect.qux &&
1214 git fast-import <<-SETUP_END &&
1215 commit refs/heads/N10
1216 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1217 data <<COMMIT
1218 hello, tree
1219 COMMIT
1221 deleteall
1222 M 644 inline foo/bar/baz
1223 data <<EOF
1224 hello
1225 EOF
1226 SETUP_END
1228 tree=$(git rev-parse --verify N10:) &&
1229 git fast-import <<-INPUT_END &&
1230 commit refs/heads/N11
1231 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1232 data <<COMMIT
1233 copy to root by id and modify
1234 COMMIT
1236 M 040000 $tree ""
1237 M 100644 inline foo/bar/qux
1238 data <<EOF
1239 hello, world
1240 EOF
1241 R "foo" ""
1242 C "bar/qux" "bar/quux"
1243 INPUT_END
1244 git show N11:bar/baz >actual.baz &&
1245 git show N11:bar/qux >actual.qux &&
1246 git show N11:bar/quux >actual.quux &&
1247 test_cmp expect.baz actual.baz &&
1248 test_cmp expect.qux actual.qux &&
1249 test_cmp expect.qux actual.quux'
1251 ###
1252 ### series O
1253 ###
1255 cat >input <<INPUT_END
1256 #we will
1257 commit refs/heads/O1
1258 # -- ignore all of this text
1259 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1260 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1261 data <<COMMIT
1262 dirty directory copy
1263 COMMIT
1265 # don't forget the import blank line!
1266 #
1267 # yes, we started from our usual base of branch^0.
1268 # i like branch^0.
1269 from refs/heads/branch^0
1270 # and we need to reuse file2/file5 from N3 above.
1271 M 644 inline file2/file5
1272 # otherwise the tree will be different
1273 data <<EOF
1274 $file5_data
1275 EOF
1277 # don't forget to copy file2 to file3
1278 C file2 file3
1279 #
1280 # or to delete file5 from file2.
1281 D file2/file5
1282 # are we done yet?
1284 INPUT_END
1286 test_expect_success \
1287 'O: comments are all skipped' \
1288 'git fast-import <input &&
1289 test `git rev-parse N3` = `git rev-parse O1`'
1291 cat >input <<INPUT_END
1292 commit refs/heads/O2
1293 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1294 data <<COMMIT
1295 dirty directory copy
1296 COMMIT
1297 from refs/heads/branch^0
1298 M 644 inline file2/file5
1299 data <<EOF
1300 $file5_data
1301 EOF
1302 C file2 file3
1303 D file2/file5
1305 INPUT_END
1307 test_expect_success \
1308 'O: blank lines not necessary after data commands' \
1309 'git fast-import <input &&
1310 test `git rev-parse N3` = `git rev-parse O2`'
1312 test_expect_success \
1313 'O: repack before next test' \
1314 'git repack -a -d'
1316 cat >input <<INPUT_END
1317 commit refs/heads/O3
1318 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1319 data <<COMMIT
1320 zstring
1321 COMMIT
1322 commit refs/heads/O3
1323 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1324 data <<COMMIT
1325 zof
1326 COMMIT
1327 checkpoint
1328 commit refs/heads/O3
1329 mark :5
1330 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1331 data <<COMMIT
1332 zempty
1333 COMMIT
1334 checkpoint
1335 commit refs/heads/O3
1336 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1337 data <<COMMIT
1338 zcommits
1339 COMMIT
1340 reset refs/tags/O3-2nd
1341 from :5
1342 reset refs/tags/O3-3rd
1343 from :5
1344 INPUT_END
1346 cat >expect <<INPUT_END
1347 string
1348 of
1349 empty
1350 commits
1351 INPUT_END
1352 test_expect_success \
1353 'O: blank lines not necessary after other commands' \
1354 'git fast-import <input &&
1355 test 8 = `find .git/objects/pack -type f | wc -l` &&
1356 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1357 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1358 test_cmp expect actual'
1360 cat >input <<INPUT_END
1361 commit refs/heads/O4
1362 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1363 data <<COMMIT
1364 zstring
1365 COMMIT
1366 commit refs/heads/O4
1367 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1368 data <<COMMIT
1369 zof
1370 COMMIT
1371 progress Two commits down, 2 to go!
1372 commit refs/heads/O4
1373 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1374 data <<COMMIT
1375 zempty
1376 COMMIT
1377 progress Three commits down, 1 to go!
1378 commit refs/heads/O4
1379 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1380 data <<COMMIT
1381 zcommits
1382 COMMIT
1383 progress I'm done!
1384 INPUT_END
1385 test_expect_success \
1386 'O: progress outputs as requested by input' \
1387 'git fast-import <input >actual &&
1388 grep "progress " <input >expect &&
1389 test_cmp expect actual'
1391 ###
1392 ### series P (gitlinks)
1393 ###
1395 cat >input <<INPUT_END
1396 blob
1397 mark :1
1398 data 10
1399 test file
1401 reset refs/heads/sub
1402 commit refs/heads/sub
1403 mark :2
1404 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1405 data 12
1406 sub_initial
1407 M 100644 :1 file
1409 blob
1410 mark :3
1411 data <<DATAEND
1412 [submodule "sub"]
1413 path = sub
1414 url = "`pwd`/sub"
1415 DATAEND
1417 commit refs/heads/subuse1
1418 mark :4
1419 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1420 data 8
1421 initial
1422 from refs/heads/master
1423 M 100644 :3 .gitmodules
1424 M 160000 :2 sub
1426 blob
1427 mark :5
1428 data 20
1429 test file
1430 more data
1432 commit refs/heads/sub
1433 mark :6
1434 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1435 data 11
1436 sub_second
1437 from :2
1438 M 100644 :5 file
1440 commit refs/heads/subuse1
1441 mark :7
1442 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1443 data 7
1444 second
1445 from :4
1446 M 160000 :6 sub
1448 INPUT_END
1450 test_expect_success \
1451 'P: supermodule & submodule mix' \
1452 'git fast-import <input &&
1453 git checkout subuse1 &&
1454 rm -rf sub && mkdir sub && (cd sub &&
1455 git init &&
1456 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1457 git checkout master) &&
1458 git submodule init &&
1459 git submodule update'
1461 SUBLAST=$(git rev-parse --verify sub)
1462 SUBPREV=$(git rev-parse --verify sub^)
1464 cat >input <<INPUT_END
1465 blob
1466 mark :1
1467 data <<DATAEND
1468 [submodule "sub"]
1469 path = sub
1470 url = "`pwd`/sub"
1471 DATAEND
1473 commit refs/heads/subuse2
1474 mark :2
1475 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1476 data 8
1477 initial
1478 from refs/heads/master
1479 M 100644 :1 .gitmodules
1480 M 160000 $SUBPREV sub
1482 commit refs/heads/subuse2
1483 mark :3
1484 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1485 data 7
1486 second
1487 from :2
1488 M 160000 $SUBLAST sub
1490 INPUT_END
1492 test_expect_success \
1493 'P: verbatim SHA gitlinks' \
1494 'git branch -D sub &&
1495 git gc && git prune &&
1496 git fast-import <input &&
1497 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1499 test_tick
1500 cat >input <<INPUT_END
1501 commit refs/heads/subuse3
1502 mark :1
1503 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1504 data <<COMMIT
1505 corrupt
1506 COMMIT
1508 from refs/heads/subuse2
1509 M 160000 inline sub
1510 data <<DATA
1511 $SUBPREV
1512 DATA
1514 INPUT_END
1516 test_expect_success 'P: fail on inline gitlink' '
1517 test_must_fail git fast-import <input'
1519 test_tick
1520 cat >input <<INPUT_END
1521 blob
1522 mark :1
1523 data <<DATA
1524 $SUBPREV
1525 DATA
1527 commit refs/heads/subuse3
1528 mark :2
1529 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1530 data <<COMMIT
1531 corrupt
1532 COMMIT
1534 from refs/heads/subuse2
1535 M 160000 :1 sub
1537 INPUT_END
1539 test_expect_success 'P: fail on blob mark in gitlink' '
1540 test_must_fail git fast-import <input'
1542 ###
1543 ### series Q (notes)
1544 ###
1546 note1_data="The first note for the first commit"
1547 note2_data="The first note for the second commit"
1548 note3_data="The first note for the third commit"
1549 note1b_data="The second note for the first commit"
1550 note1c_data="The third note for the first commit"
1551 note2b_data="The second note for the second commit"
1553 test_tick
1554 cat >input <<INPUT_END
1555 blob
1556 mark :2
1557 data <<EOF
1558 $file2_data
1559 EOF
1561 commit refs/heads/notes-test
1562 mark :3
1563 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1564 data <<COMMIT
1565 first (:3)
1566 COMMIT
1568 M 644 :2 file2
1570 blob
1571 mark :4
1572 data $file4_len
1573 $file4_data
1574 commit refs/heads/notes-test
1575 mark :5
1576 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1577 data <<COMMIT
1578 second (:5)
1579 COMMIT
1581 M 644 :4 file4
1583 commit refs/heads/notes-test
1584 mark :6
1585 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1586 data <<COMMIT
1587 third (:6)
1588 COMMIT
1590 M 644 inline file5
1591 data <<EOF
1592 $file5_data
1593 EOF
1595 M 755 inline file6
1596 data <<EOF
1597 $file6_data
1598 EOF
1600 blob
1601 mark :7
1602 data <<EOF
1603 $note1_data
1604 EOF
1606 blob
1607 mark :8
1608 data <<EOF
1609 $note2_data
1610 EOF
1612 commit refs/notes/foobar
1613 mark :9
1614 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1615 data <<COMMIT
1616 notes (:9)
1617 COMMIT
1619 N :7 :3
1620 N :8 :5
1621 N inline :6
1622 data <<EOF
1623 $note3_data
1624 EOF
1626 commit refs/notes/foobar
1627 mark :10
1628 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1629 data <<COMMIT
1630 notes (:10)
1631 COMMIT
1633 N inline :3
1634 data <<EOF
1635 $note1b_data
1636 EOF
1638 commit refs/notes/foobar2
1639 mark :11
1640 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1641 data <<COMMIT
1642 notes (:11)
1643 COMMIT
1645 N inline :3
1646 data <<EOF
1647 $note1c_data
1648 EOF
1650 commit refs/notes/foobar
1651 mark :12
1652 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1653 data <<COMMIT
1654 notes (:12)
1655 COMMIT
1657 deleteall
1658 N inline :5
1659 data <<EOF
1660 $note2b_data
1661 EOF
1663 INPUT_END
1665 test_expect_success \
1666 'Q: commit notes' \
1667 'git fast-import <input &&
1668 git whatchanged notes-test'
1669 test_expect_success \
1670 'Q: verify pack' \
1671 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1673 commit1=$(git rev-parse notes-test~2)
1674 commit2=$(git rev-parse notes-test^)
1675 commit3=$(git rev-parse notes-test)
1677 cat >expect <<EOF
1678 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1679 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1681 first (:3)
1682 EOF
1683 test_expect_success \
1684 'Q: verify first commit' \
1685 'git cat-file commit notes-test~2 | sed 1d >actual &&
1686 test_cmp expect actual'
1688 cat >expect <<EOF
1689 parent $commit1
1690 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1691 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1693 second (:5)
1694 EOF
1695 test_expect_success \
1696 'Q: verify second commit' \
1697 'git cat-file commit notes-test^ | sed 1d >actual &&
1698 test_cmp expect actual'
1700 cat >expect <<EOF
1701 parent $commit2
1702 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1703 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1705 third (:6)
1706 EOF
1707 test_expect_success \
1708 'Q: verify third commit' \
1709 'git cat-file commit notes-test | sed 1d >actual &&
1710 test_cmp expect actual'
1712 cat >expect <<EOF
1713 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1714 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1716 notes (:9)
1717 EOF
1718 test_expect_success \
1719 'Q: verify first notes commit' \
1720 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1721 test_cmp expect actual'
1723 cat >expect.unsorted <<EOF
1724 100644 blob $commit1
1725 100644 blob $commit2
1726 100644 blob $commit3
1727 EOF
1728 cat expect.unsorted | sort >expect
1729 test_expect_success \
1730 'Q: verify first notes tree' \
1731 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1732 test_cmp expect actual'
1734 echo "$note1_data" >expect
1735 test_expect_success \
1736 'Q: verify first note for first commit' \
1737 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1739 echo "$note2_data" >expect
1740 test_expect_success \
1741 'Q: verify first note for second commit' \
1742 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1744 echo "$note3_data" >expect
1745 test_expect_success \
1746 'Q: verify first note for third commit' \
1747 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1749 cat >expect <<EOF
1750 parent `git rev-parse --verify refs/notes/foobar~2`
1751 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1752 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1754 notes (:10)
1755 EOF
1756 test_expect_success \
1757 'Q: verify second notes commit' \
1758 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1759 test_cmp expect actual'
1761 cat >expect.unsorted <<EOF
1762 100644 blob $commit1
1763 100644 blob $commit2
1764 100644 blob $commit3
1765 EOF
1766 cat expect.unsorted | sort >expect
1767 test_expect_success \
1768 'Q: verify second notes tree' \
1769 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1770 test_cmp expect actual'
1772 echo "$note1b_data" >expect
1773 test_expect_success \
1774 'Q: verify second note for first commit' \
1775 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1777 echo "$note2_data" >expect
1778 test_expect_success \
1779 'Q: verify first note for second commit' \
1780 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1782 echo "$note3_data" >expect
1783 test_expect_success \
1784 'Q: verify first note for third commit' \
1785 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1787 cat >expect <<EOF
1788 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1789 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1791 notes (:11)
1792 EOF
1793 test_expect_success \
1794 'Q: verify third notes commit' \
1795 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1796 test_cmp expect actual'
1798 cat >expect.unsorted <<EOF
1799 100644 blob $commit1
1800 EOF
1801 cat expect.unsorted | sort >expect
1802 test_expect_success \
1803 'Q: verify third notes tree' \
1804 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1805 test_cmp expect actual'
1807 echo "$note1c_data" >expect
1808 test_expect_success \
1809 'Q: verify third note for first commit' \
1810 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1812 cat >expect <<EOF
1813 parent `git rev-parse --verify refs/notes/foobar^`
1814 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1815 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1817 notes (:12)
1818 EOF
1819 test_expect_success \
1820 'Q: verify fourth notes commit' \
1821 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1822 test_cmp expect actual'
1824 cat >expect.unsorted <<EOF
1825 100644 blob $commit2
1826 EOF
1827 cat expect.unsorted | sort >expect
1828 test_expect_success \
1829 'Q: verify fourth notes tree' \
1830 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1831 test_cmp expect actual'
1833 echo "$note2b_data" >expect
1834 test_expect_success \
1835 'Q: verify second note for second commit' \
1836 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1838 ###
1839 ### series R (feature and option)
1840 ###
1842 cat >input <<EOF
1843 feature no-such-feature-exists
1844 EOF
1846 test_expect_success 'R: abort on unsupported feature' '
1847 test_must_fail git fast-import <input
1848 '
1850 cat >input <<EOF
1851 feature date-format=now
1852 EOF
1854 test_expect_success 'R: supported feature is accepted' '
1855 git fast-import <input
1856 '
1858 cat >input << EOF
1859 blob
1860 data 3
1861 hi
1862 feature date-format=now
1863 EOF
1865 test_expect_success 'R: abort on receiving feature after data command' '
1866 test_must_fail git fast-import <input
1867 '
1869 cat >input << EOF
1870 feature import-marks=git.marks
1871 feature import-marks=git2.marks
1872 EOF
1874 test_expect_success 'R: only one import-marks feature allowed per stream' '
1875 test_must_fail git fast-import <input
1876 '
1878 cat >input << EOF
1879 feature export-marks=git.marks
1880 blob
1881 mark :1
1882 data 3
1883 hi
1885 EOF
1887 test_expect_success \
1888 'R: export-marks feature results in a marks file being created' \
1889 'cat input | git fast-import &&
1890 grep :1 git.marks'
1892 test_expect_success \
1893 'R: export-marks options can be overriden by commandline options' \
1894 'cat input | git fast-import --export-marks=other.marks &&
1895 grep :1 other.marks'
1897 test_expect_success 'R: catch typo in marks file name' '
1898 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
1899 echo "feature import-marks=nonexistent.marks" |
1900 test_must_fail git fast-import
1901 '
1903 test_expect_success 'R: import and output marks can be the same file' '
1904 rm -f io.marks &&
1905 blob=$(echo hi | git hash-object --stdin) &&
1906 cat >expect <<-EOF &&
1907 :1 $blob
1908 :2 $blob
1909 EOF
1910 git fast-import --export-marks=io.marks <<-\EOF &&
1911 blob
1912 mark :1
1913 data 3
1914 hi
1916 EOF
1917 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
1918 blob
1919 mark :2
1920 data 3
1921 hi
1923 EOF
1924 test_cmp expect io.marks
1925 '
1927 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
1928 rm -f io.marks &&
1929 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
1930 blob
1931 mark :1
1932 data 3
1933 hi
1935 EOF
1936 '
1938 test_expect_success 'R: --import-marks-if-exists' '
1939 rm -f io.marks &&
1940 blob=$(echo hi | git hash-object --stdin) &&
1941 echo ":1 $blob" >expect &&
1942 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
1943 blob
1944 mark :1
1945 data 3
1946 hi
1948 EOF
1949 test_cmp expect io.marks
1950 '
1952 cat >input << EOF
1953 feature import-marks=marks.out
1954 feature export-marks=marks.new
1955 EOF
1957 test_expect_success \
1958 'R: import to output marks works without any content' \
1959 'cat input | git fast-import &&
1960 test_cmp marks.out marks.new'
1962 cat >input <<EOF
1963 feature import-marks=nonexistent.marks
1964 feature export-marks=marks.new
1965 EOF
1967 test_expect_success \
1968 'R: import marks prefers commandline marks file over the stream' \
1969 'cat input | git fast-import --import-marks=marks.out &&
1970 test_cmp marks.out marks.new'
1973 cat >input <<EOF
1974 feature import-marks=nonexistent.marks
1975 feature export-marks=combined.marks
1976 EOF
1978 test_expect_success 'R: multiple --import-marks= should be honoured' '
1979 head -n2 marks.out > one.marks &&
1980 tail -n +3 marks.out > two.marks &&
1981 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1982 test_cmp marks.out combined.marks
1983 '
1985 cat >input <<EOF
1986 feature relative-marks
1987 feature import-marks=relative.in
1988 feature export-marks=relative.out
1989 EOF
1991 test_expect_success 'R: feature relative-marks should be honoured' '
1992 mkdir -p .git/info/fast-import/ &&
1993 cp marks.new .git/info/fast-import/relative.in &&
1994 git fast-import <input &&
1995 test_cmp marks.new .git/info/fast-import/relative.out
1996 '
1998 cat >input <<EOF
1999 feature relative-marks
2000 feature import-marks=relative.in
2001 feature no-relative-marks
2002 feature export-marks=non-relative.out
2003 EOF
2005 test_expect_success 'R: feature no-relative-marks should be honoured' '
2006 git fast-import <input &&
2007 test_cmp marks.new non-relative.out
2008 '
2010 test_expect_success 'R: feature ls supported' '
2011 echo "feature ls" |
2012 git fast-import
2013 '
2015 test_expect_success 'R: feature cat-blob supported' '
2016 echo "feature cat-blob" |
2017 git fast-import
2018 '
2020 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2021 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2022 '
2024 test_expect_success 'R: print old blob' '
2025 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2026 cat >expect <<-EOF &&
2027 ${blob} blob 11
2028 yes it can
2030 EOF
2031 echo "cat-blob $blob" |
2032 git fast-import --cat-blob-fd=6 6>actual &&
2033 test_cmp expect actual
2034 '
2036 test_expect_success 'R: in-stream cat-blob-fd not respected' '
2037 echo hello >greeting &&
2038 blob=$(git hash-object -w greeting) &&
2039 cat >expect <<-EOF &&
2040 ${blob} blob 6
2041 hello
2043 EOF
2044 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2045 cat-blob $blob
2046 EOF
2047 test_cmp expect actual.3 &&
2048 test_cmp empty actual.1 &&
2049 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2050 option cat-blob-fd=3
2051 cat-blob $blob
2052 EOF
2053 test_cmp empty actual.3 &&
2054 test_cmp expect actual.1
2055 '
2057 test_expect_success 'R: print new blob' '
2058 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2059 cat >expect <<-EOF &&
2060 ${blob} blob 12
2061 yep yep yep
2063 EOF
2064 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2065 blob
2066 mark :1
2067 data <<BLOB_END
2068 yep yep yep
2069 BLOB_END
2070 cat-blob :1
2071 EOF
2072 test_cmp expect actual
2073 '
2075 test_expect_success 'R: print new blob by sha1' '
2076 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2077 cat >expect <<-EOF &&
2078 ${blob} blob 25
2079 a new blob named by sha1
2081 EOF
2082 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2083 blob
2084 data <<BLOB_END
2085 a new blob named by sha1
2086 BLOB_END
2087 cat-blob $blob
2088 EOF
2089 test_cmp expect actual
2090 '
2092 test_expect_success 'setup: big file' '
2093 (
2094 echo "the quick brown fox jumps over the lazy dog" >big &&
2095 for i in 1 2 3
2096 do
2097 cat big big big big >bigger &&
2098 cat bigger bigger bigger bigger >big ||
2099 exit
2100 done
2101 )
2102 '
2104 test_expect_success 'R: print two blobs to stdout' '
2105 blob1=$(git hash-object big) &&
2106 blob1_len=$(wc -c <big) &&
2107 blob2=$(echo hello | git hash-object --stdin) &&
2108 {
2109 echo ${blob1} blob $blob1_len &&
2110 cat big &&
2111 cat <<-EOF
2113 ${blob2} blob 6
2114 hello
2116 EOF
2117 } >expect &&
2118 {
2119 cat <<-\END_PART1 &&
2120 blob
2121 mark :1
2122 data <<data_end
2123 END_PART1
2124 cat big &&
2125 cat <<-\EOF
2126 data_end
2127 blob
2128 mark :2
2129 data <<data_end
2130 hello
2131 data_end
2132 cat-blob :1
2133 cat-blob :2
2134 EOF
2135 } |
2136 git fast-import >actual &&
2137 test_cmp expect actual
2138 '
2140 test_expect_success PIPE 'R: copy using cat-file' '
2141 expect_id=$(git hash-object big) &&
2142 expect_len=$(wc -c <big) &&
2143 echo $expect_id blob $expect_len >expect.response &&
2145 rm -f blobs &&
2146 cat >frontend <<-\FRONTEND_END &&
2147 #!/bin/sh
2148 FRONTEND_END
2150 mkfifo blobs &&
2151 (
2152 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
2153 cat <<-\EOF &&
2154 feature cat-blob
2155 blob
2156 mark :1
2157 data <<BLOB
2158 EOF
2159 cat big &&
2160 cat <<-\EOF &&
2161 BLOB
2162 cat-blob :1
2163 EOF
2165 read blob_id type size <&3 &&
2166 echo "$blob_id $type $size" >response &&
2167 head_c $size >blob <&3 &&
2168 read newline <&3 &&
2170 cat <<-EOF &&
2171 commit refs/heads/copied
2172 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2173 data <<COMMIT
2174 copy big file as file3
2175 COMMIT
2176 M 644 inline file3
2177 data <<BLOB
2178 EOF
2179 cat blob &&
2180 echo BLOB
2181 ) 3<blobs |
2182 git fast-import --cat-blob-fd=3 3>blobs &&
2183 git show copied:file3 >actual &&
2184 test_cmp expect.response response &&
2185 test_cmp big actual
2186 '
2188 test_expect_success PIPE 'R: print blob mid-commit' '
2189 rm -f blobs &&
2190 echo "A blob from _before_ the commit." >expect &&
2191 mkfifo blobs &&
2192 (
2193 exec 3<blobs &&
2194 cat <<-EOF &&
2195 feature cat-blob
2196 blob
2197 mark :1
2198 data <<BLOB
2199 A blob from _before_ the commit.
2200 BLOB
2201 commit refs/heads/temporary
2202 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2203 data <<COMMIT
2204 Empty commit
2205 COMMIT
2206 cat-blob :1
2207 EOF
2209 read blob_id type size <&3 &&
2210 head_c $size >actual <&3 &&
2211 read newline <&3 &&
2213 echo
2214 ) |
2215 git fast-import --cat-blob-fd=3 3>blobs &&
2216 test_cmp expect actual
2217 '
2219 test_expect_success PIPE 'R: print staged blob within commit' '
2220 rm -f blobs &&
2221 echo "A blob from _within_ the commit." >expect &&
2222 mkfifo blobs &&
2223 (
2224 exec 3<blobs &&
2225 cat <<-EOF &&
2226 feature cat-blob
2227 commit refs/heads/within
2228 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2229 data <<COMMIT
2230 Empty commit
2231 COMMIT
2232 M 644 inline within
2233 data <<BLOB
2234 A blob from _within_ the commit.
2235 BLOB
2236 EOF
2238 to_get=$(
2239 echo "A blob from _within_ the commit." |
2240 git hash-object --stdin
2241 ) &&
2242 echo "cat-blob $to_get" &&
2244 read blob_id type size <&3 &&
2245 head_c $size >actual <&3 &&
2246 read newline <&3 &&
2248 echo deleteall
2249 ) |
2250 git fast-import --cat-blob-fd=3 3>blobs &&
2251 test_cmp expect actual
2252 '
2254 cat >input << EOF
2255 option git quiet
2256 blob
2257 data 3
2258 hi
2260 EOF
2262 test_expect_success 'R: quiet option results in no stats being output' '
2263 cat input | git fast-import 2> output &&
2264 test_cmp empty output
2265 '
2267 cat >input <<EOF
2268 option git non-existing-option
2269 EOF
2271 test_expect_success 'R: die on unknown option' '
2272 test_must_fail git fast-import <input
2273 '
2275 test_expect_success 'R: unknown commandline options are rejected' '\
2276 test_must_fail git fast-import --non-existing-option < /dev/null
2277 '
2279 test_expect_success 'R: die on invalid option argument' '
2280 echo "option git active-branches=-5" |
2281 test_must_fail git fast-import &&
2282 echo "option git depth=" |
2283 test_must_fail git fast-import &&
2284 test_must_fail git fast-import --depth="5 elephants" </dev/null
2285 '
2287 cat >input <<EOF
2288 option non-existing-vcs non-existing-option
2289 EOF
2291 test_expect_success 'R: ignore non-git options' '
2292 git fast-import <input
2293 '
2295 ##
2296 ## R: very large blobs
2297 ##
2298 blobsize=$((2*1024*1024 + 53))
2299 test-genrandom bar $blobsize >expect
2300 cat >input <<INPUT_END
2301 commit refs/heads/big-file
2302 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2303 data <<COMMIT
2304 R - big file
2305 COMMIT
2307 M 644 inline big1
2308 data $blobsize
2309 INPUT_END
2310 cat expect >>input
2311 cat >>input <<INPUT_END
2312 M 644 inline big2
2313 data $blobsize
2314 INPUT_END
2315 cat expect >>input
2316 echo >>input
2318 test_expect_success \
2319 'R: blob bigger than threshold' \
2320 'test_create_repo R &&
2321 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2322 test_expect_success \
2323 'R: verify created pack' \
2324 ': >verify &&
2325 for p in R/.git/objects/pack/*.pack;
2326 do
2327 git verify-pack -v $p >>verify || exit;
2328 done'
2329 test_expect_success \
2330 'R: verify written objects' \
2331 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2332 test_cmp expect actual &&
2333 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2334 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2335 test $a = $b'
2336 test_expect_success \
2337 'R: blob appears only once' \
2338 'n=$(grep $a verify | wc -l) &&
2339 test 1 = $n'
2341 test_done