fast-import: treat filemodify with empty tree as delete
[git/dkf.git] / t / t9300-fast-import.sh
blob8487734ada77b4667c89665d255886c59cff8b22
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 ###
27 ### series A
28 ###
30 test_tick
31 cat >input <<INPUT_END
32 blob
33 mark :2
34 data <<EOF
35 $file2_data
36 EOF
38 blob
39 mark :3
40 data <<END
41 $file3_data
42 END
44 blob
45 mark :4
46 data $file4_len
47 $file4_data
48 commit refs/heads/master
49 mark :5
50 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
51 data <<COMMIT
52 initial
53 COMMIT
55 M 644 :2 file2
56 M 644 :3 file3
57 M 755 :4 file4
59 tag series-A
60 from :5
61 data <<EOF
62 An annotated tag without a tagger
63 EOF
65 INPUT_END
66 test_expect_success \
67 'A: create pack from stdin' \
68 'git fast-import --export-marks=marks.out <input &&
69 git whatchanged master'
70 test_expect_success \
71 'A: verify pack' \
72 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
74 cat >expect <<EOF
75 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
76 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
78 initial
79 EOF
80 test_expect_success \
81 'A: verify commit' \
82 'git cat-file commit master | sed 1d >actual &&
83 test_cmp expect actual'
85 cat >expect <<EOF
86 100644 blob file2
87 100644 blob file3
88 100755 blob file4
89 EOF
90 test_expect_success \
91 'A: verify tree' \
92 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
93 test_cmp expect actual'
95 echo "$file2_data" >expect
96 test_expect_success \
97 'A: verify file2' \
98 'git cat-file blob master:file2 >actual && test_cmp expect actual'
100 echo "$file3_data" >expect
101 test_expect_success \
102 'A: verify file3' \
103 'git cat-file blob master:file3 >actual && test_cmp expect actual'
105 printf "$file4_data" >expect
106 test_expect_success \
107 'A: verify file4' \
108 'git cat-file blob master:file4 >actual && test_cmp expect actual'
110 cat >expect <<EOF
111 object $(git rev-parse refs/heads/master)
112 type commit
113 tag series-A
115 An annotated tag without a tagger
117 test_expect_success 'A: verify tag/series-A' '
118 git cat-file tag tags/series-A >actual &&
119 test_cmp expect actual
122 cat >expect <<EOF
123 :2 `git rev-parse --verify master:file2`
124 :3 `git rev-parse --verify master:file3`
125 :4 `git rev-parse --verify master:file4`
126 :5 `git rev-parse --verify master^0`
128 test_expect_success \
129 'A: verify marks output' \
130 'test_cmp expect marks.out'
132 test_expect_success \
133 'A: verify marks import' \
134 'git fast-import \
135 --import-marks=marks.out \
136 --export-marks=marks.new \
137 </dev/null &&
138 test_cmp expect marks.new'
140 test_tick
141 cat >input <<INPUT_END
142 commit refs/heads/verify--import-marks
143 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
144 data <<COMMIT
145 recreate from :5
146 COMMIT
148 from :5
149 M 755 :2 copy-of-file2
151 INPUT_END
152 test_expect_success \
153 'A: verify marks import does not crash' \
154 'git fast-import --import-marks=marks.out <input &&
155 git whatchanged verify--import-marks'
156 test_expect_success \
157 'A: verify pack' \
158 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
159 cat >expect <<EOF
160 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
162 git diff-tree -M -r master verify--import-marks >actual
163 test_expect_success \
164 'A: verify diff' \
165 'compare_diff_raw expect actual &&
166 test `git rev-parse --verify master:file2` \
167 = `git rev-parse --verify verify--import-marks:copy-of-file2`'
170 ### series B
173 test_tick
174 cat >input <<INPUT_END
175 commit refs/heads/branch
176 mark :1
177 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
178 data <<COMMIT
179 corrupt
180 COMMIT
182 from refs/heads/master
183 M 755 0000000000000000000000000000000000000001 zero1
185 INPUT_END
186 test_expect_success 'B: fail on invalid blob sha1' '
187 test_must_fail git fast-import <input
189 rm -f .git/objects/pack_* .git/objects/index_*
191 cat >input <<INPUT_END
192 commit .badbranchname
193 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
194 data <<COMMIT
195 corrupt
196 COMMIT
198 from refs/heads/master
200 INPUT_END
201 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
202 test_must_fail git fast-import <input
204 rm -f .git/objects/pack_* .git/objects/index_*
206 cat >input <<INPUT_END
207 commit bad[branch]name
208 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
209 data <<COMMIT
210 corrupt
211 COMMIT
213 from refs/heads/master
215 INPUT_END
216 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
217 test_must_fail git fast-import <input
219 rm -f .git/objects/pack_* .git/objects/index_*
221 cat >input <<INPUT_END
222 commit TEMP_TAG
223 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
224 data <<COMMIT
225 tag base
226 COMMIT
228 from refs/heads/master
230 INPUT_END
231 test_expect_success \
232 'B: accept branch name "TEMP_TAG"' \
233 'git fast-import <input &&
234 test -f .git/TEMP_TAG &&
235 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
236 rm -f .git/TEMP_TAG
239 ### series C
242 newf=`echo hi newf | git hash-object -w --stdin`
243 oldf=`git rev-parse --verify master:file2`
244 test_tick
245 cat >input <<INPUT_END
246 commit refs/heads/branch
247 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
248 data <<COMMIT
249 second
250 COMMIT
252 from refs/heads/master
253 M 644 $oldf file2/oldf
254 M 755 $newf file2/newf
255 D file3
257 INPUT_END
258 test_expect_success \
259 'C: incremental import create pack from stdin' \
260 'git fast-import <input &&
261 git whatchanged branch'
262 test_expect_success \
263 'C: verify pack' \
264 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
265 test_expect_success \
266 'C: validate reuse existing blob' \
267 'test $newf = `git rev-parse --verify branch:file2/newf`
268 test $oldf = `git rev-parse --verify branch:file2/oldf`'
270 cat >expect <<EOF
271 parent `git rev-parse --verify master^0`
272 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
273 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
275 second
277 test_expect_success \
278 'C: verify commit' \
279 'git cat-file commit branch | sed 1d >actual &&
280 test_cmp expect actual'
282 cat >expect <<EOF
283 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
284 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
285 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
287 git diff-tree -M -r master branch >actual
288 test_expect_success \
289 'C: validate rename result' \
290 'compare_diff_raw expect actual'
293 ### series D
296 test_tick
297 cat >input <<INPUT_END
298 commit refs/heads/branch
299 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
300 data <<COMMIT
301 third
302 COMMIT
304 from refs/heads/branch^0
305 M 644 inline newdir/interesting
306 data <<EOF
307 $file5_data
310 M 755 inline newdir/exec.sh
311 data <<EOF
312 $file6_data
315 INPUT_END
316 test_expect_success \
317 'D: inline data in commit' \
318 'git fast-import <input &&
319 git whatchanged branch'
320 test_expect_success \
321 'D: verify pack' \
322 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
324 cat >expect <<EOF
325 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
326 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
328 git diff-tree -M -r branch^ branch >actual
329 test_expect_success \
330 'D: validate new files added' \
331 'compare_diff_raw expect actual'
333 echo "$file5_data" >expect
334 test_expect_success \
335 'D: verify file5' \
336 'git cat-file blob branch:newdir/interesting >actual &&
337 test_cmp expect actual'
339 echo "$file6_data" >expect
340 test_expect_success \
341 'D: verify file6' \
342 'git cat-file blob branch:newdir/exec.sh >actual &&
343 test_cmp expect actual'
346 ### series E
349 cat >input <<INPUT_END
350 commit refs/heads/branch
351 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
352 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
353 data <<COMMIT
354 RFC 2822 type date
355 COMMIT
357 from refs/heads/branch^0
359 INPUT_END
360 test_expect_success 'E: rfc2822 date, --date-format=raw' '
361 test_must_fail git fast-import --date-format=raw <input
363 test_expect_success \
364 'E: rfc2822 date, --date-format=rfc2822' \
365 'git fast-import --date-format=rfc2822 <input'
366 test_expect_success \
367 'E: verify pack' \
368 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
370 cat >expect <<EOF
371 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
372 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
374 RFC 2822 type date
376 test_expect_success \
377 'E: verify commit' \
378 'git cat-file commit branch | sed 1,2d >actual &&
379 test_cmp expect actual'
382 ### series F
385 old_branch=`git rev-parse --verify branch^0`
386 test_tick
387 cat >input <<INPUT_END
388 commit refs/heads/branch
389 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
390 data <<COMMIT
391 losing things already?
392 COMMIT
394 from refs/heads/branch~1
396 reset refs/heads/other
397 from refs/heads/branch
399 INPUT_END
400 test_expect_success \
401 'F: non-fast-forward update skips' \
402 'if git fast-import <input
403 then
404 echo BAD gfi did not fail
405 return 1
406 else
407 if test $old_branch = `git rev-parse --verify branch^0`
408 then
409 : branch unaffected and failure returned
410 return 0
411 else
412 echo BAD gfi changed branch $old_branch
413 return 1
417 test_expect_success \
418 'F: verify pack' \
419 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
421 cat >expect <<EOF
422 tree `git rev-parse branch~1^{tree}`
423 parent `git rev-parse branch~1`
424 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
425 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
427 losing things already?
429 test_expect_success \
430 'F: verify other commit' \
431 'git cat-file commit other >actual &&
432 test_cmp expect actual'
435 ### series G
438 old_branch=`git rev-parse --verify branch^0`
439 test_tick
440 cat >input <<INPUT_END
441 commit refs/heads/branch
442 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
443 data <<COMMIT
444 losing things already?
445 COMMIT
447 from refs/heads/branch~1
449 INPUT_END
450 test_expect_success \
451 'G: non-fast-forward update forced' \
452 'git fast-import --force <input'
453 test_expect_success \
454 'G: verify pack' \
455 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
456 test_expect_success \
457 'G: branch changed, but logged' \
458 'test $old_branch != `git rev-parse --verify branch^0` &&
459 test $old_branch = `git rev-parse --verify branch@{1}`'
462 ### series H
465 test_tick
466 cat >input <<INPUT_END
467 commit refs/heads/H
468 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
469 data <<COMMIT
470 third
471 COMMIT
473 from refs/heads/branch^0
474 M 644 inline i-will-die
475 data <<EOF
476 this file will never exist.
479 deleteall
480 M 644 inline h/e/l/lo
481 data <<EOF
482 $file5_data
485 INPUT_END
486 test_expect_success \
487 'H: deletall, add 1' \
488 'git fast-import <input &&
489 git whatchanged H'
490 test_expect_success \
491 'H: verify pack' \
492 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
494 cat >expect <<EOF
495 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
496 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
497 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
498 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
499 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
501 git diff-tree -M -r H^ H >actual
502 test_expect_success \
503 'H: validate old files removed, new files added' \
504 'compare_diff_raw expect actual'
506 echo "$file5_data" >expect
507 test_expect_success \
508 'H: verify file' \
509 'git cat-file blob H:h/e/l/lo >actual &&
510 test_cmp expect actual'
513 ### series I
516 cat >input <<INPUT_END
517 commit refs/heads/export-boundary
518 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
519 data <<COMMIT
520 we have a border. its only 40 characters wide.
521 COMMIT
523 from refs/heads/branch
525 INPUT_END
526 test_expect_success \
527 'I: export-pack-edges' \
528 'git fast-import --export-pack-edges=edges.list <input'
530 cat >expect <<EOF
531 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
533 test_expect_success \
534 'I: verify edge list' \
535 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
536 test_cmp expect actual'
539 ### series J
542 cat >input <<INPUT_END
543 commit refs/heads/J
544 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
545 data <<COMMIT
546 create J
547 COMMIT
549 from refs/heads/branch
551 reset refs/heads/J
553 commit refs/heads/J
554 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
555 data <<COMMIT
556 initialize J
557 COMMIT
559 INPUT_END
560 test_expect_success \
561 'J: reset existing branch creates empty commit' \
562 'git fast-import <input'
563 test_expect_success \
564 'J: branch has 1 commit, empty tree' \
565 'test 1 = `git rev-list J | wc -l` &&
566 test 0 = `git ls-tree J | wc -l`'
569 ### series K
572 cat >input <<INPUT_END
573 commit refs/heads/K
574 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
575 data <<COMMIT
576 create K
577 COMMIT
579 from refs/heads/branch
581 commit refs/heads/K
582 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
583 data <<COMMIT
584 redo K
585 COMMIT
587 from refs/heads/branch^1
589 INPUT_END
590 test_expect_success \
591 'K: reinit branch with from' \
592 'git fast-import <input'
593 test_expect_success \
594 'K: verify K^1 = branch^1' \
595 'test `git rev-parse --verify branch^1` \
596 = `git rev-parse --verify K^1`'
599 ### series L
602 cat >input <<INPUT_END
603 blob
604 mark :1
605 data <<EOF
606 some data
609 blob
610 mark :2
611 data <<EOF
612 other data
615 commit refs/heads/L
616 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
617 data <<COMMIT
618 create L
619 COMMIT
621 M 644 :1 b.
622 M 644 :1 b/other
623 M 644 :1 ba
625 commit refs/heads/L
626 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
627 data <<COMMIT
628 update L
629 COMMIT
631 M 644 :2 b.
632 M 644 :2 b/other
633 M 644 :2 ba
634 INPUT_END
636 cat >expect <<EXPECT_END
637 :100644 100644 4268632... 55d3a52... M b.
638 :040000 040000 0ae5cac... 443c768... M b
639 :100644 100644 4268632... 55d3a52... M ba
640 EXPECT_END
642 test_expect_success \
643 'L: verify internal tree sorting' \
644 'git fast-import <input &&
645 git diff-tree --abbrev --raw L^ L >output &&
646 test_cmp expect output'
649 ### series M
652 test_tick
653 cat >input <<INPUT_END
654 commit refs/heads/M1
655 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
656 data <<COMMIT
657 file rename
658 COMMIT
660 from refs/heads/branch^0
661 R file2/newf file2/n.e.w.f
663 INPUT_END
665 cat >expect <<EOF
666 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
668 test_expect_success \
669 'M: rename file in same subdirectory' \
670 'git fast-import <input &&
671 git diff-tree -M -r M1^ M1 >actual &&
672 compare_diff_raw expect actual'
674 cat >input <<INPUT_END
675 commit refs/heads/M2
676 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
677 data <<COMMIT
678 file rename
679 COMMIT
681 from refs/heads/branch^0
682 R file2/newf i/am/new/to/you
684 INPUT_END
686 cat >expect <<EOF
687 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
689 test_expect_success \
690 'M: rename file to new subdirectory' \
691 'git fast-import <input &&
692 git diff-tree -M -r M2^ M2 >actual &&
693 compare_diff_raw expect actual'
695 cat >input <<INPUT_END
696 commit refs/heads/M3
697 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
698 data <<COMMIT
699 file rename
700 COMMIT
702 from refs/heads/M2^0
703 R i other/sub
705 INPUT_END
707 cat >expect <<EOF
708 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
710 test_expect_success \
711 'M: rename subdirectory to new subdirectory' \
712 'git fast-import <input &&
713 git diff-tree -M -r M3^ M3 >actual &&
714 compare_diff_raw expect actual'
717 ### series N
720 test_tick
721 cat >input <<INPUT_END
722 commit refs/heads/N1
723 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
724 data <<COMMIT
725 file copy
726 COMMIT
728 from refs/heads/branch^0
729 C file2/newf file2/n.e.w.f
731 INPUT_END
733 cat >expect <<EOF
734 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
736 test_expect_success \
737 'N: copy file in same subdirectory' \
738 'git fast-import <input &&
739 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
740 compare_diff_raw expect actual'
742 cat >input <<INPUT_END
743 commit refs/heads/N2
744 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
745 data <<COMMIT
746 clean directory copy
747 COMMIT
749 from refs/heads/branch^0
750 C file2 file3
752 commit refs/heads/N2
753 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
754 data <<COMMIT
755 modify directory copy
756 COMMIT
758 M 644 inline file3/file5
759 data <<EOF
760 $file5_data
763 INPUT_END
765 cat >expect <<EOF
766 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
767 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
768 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
770 test_expect_success \
771 'N: copy then modify subdirectory' \
772 'git fast-import <input &&
773 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
774 compare_diff_raw expect actual'
776 cat >input <<INPUT_END
777 commit refs/heads/N3
778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
779 data <<COMMIT
780 dirty directory copy
781 COMMIT
783 from refs/heads/branch^0
784 M 644 inline file2/file5
785 data <<EOF
786 $file5_data
789 C file2 file3
790 D file2/file5
792 INPUT_END
794 test_expect_success \
795 'N: copy dirty subdirectory' \
796 'git fast-import <input &&
797 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
799 test_expect_success \
800 'N: copy directory by id' \
801 'cat >expect <<-\EOF &&
802 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
803 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
805 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
806 cat >input <<-INPUT_END &&
807 commit refs/heads/N4
808 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
809 data <<COMMIT
810 copy by tree hash
811 COMMIT
813 from refs/heads/branch^0
814 M 040000 $subdir file3
815 INPUT_END
816 git fast-import <input &&
817 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
818 compare_diff_raw expect actual'
820 test_expect_success \
821 'N: delete directory by copying' \
822 'cat >expect <<-\EOF &&
823 OBJID
824 :100644 000000 OBJID OBJID D foo/bar/qux
825 OBJID
826 :000000 100644 OBJID OBJID A foo/bar/baz
827 :000000 100644 OBJID OBJID A foo/bar/qux
829 empty_tree=$(git mktree </dev/null) &&
830 cat >input <<-INPUT_END &&
831 commit refs/heads/N-delete
832 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
833 data <<COMMIT
834 collect data to be deleted
835 COMMIT
837 deleteall
838 M 100644 inline foo/bar/baz
839 data <<DATA_END
840 hello
841 DATA_END
842 C "foo/bar/baz" "foo/bar/qux"
843 C "foo/bar/baz" "foo/bar/quux/1"
844 C "foo/bar/baz" "foo/bar/quuux"
845 M 040000 $empty_tree foo/bar/quux
846 M 040000 $empty_tree foo/bar/quuux
848 commit refs/heads/N-delete
849 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
850 data <<COMMIT
851 delete subdirectory
852 COMMIT
854 M 040000 $empty_tree foo/bar/qux
855 INPUT_END
856 git fast-import <input &&
857 git rev-list N-delete |
858 git diff-tree -r --stdin --root --always |
859 sed -e "s/$_x40/OBJID/g" >actual &&
860 test_cmp expect actual'
862 test_expect_success \
863 'N: modify copied tree' \
864 'cat >expect <<-\EOF &&
865 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
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/N5
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
880 commit refs/heads/N5
881 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
882 data <<COMMIT
883 modify directory copy
884 COMMIT
886 M 644 inline file3/file5
887 data <<EOF
888 $file5_data
890 INPUT_END
891 git fast-import <input &&
892 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
893 compare_diff_raw expect actual'
896 ### series O
899 cat >input <<INPUT_END
900 #we will
901 commit refs/heads/O1
902 # -- ignore all of this text
903 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
904 # $GIT_COMMITTER_NAME has inserted here for his benefit.
905 data <<COMMIT
906 dirty directory copy
907 COMMIT
909 # don't forget the import blank line!
911 # yes, we started from our usual base of branch^0.
912 # i like branch^0.
913 from refs/heads/branch^0
914 # and we need to reuse file2/file5 from N3 above.
915 M 644 inline file2/file5
916 # otherwise the tree will be different
917 data <<EOF
918 $file5_data
921 # don't forget to copy file2 to file3
922 C file2 file3
924 # or to delete file5 from file2.
925 D file2/file5
926 # are we done yet?
928 INPUT_END
930 test_expect_success \
931 'O: comments are all skipped' \
932 'git fast-import <input &&
933 test `git rev-parse N3` = `git rev-parse O1`'
935 cat >input <<INPUT_END
936 commit refs/heads/O2
937 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
938 data <<COMMIT
939 dirty directory copy
940 COMMIT
941 from refs/heads/branch^0
942 M 644 inline file2/file5
943 data <<EOF
944 $file5_data
946 C file2 file3
947 D file2/file5
949 INPUT_END
951 test_expect_success \
952 'O: blank lines not necessary after data commands' \
953 'git fast-import <input &&
954 test `git rev-parse N3` = `git rev-parse O2`'
956 test_expect_success \
957 'O: repack before next test' \
958 'git repack -a -d'
960 cat >input <<INPUT_END
961 commit refs/heads/O3
962 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
963 data <<COMMIT
964 zstring
965 COMMIT
966 commit refs/heads/O3
967 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
968 data <<COMMIT
970 COMMIT
971 checkpoint
972 commit refs/heads/O3
973 mark :5
974 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
975 data <<COMMIT
976 zempty
977 COMMIT
978 checkpoint
979 commit refs/heads/O3
980 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
981 data <<COMMIT
982 zcommits
983 COMMIT
984 reset refs/tags/O3-2nd
985 from :5
986 reset refs/tags/O3-3rd
987 from :5
988 INPUT_END
990 cat >expect <<INPUT_END
991 string
993 empty
994 commits
995 INPUT_END
996 test_expect_success \
997 'O: blank lines not necessary after other commands' \
998 'git fast-import <input &&
999 test 8 = `find .git/objects/pack -type f | wc -l` &&
1000 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1001 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1002 test_cmp expect actual'
1004 cat >input <<INPUT_END
1005 commit refs/heads/O4
1006 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1007 data <<COMMIT
1008 zstring
1009 COMMIT
1010 commit refs/heads/O4
1011 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1012 data <<COMMIT
1014 COMMIT
1015 progress Two commits down, 2 to go!
1016 commit refs/heads/O4
1017 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1018 data <<COMMIT
1019 zempty
1020 COMMIT
1021 progress Three commits down, 1 to go!
1022 commit refs/heads/O4
1023 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1024 data <<COMMIT
1025 zcommits
1026 COMMIT
1027 progress I'm done!
1028 INPUT_END
1029 test_expect_success \
1030 'O: progress outputs as requested by input' \
1031 'git fast-import <input >actual &&
1032 grep "progress " <input >expect &&
1033 test_cmp expect actual'
1036 ### series P (gitlinks)
1039 cat >input <<INPUT_END
1040 blob
1041 mark :1
1042 data 10
1043 test file
1045 reset refs/heads/sub
1046 commit refs/heads/sub
1047 mark :2
1048 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1049 data 12
1050 sub_initial
1051 M 100644 :1 file
1053 blob
1054 mark :3
1055 data <<DATAEND
1056 [submodule "sub"]
1057 path = sub
1058 url = "`pwd`/sub"
1059 DATAEND
1061 commit refs/heads/subuse1
1062 mark :4
1063 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1064 data 8
1065 initial
1066 from refs/heads/master
1067 M 100644 :3 .gitmodules
1068 M 160000 :2 sub
1070 blob
1071 mark :5
1072 data 20
1073 test file
1074 more data
1076 commit refs/heads/sub
1077 mark :6
1078 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1079 data 11
1080 sub_second
1081 from :2
1082 M 100644 :5 file
1084 commit refs/heads/subuse1
1085 mark :7
1086 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1087 data 7
1088 second
1089 from :4
1090 M 160000 :6 sub
1092 INPUT_END
1094 test_expect_success \
1095 'P: supermodule & submodule mix' \
1096 'git fast-import <input &&
1097 git checkout subuse1 &&
1098 rm -rf sub && mkdir sub && cd sub &&
1099 git init &&
1100 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1101 git checkout master &&
1102 cd .. &&
1103 git submodule init &&
1104 git submodule update'
1106 SUBLAST=$(git rev-parse --verify sub)
1107 SUBPREV=$(git rev-parse --verify sub^)
1109 cat >input <<INPUT_END
1110 blob
1111 mark :1
1112 data <<DATAEND
1113 [submodule "sub"]
1114 path = sub
1115 url = "`pwd`/sub"
1116 DATAEND
1118 commit refs/heads/subuse2
1119 mark :2
1120 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1121 data 8
1122 initial
1123 from refs/heads/master
1124 M 100644 :1 .gitmodules
1125 M 160000 $SUBPREV sub
1127 commit refs/heads/subuse2
1128 mark :3
1129 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1130 data 7
1131 second
1132 from :2
1133 M 160000 $SUBLAST sub
1135 INPUT_END
1137 test_expect_success \
1138 'P: verbatim SHA gitlinks' \
1139 'git branch -D sub &&
1140 git gc && git prune &&
1141 git fast-import <input &&
1142 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1144 test_tick
1145 cat >input <<INPUT_END
1146 commit refs/heads/subuse3
1147 mark :1
1148 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1149 data <<COMMIT
1150 corrupt
1151 COMMIT
1153 from refs/heads/subuse2
1154 M 160000 inline sub
1155 data <<DATA
1156 $SUBPREV
1157 DATA
1159 INPUT_END
1161 test_expect_success 'P: fail on inline gitlink' '
1162 test_must_fail git fast-import <input'
1164 test_tick
1165 cat >input <<INPUT_END
1166 blob
1167 mark :1
1168 data <<DATA
1169 $SUBPREV
1170 DATA
1172 commit refs/heads/subuse3
1173 mark :2
1174 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1175 data <<COMMIT
1176 corrupt
1177 COMMIT
1179 from refs/heads/subuse2
1180 M 160000 :1 sub
1182 INPUT_END
1184 test_expect_success 'P: fail on blob mark in gitlink' '
1185 test_must_fail git fast-import <input'
1188 ### series Q (notes)
1191 note1_data="The first note for the first commit"
1192 note2_data="The first note for the second commit"
1193 note3_data="The first note for the third commit"
1194 note1b_data="The second note for the first commit"
1195 note1c_data="The third note for the first commit"
1196 note2b_data="The second note for the second commit"
1198 test_tick
1199 cat >input <<INPUT_END
1200 blob
1201 mark :2
1202 data <<EOF
1203 $file2_data
1206 commit refs/heads/notes-test
1207 mark :3
1208 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1209 data <<COMMIT
1210 first (:3)
1211 COMMIT
1213 M 644 :2 file2
1215 blob
1216 mark :4
1217 data $file4_len
1218 $file4_data
1219 commit refs/heads/notes-test
1220 mark :5
1221 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1222 data <<COMMIT
1223 second (:5)
1224 COMMIT
1226 M 644 :4 file4
1228 commit refs/heads/notes-test
1229 mark :6
1230 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1231 data <<COMMIT
1232 third (:6)
1233 COMMIT
1235 M 644 inline file5
1236 data <<EOF
1237 $file5_data
1240 M 755 inline file6
1241 data <<EOF
1242 $file6_data
1245 blob
1246 mark :7
1247 data <<EOF
1248 $note1_data
1251 blob
1252 mark :8
1253 data <<EOF
1254 $note2_data
1257 commit refs/notes/foobar
1258 mark :9
1259 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1260 data <<COMMIT
1261 notes (:9)
1262 COMMIT
1264 N :7 :3
1265 N :8 :5
1266 N inline :6
1267 data <<EOF
1268 $note3_data
1271 commit refs/notes/foobar
1272 mark :10
1273 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1274 data <<COMMIT
1275 notes (:10)
1276 COMMIT
1278 N inline :3
1279 data <<EOF
1280 $note1b_data
1283 commit refs/notes/foobar2
1284 mark :11
1285 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1286 data <<COMMIT
1287 notes (:11)
1288 COMMIT
1290 N inline :3
1291 data <<EOF
1292 $note1c_data
1295 commit refs/notes/foobar
1296 mark :12
1297 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1298 data <<COMMIT
1299 notes (:12)
1300 COMMIT
1302 deleteall
1303 N inline :5
1304 data <<EOF
1305 $note2b_data
1308 INPUT_END
1310 test_expect_success \
1311 'Q: commit notes' \
1312 'git fast-import <input &&
1313 git whatchanged notes-test'
1314 test_expect_success \
1315 'Q: verify pack' \
1316 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1318 commit1=$(git rev-parse notes-test~2)
1319 commit2=$(git rev-parse notes-test^)
1320 commit3=$(git rev-parse notes-test)
1322 cat >expect <<EOF
1323 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1324 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1326 first (:3)
1328 test_expect_success \
1329 'Q: verify first commit' \
1330 'git cat-file commit notes-test~2 | sed 1d >actual &&
1331 test_cmp expect actual'
1333 cat >expect <<EOF
1334 parent $commit1
1335 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1336 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1338 second (:5)
1340 test_expect_success \
1341 'Q: verify second commit' \
1342 'git cat-file commit notes-test^ | sed 1d >actual &&
1343 test_cmp expect actual'
1345 cat >expect <<EOF
1346 parent $commit2
1347 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1348 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1350 third (:6)
1352 test_expect_success \
1353 'Q: verify third commit' \
1354 'git cat-file commit notes-test | sed 1d >actual &&
1355 test_cmp expect actual'
1357 cat >expect <<EOF
1358 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1359 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1361 notes (:9)
1363 test_expect_success \
1364 'Q: verify first notes commit' \
1365 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1366 test_cmp expect actual'
1368 cat >expect.unsorted <<EOF
1369 100644 blob $commit1
1370 100644 blob $commit2
1371 100644 blob $commit3
1373 cat expect.unsorted | sort >expect
1374 test_expect_success \
1375 'Q: verify first notes tree' \
1376 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1377 test_cmp expect actual'
1379 echo "$note1_data" >expect
1380 test_expect_success \
1381 'Q: verify first note for first commit' \
1382 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1384 echo "$note2_data" >expect
1385 test_expect_success \
1386 'Q: verify first note for second commit' \
1387 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1389 echo "$note3_data" >expect
1390 test_expect_success \
1391 'Q: verify first note for third commit' \
1392 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1394 cat >expect <<EOF
1395 parent `git rev-parse --verify refs/notes/foobar~2`
1396 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1397 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1399 notes (:10)
1401 test_expect_success \
1402 'Q: verify second notes commit' \
1403 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1404 test_cmp expect actual'
1406 cat >expect.unsorted <<EOF
1407 100644 blob $commit1
1408 100644 blob $commit2
1409 100644 blob $commit3
1411 cat expect.unsorted | sort >expect
1412 test_expect_success \
1413 'Q: verify second notes tree' \
1414 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1415 test_cmp expect actual'
1417 echo "$note1b_data" >expect
1418 test_expect_success \
1419 'Q: verify second note for first commit' \
1420 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1422 echo "$note2_data" >expect
1423 test_expect_success \
1424 'Q: verify first note for second commit' \
1425 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1427 echo "$note3_data" >expect
1428 test_expect_success \
1429 'Q: verify first note for third commit' \
1430 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1432 cat >expect <<EOF
1433 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1434 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1436 notes (:11)
1438 test_expect_success \
1439 'Q: verify third notes commit' \
1440 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1441 test_cmp expect actual'
1443 cat >expect.unsorted <<EOF
1444 100644 blob $commit1
1446 cat expect.unsorted | sort >expect
1447 test_expect_success \
1448 'Q: verify third notes tree' \
1449 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1450 test_cmp expect actual'
1452 echo "$note1c_data" >expect
1453 test_expect_success \
1454 'Q: verify third note for first commit' \
1455 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1457 cat >expect <<EOF
1458 parent `git rev-parse --verify refs/notes/foobar^`
1459 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1460 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1462 notes (:12)
1464 test_expect_success \
1465 'Q: verify fourth notes commit' \
1466 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1467 test_cmp expect actual'
1469 cat >expect.unsorted <<EOF
1470 100644 blob $commit2
1472 cat expect.unsorted | sort >expect
1473 test_expect_success \
1474 'Q: verify fourth notes tree' \
1475 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1476 test_cmp expect actual'
1478 echo "$note2b_data" >expect
1479 test_expect_success \
1480 'Q: verify second note for second commit' \
1481 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1484 ### series R (feature and option)
1487 cat >input <<EOF
1488 feature no-such-feature-exists
1491 test_expect_success 'R: abort on unsupported feature' '
1492 test_must_fail git fast-import <input
1495 cat >input <<EOF
1496 feature date-format=now
1499 test_expect_success 'R: supported feature is accepted' '
1500 git fast-import <input
1503 cat >input << EOF
1504 blob
1505 data 3
1507 feature date-format=now
1510 test_expect_success 'R: abort on receiving feature after data command' '
1511 test_must_fail git fast-import <input
1514 cat >input << EOF
1515 feature import-marks=git.marks
1516 feature import-marks=git2.marks
1519 test_expect_success 'R: only one import-marks feature allowed per stream' '
1520 test_must_fail git fast-import <input
1523 cat >input << EOF
1524 feature export-marks=git.marks
1525 blob
1526 mark :1
1527 data 3
1532 test_expect_success \
1533 'R: export-marks feature results in a marks file being created' \
1534 'cat input | git fast-import &&
1535 grep :1 git.marks'
1537 test_expect_success \
1538 'R: export-marks options can be overriden by commandline options' \
1539 'cat input | git fast-import --export-marks=other.marks &&
1540 grep :1 other.marks'
1542 cat >input << EOF
1543 feature import-marks=marks.out
1544 feature export-marks=marks.new
1547 test_expect_success \
1548 'R: import to output marks works without any content' \
1549 'cat input | git fast-import &&
1550 test_cmp marks.out marks.new'
1552 cat >input <<EOF
1553 feature import-marks=nonexistant.marks
1554 feature export-marks=marks.new
1557 test_expect_success \
1558 'R: import marks prefers commandline marks file over the stream' \
1559 'cat input | git fast-import --import-marks=marks.out &&
1560 test_cmp marks.out marks.new'
1563 cat >input <<EOF
1564 feature import-marks=nonexistant.marks
1565 feature export-marks=combined.marks
1568 test_expect_success 'R: multiple --import-marks= should be honoured' '
1569 head -n2 marks.out > one.marks &&
1570 tail -n +3 marks.out > two.marks &&
1571 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1572 test_cmp marks.out combined.marks
1575 cat >input <<EOF
1576 feature relative-marks
1577 feature import-marks=relative.in
1578 feature export-marks=relative.out
1581 test_expect_success 'R: feature relative-marks should be honoured' '
1582 mkdir -p .git/info/fast-import/ &&
1583 cp marks.new .git/info/fast-import/relative.in &&
1584 git fast-import <input &&
1585 test_cmp marks.new .git/info/fast-import/relative.out
1588 cat >input <<EOF
1589 feature relative-marks
1590 feature import-marks=relative.in
1591 feature no-relative-marks
1592 feature export-marks=non-relative.out
1595 test_expect_success 'R: feature no-relative-marks should be honoured' '
1596 git fast-import <input &&
1597 test_cmp marks.new non-relative.out
1600 cat >input << EOF
1601 option git quiet
1602 blob
1603 data 3
1608 touch empty
1610 test_expect_success 'R: quiet option results in no stats being output' '
1611 cat input | git fast-import 2> output &&
1612 test_cmp empty output
1615 cat >input <<EOF
1616 option git non-existing-option
1619 test_expect_success 'R: die on unknown option' '
1620 test_must_fail git fast-import <input
1623 test_expect_success 'R: unknown commandline options are rejected' '\
1624 test_must_fail git fast-import --non-existing-option < /dev/null
1627 cat >input <<EOF
1628 option non-existing-vcs non-existing-option
1631 test_expect_success 'R: ignore non-git options' '
1632 git fast-import <input
1636 ## R: very large blobs
1638 blobsize=$((2*1024*1024 + 53))
1639 test-genrandom bar $blobsize >expect
1640 cat >input <<INPUT_END
1641 commit refs/heads/big-file
1642 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1643 data <<COMMIT
1644 R - big file
1645 COMMIT
1647 M 644 inline big1
1648 data $blobsize
1649 INPUT_END
1650 cat expect >>input
1651 cat >>input <<INPUT_END
1652 M 644 inline big2
1653 data $blobsize
1654 INPUT_END
1655 cat expect >>input
1656 echo >>input
1658 test_expect_success \
1659 'R: blob bigger than threshold' \
1660 'test_create_repo R &&
1661 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
1662 test_expect_success \
1663 'R: verify created pack' \
1664 ': >verify &&
1665 for p in R/.git/objects/pack/*.pack;
1667 git verify-pack -v $p >>verify || exit;
1668 done'
1669 test_expect_success \
1670 'R: verify written objects' \
1671 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
1672 test_cmp expect actual &&
1673 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
1674 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
1675 test $a = $b'
1676 test_expect_success \
1677 'R: blob appears only once' \
1678 'n=$(grep $a verify | wc -l) &&
1679 test 1 = $n'
1681 test_done