fast-import: let importers retrieve blobs
[git/mingw.git] / t / t9300-fast-import.sh
bloba0162b73d9e63659f6ef9102daede32bce816f04
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 file2_data='file2
11 second line of EOF'
13 file3_data='EOF
14 in 3rd file
15 END'
17 file4_data=abcd
18 file4_len=4
20 file5_data='an inline file.
21 we should see it later.'
23 file6_data='#!/bin/sh
24 echo "$@"'
26 >empty
28 ###
29 ### series A
30 ###
32 test_tick
34 test_expect_success 'empty stream succeeds' '
35 git fast-import </dev/null
38 cat >input <<INPUT_END
39 blob
40 mark :2
41 data <<EOF
42 $file2_data
43 EOF
45 blob
46 mark :3
47 data <<END
48 $file3_data
49 END
51 blob
52 mark :4
53 data $file4_len
54 $file4_data
55 commit refs/heads/master
56 mark :5
57 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
58 data <<COMMIT
59 initial
60 COMMIT
62 M 644 :2 file2
63 M 644 :3 file3
64 M 755 :4 file4
66 tag series-A
67 from :5
68 data <<EOF
69 An annotated tag without a tagger
70 EOF
72 INPUT_END
73 test_expect_success \
74 'A: create pack from stdin' \
75 'git fast-import --export-marks=marks.out <input &&
76 git whatchanged master'
77 test_expect_success \
78 'A: verify pack' \
79 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
81 cat >expect <<EOF
82 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
83 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
85 initial
86 EOF
87 test_expect_success \
88 'A: verify commit' \
89 'git cat-file commit master | sed 1d >actual &&
90 test_cmp expect actual'
92 cat >expect <<EOF
93 100644 blob file2
94 100644 blob file3
95 100755 blob file4
96 EOF
97 test_expect_success \
98 'A: verify tree' \
99 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
100 test_cmp expect actual'
102 echo "$file2_data" >expect
103 test_expect_success \
104 'A: verify file2' \
105 'git cat-file blob master:file2 >actual && test_cmp expect actual'
107 echo "$file3_data" >expect
108 test_expect_success \
109 'A: verify file3' \
110 'git cat-file blob master:file3 >actual && test_cmp expect actual'
112 printf "$file4_data" >expect
113 test_expect_success \
114 'A: verify file4' \
115 'git cat-file blob master:file4 >actual && test_cmp expect actual'
117 cat >expect <<EOF
118 object $(git rev-parse refs/heads/master)
119 type commit
120 tag series-A
122 An annotated tag without a tagger
124 test_expect_success 'A: verify tag/series-A' '
125 git cat-file tag tags/series-A >actual &&
126 test_cmp expect actual
129 cat >expect <<EOF
130 :2 `git rev-parse --verify master:file2`
131 :3 `git rev-parse --verify master:file3`
132 :4 `git rev-parse --verify master:file4`
133 :5 `git rev-parse --verify master^0`
135 test_expect_success \
136 'A: verify marks output' \
137 'test_cmp expect marks.out'
139 test_expect_success \
140 'A: verify marks import' \
141 'git fast-import \
142 --import-marks=marks.out \
143 --export-marks=marks.new \
144 </dev/null &&
145 test_cmp expect marks.new'
147 test_tick
148 cat >input <<INPUT_END
149 commit refs/heads/verify--import-marks
150 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
151 data <<COMMIT
152 recreate from :5
153 COMMIT
155 from :5
156 M 755 :2 copy-of-file2
158 INPUT_END
159 test_expect_success \
160 'A: verify marks import does not crash' \
161 'git fast-import --import-marks=marks.out <input &&
162 git whatchanged verify--import-marks'
163 test_expect_success \
164 'A: verify pack' \
165 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
166 cat >expect <<EOF
167 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
169 git diff-tree -M -r master verify--import-marks >actual
170 test_expect_success \
171 'A: verify diff' \
172 'compare_diff_raw expect actual &&
173 test `git rev-parse --verify master:file2` \
174 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
176 test_tick
177 mt=$(git hash-object --stdin < /dev/null)
178 : >input.blob
179 : >marks.exp
180 : >tree.exp
182 cat >input.commit <<EOF
183 commit refs/heads/verify--dump-marks
184 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
185 data <<COMMIT
186 test the sparse array dumping routines with exponentially growing marks
187 COMMIT
194 while test "$i" -lt 27; do
195 cat >>input.blob <<EOF
196 blob
197 mark :$l
198 data 0
199 blob
200 mark :$m
201 data 0
202 blob
203 mark :$n
204 data 0
206 echo "M 100644 :$l l$i" >>input.commit
207 echo "M 100644 :$m m$i" >>input.commit
208 echo "M 100644 :$n n$i" >>input.commit
210 echo ":$l $mt" >>marks.exp
211 echo ":$m $mt" >>marks.exp
212 echo ":$n $mt" >>marks.exp
214 printf "100644 blob $mt\tl$i\n" >>tree.exp
215 printf "100644 blob $mt\tm$i\n" >>tree.exp
216 printf "100644 blob $mt\tn$i\n" >>tree.exp
218 l=$(($l + $l))
219 m=$(($m + $m))
220 n=$(($l + $n))
222 i=$((1 + $i))
223 done
225 sort tree.exp > tree.exp_s
227 test_expect_success 'A: export marks with large values' '
228 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
229 git ls-tree refs/heads/verify--dump-marks >tree.out &&
230 test_cmp tree.exp_s tree.out &&
231 test_cmp marks.exp marks.large'
234 ### series B
237 test_tick
238 cat >input <<INPUT_END
239 commit refs/heads/branch
240 mark :1
241 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
242 data <<COMMIT
243 corrupt
244 COMMIT
246 from refs/heads/master
247 M 755 0000000000000000000000000000000000000001 zero1
249 INPUT_END
250 test_expect_success 'B: fail on invalid blob sha1' '
251 test_must_fail git fast-import <input
253 rm -f .git/objects/pack_* .git/objects/index_*
255 cat >input <<INPUT_END
256 commit .badbranchname
257 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
258 data <<COMMIT
259 corrupt
260 COMMIT
262 from refs/heads/master
264 INPUT_END
265 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
266 test_must_fail git fast-import <input
268 rm -f .git/objects/pack_* .git/objects/index_*
270 cat >input <<INPUT_END
271 commit bad[branch]name
272 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
273 data <<COMMIT
274 corrupt
275 COMMIT
277 from refs/heads/master
279 INPUT_END
280 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
281 test_must_fail git fast-import <input
283 rm -f .git/objects/pack_* .git/objects/index_*
285 cat >input <<INPUT_END
286 commit TEMP_TAG
287 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
288 data <<COMMIT
289 tag base
290 COMMIT
292 from refs/heads/master
294 INPUT_END
295 test_expect_success \
296 'B: accept branch name "TEMP_TAG"' \
297 'git fast-import <input &&
298 test -f .git/TEMP_TAG &&
299 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
300 rm -f .git/TEMP_TAG
303 ### series C
306 newf=`echo hi newf | git hash-object -w --stdin`
307 oldf=`git rev-parse --verify master:file2`
308 test_tick
309 cat >input <<INPUT_END
310 commit refs/heads/branch
311 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
312 data <<COMMIT
313 second
314 COMMIT
316 from refs/heads/master
317 M 644 $oldf file2/oldf
318 M 755 $newf file2/newf
319 D file3
321 INPUT_END
322 test_expect_success \
323 'C: incremental import create pack from stdin' \
324 'git fast-import <input &&
325 git whatchanged branch'
326 test_expect_success \
327 'C: verify pack' \
328 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
329 test_expect_success \
330 'C: validate reuse existing blob' \
331 'test $newf = `git rev-parse --verify branch:file2/newf` &&
332 test $oldf = `git rev-parse --verify branch:file2/oldf`'
334 cat >expect <<EOF
335 parent `git rev-parse --verify master^0`
336 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
337 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
339 second
341 test_expect_success \
342 'C: verify commit' \
343 'git cat-file commit branch | sed 1d >actual &&
344 test_cmp expect actual'
346 cat >expect <<EOF
347 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
348 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
349 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
351 git diff-tree -M -r master branch >actual
352 test_expect_success \
353 'C: validate rename result' \
354 'compare_diff_raw expect actual'
357 ### series D
360 test_tick
361 cat >input <<INPUT_END
362 commit refs/heads/branch
363 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
364 data <<COMMIT
365 third
366 COMMIT
368 from refs/heads/branch^0
369 M 644 inline newdir/interesting
370 data <<EOF
371 $file5_data
374 M 755 inline newdir/exec.sh
375 data <<EOF
376 $file6_data
379 INPUT_END
380 test_expect_success \
381 'D: inline data in commit' \
382 'git fast-import <input &&
383 git whatchanged branch'
384 test_expect_success \
385 'D: verify pack' \
386 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
388 cat >expect <<EOF
389 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
390 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
392 git diff-tree -M -r branch^ branch >actual
393 test_expect_success \
394 'D: validate new files added' \
395 'compare_diff_raw expect actual'
397 echo "$file5_data" >expect
398 test_expect_success \
399 'D: verify file5' \
400 'git cat-file blob branch:newdir/interesting >actual &&
401 test_cmp expect actual'
403 echo "$file6_data" >expect
404 test_expect_success \
405 'D: verify file6' \
406 'git cat-file blob branch:newdir/exec.sh >actual &&
407 test_cmp expect actual'
410 ### series E
413 cat >input <<INPUT_END
414 commit refs/heads/branch
415 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
416 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
417 data <<COMMIT
418 RFC 2822 type date
419 COMMIT
421 from refs/heads/branch^0
423 INPUT_END
424 test_expect_success 'E: rfc2822 date, --date-format=raw' '
425 test_must_fail git fast-import --date-format=raw <input
427 test_expect_success \
428 'E: rfc2822 date, --date-format=rfc2822' \
429 'git fast-import --date-format=rfc2822 <input'
430 test_expect_success \
431 'E: verify pack' \
432 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
434 cat >expect <<EOF
435 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
436 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
438 RFC 2822 type date
440 test_expect_success \
441 'E: verify commit' \
442 'git cat-file commit branch | sed 1,2d >actual &&
443 test_cmp expect actual'
446 ### series F
449 old_branch=`git rev-parse --verify branch^0`
450 test_tick
451 cat >input <<INPUT_END
452 commit refs/heads/branch
453 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
454 data <<COMMIT
455 losing things already?
456 COMMIT
458 from refs/heads/branch~1
460 reset refs/heads/other
461 from refs/heads/branch
463 INPUT_END
464 test_expect_success \
465 'F: non-fast-forward update skips' \
466 'if git fast-import <input
467 then
468 echo BAD gfi did not fail
469 return 1
470 else
471 if test $old_branch = `git rev-parse --verify branch^0`
472 then
473 : branch unaffected and failure returned
474 return 0
475 else
476 echo BAD gfi changed branch $old_branch
477 return 1
481 test_expect_success \
482 'F: verify pack' \
483 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
485 cat >expect <<EOF
486 tree `git rev-parse branch~1^{tree}`
487 parent `git rev-parse branch~1`
488 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
489 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
491 losing things already?
493 test_expect_success \
494 'F: verify other commit' \
495 'git cat-file commit other >actual &&
496 test_cmp expect actual'
499 ### series G
502 old_branch=`git rev-parse --verify branch^0`
503 test_tick
504 cat >input <<INPUT_END
505 commit refs/heads/branch
506 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
507 data <<COMMIT
508 losing things already?
509 COMMIT
511 from refs/heads/branch~1
513 INPUT_END
514 test_expect_success \
515 'G: non-fast-forward update forced' \
516 'git fast-import --force <input'
517 test_expect_success \
518 'G: verify pack' \
519 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
520 test_expect_success \
521 'G: branch changed, but logged' \
522 'test $old_branch != `git rev-parse --verify branch^0` &&
523 test $old_branch = `git rev-parse --verify branch@{1}`'
526 ### series H
529 test_tick
530 cat >input <<INPUT_END
531 commit refs/heads/H
532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
533 data <<COMMIT
534 third
535 COMMIT
537 from refs/heads/branch^0
538 M 644 inline i-will-die
539 data <<EOF
540 this file will never exist.
543 deleteall
544 M 644 inline h/e/l/lo
545 data <<EOF
546 $file5_data
549 INPUT_END
550 test_expect_success \
551 'H: deletall, add 1' \
552 'git fast-import <input &&
553 git whatchanged H'
554 test_expect_success \
555 'H: verify pack' \
556 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
558 cat >expect <<EOF
559 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
560 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
561 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
562 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
563 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
565 git diff-tree -M -r H^ H >actual
566 test_expect_success \
567 'H: validate old files removed, new files added' \
568 'compare_diff_raw expect actual'
570 echo "$file5_data" >expect
571 test_expect_success \
572 'H: verify file' \
573 'git cat-file blob H:h/e/l/lo >actual &&
574 test_cmp expect actual'
577 ### series I
580 cat >input <<INPUT_END
581 commit refs/heads/export-boundary
582 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
583 data <<COMMIT
584 we have a border. its only 40 characters wide.
585 COMMIT
587 from refs/heads/branch
589 INPUT_END
590 test_expect_success \
591 'I: export-pack-edges' \
592 'git fast-import --export-pack-edges=edges.list <input'
594 cat >expect <<EOF
595 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
597 test_expect_success \
598 'I: verify edge list' \
599 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
600 test_cmp expect actual'
603 ### series J
606 cat >input <<INPUT_END
607 commit refs/heads/J
608 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
609 data <<COMMIT
610 create J
611 COMMIT
613 from refs/heads/branch
615 reset refs/heads/J
617 commit refs/heads/J
618 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
619 data <<COMMIT
620 initialize J
621 COMMIT
623 INPUT_END
624 test_expect_success \
625 'J: reset existing branch creates empty commit' \
626 'git fast-import <input'
627 test_expect_success \
628 'J: branch has 1 commit, empty tree' \
629 'test 1 = `git rev-list J | wc -l` &&
630 test 0 = `git ls-tree J | wc -l`'
633 ### series K
636 cat >input <<INPUT_END
637 commit refs/heads/K
638 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
639 data <<COMMIT
640 create K
641 COMMIT
643 from refs/heads/branch
645 commit refs/heads/K
646 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
647 data <<COMMIT
648 redo K
649 COMMIT
651 from refs/heads/branch^1
653 INPUT_END
654 test_expect_success \
655 'K: reinit branch with from' \
656 'git fast-import <input'
657 test_expect_success \
658 'K: verify K^1 = branch^1' \
659 'test `git rev-parse --verify branch^1` \
660 = `git rev-parse --verify K^1`'
663 ### series L
666 cat >input <<INPUT_END
667 blob
668 mark :1
669 data <<EOF
670 some data
673 blob
674 mark :2
675 data <<EOF
676 other data
679 commit refs/heads/L
680 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
681 data <<COMMIT
682 create L
683 COMMIT
685 M 644 :1 b.
686 M 644 :1 b/other
687 M 644 :1 ba
689 commit refs/heads/L
690 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
691 data <<COMMIT
692 update L
693 COMMIT
695 M 644 :2 b.
696 M 644 :2 b/other
697 M 644 :2 ba
698 INPUT_END
700 cat >expect <<EXPECT_END
701 :100644 100644 4268632... 55d3a52... M b.
702 :040000 040000 0ae5cac... 443c768... M b
703 :100644 100644 4268632... 55d3a52... M ba
704 EXPECT_END
706 test_expect_success \
707 'L: verify internal tree sorting' \
708 'git fast-import <input &&
709 git diff-tree --abbrev --raw L^ L >output &&
710 test_cmp expect output'
713 ### series M
716 test_tick
717 cat >input <<INPUT_END
718 commit refs/heads/M1
719 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
720 data <<COMMIT
721 file rename
722 COMMIT
724 from refs/heads/branch^0
725 R file2/newf file2/n.e.w.f
727 INPUT_END
729 cat >expect <<EOF
730 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
732 test_expect_success \
733 'M: rename file in same subdirectory' \
734 'git fast-import <input &&
735 git diff-tree -M -r M1^ M1 >actual &&
736 compare_diff_raw expect actual'
738 cat >input <<INPUT_END
739 commit refs/heads/M2
740 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
741 data <<COMMIT
742 file rename
743 COMMIT
745 from refs/heads/branch^0
746 R file2/newf i/am/new/to/you
748 INPUT_END
750 cat >expect <<EOF
751 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
753 test_expect_success \
754 'M: rename file to new subdirectory' \
755 'git fast-import <input &&
756 git diff-tree -M -r M2^ M2 >actual &&
757 compare_diff_raw expect actual'
759 cat >input <<INPUT_END
760 commit refs/heads/M3
761 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
762 data <<COMMIT
763 file rename
764 COMMIT
766 from refs/heads/M2^0
767 R i other/sub
769 INPUT_END
771 cat >expect <<EOF
772 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
774 test_expect_success \
775 'M: rename subdirectory to new subdirectory' \
776 'git fast-import <input &&
777 git diff-tree -M -r M3^ M3 >actual &&
778 compare_diff_raw expect actual'
781 ### series N
784 test_tick
785 cat >input <<INPUT_END
786 commit refs/heads/N1
787 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
788 data <<COMMIT
789 file copy
790 COMMIT
792 from refs/heads/branch^0
793 C file2/newf file2/n.e.w.f
795 INPUT_END
797 cat >expect <<EOF
798 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
800 test_expect_success \
801 'N: copy file in same subdirectory' \
802 'git fast-import <input &&
803 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
804 compare_diff_raw expect actual'
806 cat >input <<INPUT_END
807 commit refs/heads/N2
808 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
809 data <<COMMIT
810 clean directory copy
811 COMMIT
813 from refs/heads/branch^0
814 C file2 file3
816 commit refs/heads/N2
817 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
818 data <<COMMIT
819 modify directory copy
820 COMMIT
822 M 644 inline file3/file5
823 data <<EOF
824 $file5_data
827 INPUT_END
829 cat >expect <<EOF
830 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
831 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
832 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
834 test_expect_success \
835 'N: copy then modify subdirectory' \
836 'git fast-import <input &&
837 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
838 compare_diff_raw expect actual'
840 cat >input <<INPUT_END
841 commit refs/heads/N3
842 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
843 data <<COMMIT
844 dirty directory copy
845 COMMIT
847 from refs/heads/branch^0
848 M 644 inline file2/file5
849 data <<EOF
850 $file5_data
853 C file2 file3
854 D file2/file5
856 INPUT_END
858 test_expect_success \
859 'N: copy dirty subdirectory' \
860 'git fast-import <input &&
861 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
863 test_expect_success \
864 'N: copy directory by id' \
865 'cat >expect <<-\EOF &&
866 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
867 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
869 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
870 cat >input <<-INPUT_END &&
871 commit refs/heads/N4
872 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
873 data <<COMMIT
874 copy by tree hash
875 COMMIT
877 from refs/heads/branch^0
878 M 040000 $subdir file3
879 INPUT_END
880 git fast-import <input &&
881 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
882 compare_diff_raw expect actual'
884 test_expect_success \
885 'N: copy root directory by tree hash' \
886 'cat >expect <<-\EOF &&
887 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
888 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
890 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
891 cat >input <<-INPUT_END &&
892 commit refs/heads/N6
893 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
894 data <<COMMIT
895 copy root directory by tree hash
896 COMMIT
898 from refs/heads/branch^0
899 M 040000 $root ""
900 INPUT_END
901 git fast-import <input &&
902 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
903 compare_diff_raw expect actual'
905 test_expect_success \
906 'N: modify copied tree' \
907 'cat >expect <<-\EOF &&
908 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
909 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
910 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
912 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
913 cat >input <<-INPUT_END &&
914 commit refs/heads/N5
915 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
916 data <<COMMIT
917 copy by tree hash
918 COMMIT
920 from refs/heads/branch^0
921 M 040000 $subdir file3
923 commit refs/heads/N5
924 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
925 data <<COMMIT
926 modify directory copy
927 COMMIT
929 M 644 inline file3/file5
930 data <<EOF
931 $file5_data
933 INPUT_END
934 git fast-import <input &&
935 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
936 compare_diff_raw expect actual'
939 ### series O
942 cat >input <<INPUT_END
943 #we will
944 commit refs/heads/O1
945 # -- ignore all of this text
946 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
947 # $GIT_COMMITTER_NAME has inserted here for his benefit.
948 data <<COMMIT
949 dirty directory copy
950 COMMIT
952 # don't forget the import blank line!
954 # yes, we started from our usual base of branch^0.
955 # i like branch^0.
956 from refs/heads/branch^0
957 # and we need to reuse file2/file5 from N3 above.
958 M 644 inline file2/file5
959 # otherwise the tree will be different
960 data <<EOF
961 $file5_data
964 # don't forget to copy file2 to file3
965 C file2 file3
967 # or to delete file5 from file2.
968 D file2/file5
969 # are we done yet?
971 INPUT_END
973 test_expect_success \
974 'O: comments are all skipped' \
975 'git fast-import <input &&
976 test `git rev-parse N3` = `git rev-parse O1`'
978 cat >input <<INPUT_END
979 commit refs/heads/O2
980 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
981 data <<COMMIT
982 dirty directory copy
983 COMMIT
984 from refs/heads/branch^0
985 M 644 inline file2/file5
986 data <<EOF
987 $file5_data
989 C file2 file3
990 D file2/file5
992 INPUT_END
994 test_expect_success \
995 'O: blank lines not necessary after data commands' \
996 'git fast-import <input &&
997 test `git rev-parse N3` = `git rev-parse O2`'
999 test_expect_success \
1000 'O: repack before next test' \
1001 'git repack -a -d'
1003 cat >input <<INPUT_END
1004 commit refs/heads/O3
1005 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1006 data <<COMMIT
1007 zstring
1008 COMMIT
1009 commit refs/heads/O3
1010 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1011 data <<COMMIT
1013 COMMIT
1014 checkpoint
1015 commit refs/heads/O3
1016 mark :5
1017 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1018 data <<COMMIT
1019 zempty
1020 COMMIT
1021 checkpoint
1022 commit refs/heads/O3
1023 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1024 data <<COMMIT
1025 zcommits
1026 COMMIT
1027 reset refs/tags/O3-2nd
1028 from :5
1029 reset refs/tags/O3-3rd
1030 from :5
1031 INPUT_END
1033 cat >expect <<INPUT_END
1034 string
1036 empty
1037 commits
1038 INPUT_END
1039 test_expect_success \
1040 'O: blank lines not necessary after other commands' \
1041 'git fast-import <input &&
1042 test 8 = `find .git/objects/pack -type f | wc -l` &&
1043 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1044 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1045 test_cmp expect actual'
1047 cat >input <<INPUT_END
1048 commit refs/heads/O4
1049 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1050 data <<COMMIT
1051 zstring
1052 COMMIT
1053 commit refs/heads/O4
1054 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1055 data <<COMMIT
1057 COMMIT
1058 progress Two commits down, 2 to go!
1059 commit refs/heads/O4
1060 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1061 data <<COMMIT
1062 zempty
1063 COMMIT
1064 progress Three commits down, 1 to go!
1065 commit refs/heads/O4
1066 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1067 data <<COMMIT
1068 zcommits
1069 COMMIT
1070 progress I'm done!
1071 INPUT_END
1072 test_expect_success \
1073 'O: progress outputs as requested by input' \
1074 'git fast-import <input >actual &&
1075 grep "progress " <input >expect &&
1076 test_cmp expect actual'
1079 ### series P (gitlinks)
1082 cat >input <<INPUT_END
1083 blob
1084 mark :1
1085 data 10
1086 test file
1088 reset refs/heads/sub
1089 commit refs/heads/sub
1090 mark :2
1091 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1092 data 12
1093 sub_initial
1094 M 100644 :1 file
1096 blob
1097 mark :3
1098 data <<DATAEND
1099 [submodule "sub"]
1100 path = sub
1101 url = "`pwd`/sub"
1102 DATAEND
1104 commit refs/heads/subuse1
1105 mark :4
1106 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1107 data 8
1108 initial
1109 from refs/heads/master
1110 M 100644 :3 .gitmodules
1111 M 160000 :2 sub
1113 blob
1114 mark :5
1115 data 20
1116 test file
1117 more data
1119 commit refs/heads/sub
1120 mark :6
1121 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1122 data 11
1123 sub_second
1124 from :2
1125 M 100644 :5 file
1127 commit refs/heads/subuse1
1128 mark :7
1129 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1130 data 7
1131 second
1132 from :4
1133 M 160000 :6 sub
1135 INPUT_END
1137 test_expect_success \
1138 'P: supermodule & submodule mix' \
1139 'git fast-import <input &&
1140 git checkout subuse1 &&
1141 rm -rf sub && mkdir sub && (cd sub &&
1142 git init &&
1143 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1144 git checkout master) &&
1145 git submodule init &&
1146 git submodule update'
1148 SUBLAST=$(git rev-parse --verify sub)
1149 SUBPREV=$(git rev-parse --verify sub^)
1151 cat >input <<INPUT_END
1152 blob
1153 mark :1
1154 data <<DATAEND
1155 [submodule "sub"]
1156 path = sub
1157 url = "`pwd`/sub"
1158 DATAEND
1160 commit refs/heads/subuse2
1161 mark :2
1162 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1163 data 8
1164 initial
1165 from refs/heads/master
1166 M 100644 :1 .gitmodules
1167 M 160000 $SUBPREV sub
1169 commit refs/heads/subuse2
1170 mark :3
1171 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1172 data 7
1173 second
1174 from :2
1175 M 160000 $SUBLAST sub
1177 INPUT_END
1179 test_expect_success \
1180 'P: verbatim SHA gitlinks' \
1181 'git branch -D sub &&
1182 git gc && git prune &&
1183 git fast-import <input &&
1184 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1186 test_tick
1187 cat >input <<INPUT_END
1188 commit refs/heads/subuse3
1189 mark :1
1190 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1191 data <<COMMIT
1192 corrupt
1193 COMMIT
1195 from refs/heads/subuse2
1196 M 160000 inline sub
1197 data <<DATA
1198 $SUBPREV
1199 DATA
1201 INPUT_END
1203 test_expect_success 'P: fail on inline gitlink' '
1204 test_must_fail git fast-import <input'
1206 test_tick
1207 cat >input <<INPUT_END
1208 blob
1209 mark :1
1210 data <<DATA
1211 $SUBPREV
1212 DATA
1214 commit refs/heads/subuse3
1215 mark :2
1216 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1217 data <<COMMIT
1218 corrupt
1219 COMMIT
1221 from refs/heads/subuse2
1222 M 160000 :1 sub
1224 INPUT_END
1226 test_expect_success 'P: fail on blob mark in gitlink' '
1227 test_must_fail git fast-import <input'
1230 ### series Q (notes)
1233 note1_data="The first note for the first commit"
1234 note2_data="The first note for the second commit"
1235 note3_data="The first note for the third commit"
1236 note1b_data="The second note for the first commit"
1237 note1c_data="The third note for the first commit"
1238 note2b_data="The second note for the second commit"
1240 test_tick
1241 cat >input <<INPUT_END
1242 blob
1243 mark :2
1244 data <<EOF
1245 $file2_data
1248 commit refs/heads/notes-test
1249 mark :3
1250 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1251 data <<COMMIT
1252 first (:3)
1253 COMMIT
1255 M 644 :2 file2
1257 blob
1258 mark :4
1259 data $file4_len
1260 $file4_data
1261 commit refs/heads/notes-test
1262 mark :5
1263 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1264 data <<COMMIT
1265 second (:5)
1266 COMMIT
1268 M 644 :4 file4
1270 commit refs/heads/notes-test
1271 mark :6
1272 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1273 data <<COMMIT
1274 third (:6)
1275 COMMIT
1277 M 644 inline file5
1278 data <<EOF
1279 $file5_data
1282 M 755 inline file6
1283 data <<EOF
1284 $file6_data
1287 blob
1288 mark :7
1289 data <<EOF
1290 $note1_data
1293 blob
1294 mark :8
1295 data <<EOF
1296 $note2_data
1299 commit refs/notes/foobar
1300 mark :9
1301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1302 data <<COMMIT
1303 notes (:9)
1304 COMMIT
1306 N :7 :3
1307 N :8 :5
1308 N inline :6
1309 data <<EOF
1310 $note3_data
1313 commit refs/notes/foobar
1314 mark :10
1315 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1316 data <<COMMIT
1317 notes (:10)
1318 COMMIT
1320 N inline :3
1321 data <<EOF
1322 $note1b_data
1325 commit refs/notes/foobar2
1326 mark :11
1327 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1328 data <<COMMIT
1329 notes (:11)
1330 COMMIT
1332 N inline :3
1333 data <<EOF
1334 $note1c_data
1337 commit refs/notes/foobar
1338 mark :12
1339 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1340 data <<COMMIT
1341 notes (:12)
1342 COMMIT
1344 deleteall
1345 N inline :5
1346 data <<EOF
1347 $note2b_data
1350 INPUT_END
1352 test_expect_success \
1353 'Q: commit notes' \
1354 'git fast-import <input &&
1355 git whatchanged notes-test'
1356 test_expect_success \
1357 'Q: verify pack' \
1358 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1360 commit1=$(git rev-parse notes-test~2)
1361 commit2=$(git rev-parse notes-test^)
1362 commit3=$(git rev-parse notes-test)
1364 cat >expect <<EOF
1365 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1366 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1368 first (:3)
1370 test_expect_success \
1371 'Q: verify first commit' \
1372 'git cat-file commit notes-test~2 | sed 1d >actual &&
1373 test_cmp expect actual'
1375 cat >expect <<EOF
1376 parent $commit1
1377 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1378 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1380 second (:5)
1382 test_expect_success \
1383 'Q: verify second commit' \
1384 'git cat-file commit notes-test^ | sed 1d >actual &&
1385 test_cmp expect actual'
1387 cat >expect <<EOF
1388 parent $commit2
1389 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1390 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1392 third (:6)
1394 test_expect_success \
1395 'Q: verify third commit' \
1396 'git cat-file commit notes-test | sed 1d >actual &&
1397 test_cmp expect actual'
1399 cat >expect <<EOF
1400 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1401 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1403 notes (:9)
1405 test_expect_success \
1406 'Q: verify first notes commit' \
1407 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1408 test_cmp expect actual'
1410 cat >expect.unsorted <<EOF
1411 100644 blob $commit1
1412 100644 blob $commit2
1413 100644 blob $commit3
1415 cat expect.unsorted | sort >expect
1416 test_expect_success \
1417 'Q: verify first notes tree' \
1418 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1419 test_cmp expect actual'
1421 echo "$note1_data" >expect
1422 test_expect_success \
1423 'Q: verify first note for first commit' \
1424 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1426 echo "$note2_data" >expect
1427 test_expect_success \
1428 'Q: verify first note for second commit' \
1429 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1431 echo "$note3_data" >expect
1432 test_expect_success \
1433 'Q: verify first note for third commit' \
1434 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1436 cat >expect <<EOF
1437 parent `git rev-parse --verify refs/notes/foobar~2`
1438 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1439 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1441 notes (:10)
1443 test_expect_success \
1444 'Q: verify second notes commit' \
1445 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1446 test_cmp expect actual'
1448 cat >expect.unsorted <<EOF
1449 100644 blob $commit1
1450 100644 blob $commit2
1451 100644 blob $commit3
1453 cat expect.unsorted | sort >expect
1454 test_expect_success \
1455 'Q: verify second notes tree' \
1456 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1457 test_cmp expect actual'
1459 echo "$note1b_data" >expect
1460 test_expect_success \
1461 'Q: verify second note for first commit' \
1462 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1464 echo "$note2_data" >expect
1465 test_expect_success \
1466 'Q: verify first note for second commit' \
1467 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1469 echo "$note3_data" >expect
1470 test_expect_success \
1471 'Q: verify first note for third commit' \
1472 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1474 cat >expect <<EOF
1475 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1476 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1478 notes (:11)
1480 test_expect_success \
1481 'Q: verify third notes commit' \
1482 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1483 test_cmp expect actual'
1485 cat >expect.unsorted <<EOF
1486 100644 blob $commit1
1488 cat expect.unsorted | sort >expect
1489 test_expect_success \
1490 'Q: verify third notes tree' \
1491 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1492 test_cmp expect actual'
1494 echo "$note1c_data" >expect
1495 test_expect_success \
1496 'Q: verify third note for first commit' \
1497 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1499 cat >expect <<EOF
1500 parent `git rev-parse --verify refs/notes/foobar^`
1501 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1502 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1504 notes (:12)
1506 test_expect_success \
1507 'Q: verify fourth notes commit' \
1508 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1509 test_cmp expect actual'
1511 cat >expect.unsorted <<EOF
1512 100644 blob $commit2
1514 cat expect.unsorted | sort >expect
1515 test_expect_success \
1516 'Q: verify fourth notes tree' \
1517 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1518 test_cmp expect actual'
1520 echo "$note2b_data" >expect
1521 test_expect_success \
1522 'Q: verify second note for second commit' \
1523 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1526 ### series R (feature and option)
1529 cat >input <<EOF
1530 feature no-such-feature-exists
1533 test_expect_success 'R: abort on unsupported feature' '
1534 test_must_fail git fast-import <input
1537 cat >input <<EOF
1538 feature date-format=now
1541 test_expect_success 'R: supported feature is accepted' '
1542 git fast-import <input
1545 cat >input << EOF
1546 blob
1547 data 3
1549 feature date-format=now
1552 test_expect_success 'R: abort on receiving feature after data command' '
1553 test_must_fail git fast-import <input
1556 cat >input << EOF
1557 feature import-marks=git.marks
1558 feature import-marks=git2.marks
1561 test_expect_success 'R: only one import-marks feature allowed per stream' '
1562 test_must_fail git fast-import <input
1565 cat >input << EOF
1566 feature export-marks=git.marks
1567 blob
1568 mark :1
1569 data 3
1574 test_expect_success \
1575 'R: export-marks feature results in a marks file being created' \
1576 'cat input | git fast-import &&
1577 grep :1 git.marks'
1579 test_expect_success \
1580 'R: export-marks options can be overriden by commandline options' \
1581 'cat input | git fast-import --export-marks=other.marks &&
1582 grep :1 other.marks'
1584 cat >input << EOF
1585 feature import-marks=marks.out
1586 feature export-marks=marks.new
1589 test_expect_success \
1590 'R: import to output marks works without any content' \
1591 'cat input | git fast-import &&
1592 test_cmp marks.out marks.new'
1594 cat >input <<EOF
1595 feature import-marks=nonexistant.marks
1596 feature export-marks=marks.new
1599 test_expect_success \
1600 'R: import marks prefers commandline marks file over the stream' \
1601 'cat input | git fast-import --import-marks=marks.out &&
1602 test_cmp marks.out marks.new'
1605 cat >input <<EOF
1606 feature import-marks=nonexistant.marks
1607 feature export-marks=combined.marks
1610 test_expect_success 'R: multiple --import-marks= should be honoured' '
1611 head -n2 marks.out > one.marks &&
1612 tail -n +3 marks.out > two.marks &&
1613 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1614 test_cmp marks.out combined.marks
1617 cat >input <<EOF
1618 feature relative-marks
1619 feature import-marks=relative.in
1620 feature export-marks=relative.out
1623 test_expect_success 'R: feature relative-marks should be honoured' '
1624 mkdir -p .git/info/fast-import/ &&
1625 cp marks.new .git/info/fast-import/relative.in &&
1626 git fast-import <input &&
1627 test_cmp marks.new .git/info/fast-import/relative.out
1630 cat >input <<EOF
1631 feature relative-marks
1632 feature import-marks=relative.in
1633 feature no-relative-marks
1634 feature export-marks=non-relative.out
1637 test_expect_success 'R: feature no-relative-marks should be honoured' '
1638 git fast-import <input &&
1639 test_cmp marks.new non-relative.out
1642 test_expect_success 'R: feature cat-blob supported' '
1643 echo "feature cat-blob" |
1644 git fast-import
1647 test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
1648 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
1651 test_expect_success 'R: print old blob' '
1652 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
1653 cat >expect <<-EOF &&
1654 ${blob} blob 11
1655 yes it can
1658 echo "cat-blob $blob" |
1659 git fast-import --cat-blob-fd=6 6>actual &&
1660 test_cmp expect actual
1663 test_expect_success 'R: in-stream cat-blob-fd not respected' '
1664 echo hello >greeting &&
1665 blob=$(git hash-object -w greeting) &&
1666 cat >expect <<-EOF &&
1667 ${blob} blob 6
1668 hello
1671 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
1672 cat-blob $blob
1674 test_cmp expect actual.3 &&
1675 test_cmp empty actual.1 &&
1676 git fast-import 3>actual.3 >actual.1 <<-EOF &&
1677 option cat-blob-fd=3
1678 cat-blob $blob
1680 test_cmp empty actual.3 &&
1681 test_cmp expect actual.1
1684 test_expect_success 'R: print new blob' '
1685 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
1686 cat >expect <<-EOF &&
1687 ${blob} blob 12
1688 yep yep yep
1691 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
1692 blob
1693 mark :1
1694 data <<BLOB_END
1695 yep yep yep
1696 BLOB_END
1697 cat-blob :1
1699 test_cmp expect actual
1702 test_expect_success 'R: print new blob by sha1' '
1703 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
1704 cat >expect <<-EOF &&
1705 ${blob} blob 25
1706 a new blob named by sha1
1709 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
1710 blob
1711 data <<BLOB_END
1712 a new blob named by sha1
1713 BLOB_END
1714 cat-blob $blob
1716 test_cmp expect actual
1719 test_expect_success 'setup: big file' '
1721 echo "the quick brown fox jumps over the lazy dog" >big &&
1722 for i in 1 2 3
1724 cat big big big big >bigger &&
1725 cat bigger bigger bigger bigger >big ||
1726 exit
1727 done
1731 test_expect_success 'R: print two blobs to stdout' '
1732 blob1=$(git hash-object big) &&
1733 blob1_len=$(wc -c <big) &&
1734 blob2=$(echo hello | git hash-object --stdin) &&
1736 echo ${blob1} blob $blob1_len &&
1737 cat big &&
1738 cat <<-EOF
1740 ${blob2} blob 6
1741 hello
1744 } >expect &&
1746 cat <<-\END_PART1 &&
1747 blob
1748 mark :1
1749 data <<data_end
1750 END_PART1
1751 cat big &&
1752 cat <<-\EOF
1753 data_end
1754 blob
1755 mark :2
1756 data <<data_end
1757 hello
1758 data_end
1759 cat-blob :1
1760 cat-blob :2
1763 git fast-import >actual &&
1764 test_cmp expect actual
1767 test_expect_success 'setup: have pipes?' '
1768 rm -f frob &&
1769 if mkfifo frob
1770 then
1771 test_set_prereq PIPE
1775 test_expect_success PIPE 'R: copy using cat-file' '
1776 expect_id=$(git hash-object big) &&
1777 expect_len=$(wc -c <big) &&
1778 echo $expect_id blob $expect_len >expect.response &&
1780 rm -f blobs &&
1781 cat >frontend <<-\FRONTEND_END &&
1782 #!/bin/sh
1783 cat <<EOF &&
1784 feature cat-blob
1785 blob
1786 mark :1
1787 data <<BLOB
1789 cat big
1790 cat <<EOF
1791 BLOB
1792 cat-blob :1
1795 read blob_id type size <&3 &&
1796 echo "$blob_id $type $size" >response &&
1797 dd if=/dev/stdin of=blob bs=$size count=1 <&3 &&
1798 read newline <&3 &&
1800 cat <<EOF &&
1801 commit refs/heads/copied
1802 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1803 data <<COMMIT
1804 copy big file as file3
1805 COMMIT
1806 M 644 inline file3
1807 data <<BLOB
1809 cat blob &&
1810 cat <<EOF
1811 BLOB
1813 FRONTEND_END
1815 mkfifo blobs &&
1817 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
1818 sh frontend 3<blobs |
1819 git fast-import --cat-blob-fd=3 3>blobs
1820 ) &&
1821 git show copied:file3 >actual &&
1822 test_cmp expect.response response &&
1823 test_cmp big actual
1826 cat >input << EOF
1827 option git quiet
1828 blob
1829 data 3
1834 test_expect_success 'R: quiet option results in no stats being output' '
1835 cat input | git fast-import 2> output &&
1836 test_cmp empty output
1839 cat >input <<EOF
1840 option git non-existing-option
1843 test_expect_success 'R: die on unknown option' '
1844 test_must_fail git fast-import <input
1847 test_expect_success 'R: unknown commandline options are rejected' '\
1848 test_must_fail git fast-import --non-existing-option < /dev/null
1851 test_expect_success 'R: die on invalid option argument' '
1852 echo "option git active-branches=-5" |
1853 test_must_fail git fast-import &&
1854 echo "option git depth=" |
1855 test_must_fail git fast-import &&
1856 test_must_fail git fast-import --depth="5 elephants" </dev/null
1859 cat >input <<EOF
1860 option non-existing-vcs non-existing-option
1863 test_expect_success 'R: ignore non-git options' '
1864 git fast-import <input
1868 ## R: very large blobs
1870 blobsize=$((2*1024*1024 + 53))
1871 test-genrandom bar $blobsize >expect
1872 cat >input <<INPUT_END
1873 commit refs/heads/big-file
1874 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1875 data <<COMMIT
1876 R - big file
1877 COMMIT
1879 M 644 inline big1
1880 data $blobsize
1881 INPUT_END
1882 cat expect >>input
1883 cat >>input <<INPUT_END
1884 M 644 inline big2
1885 data $blobsize
1886 INPUT_END
1887 cat expect >>input
1888 echo >>input
1890 test_expect_success \
1891 'R: blob bigger than threshold' \
1892 'test_create_repo R &&
1893 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
1894 test_expect_success \
1895 'R: verify created pack' \
1896 ': >verify &&
1897 for p in R/.git/objects/pack/*.pack;
1899 git verify-pack -v $p >>verify || exit;
1900 done'
1901 test_expect_success \
1902 'R: verify written objects' \
1903 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
1904 test_cmp expect actual &&
1905 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
1906 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
1907 test $a = $b'
1908 test_expect_success \
1909 'R: blob appears only once' \
1910 'n=$(grep $a verify | wc -l) &&
1911 test 1 = $n'
1913 test_done