]> rtime.felk.cvut.cz Git - git.git/blob - t/t9300-fast-import.sh
Merge branch 'jc/status-show-ignored'
[git.git] / t / t9300-fast-import.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Shawn Pearce
4 #
5
6 test_description='test git fast-import utility'
7 . ./test-lib.sh
8 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
9
10 file2_data='file2
11 second line of EOF'
12
13 file3_data='EOF
14 in 3rd file
15  END'
16
17 file4_data=abcd
18 file4_len=4
19
20 file5_data='an inline file.
21   we should see it later.'
22
23 file6_data='#!/bin/sh
24 echo "$@"'
25
26 ###
27 ### series A
28 ###
29
30 test_tick
31 cat >input <<INPUT_END
32 blob
33 mark :2
34 data <<EOF
35 $file2_data
36 EOF
37
38 blob
39 mark :3
40 data <<END
41 $file3_data
42 END
43
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
54
55 M 644 :2 file2
56 M 644 :3 file3
57 M 755 :4 file4
58
59 tag series-A
60 from :5
61 data <<EOF
62 An annotated tag without a tagger
63 EOF
64
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'
73
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
77
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'
84
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'
94
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'
99
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'
104
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'
109
110 cat >expect <<EOF
111 object $(git rev-parse refs/heads/master)
112 type commit
113 tag series-A
114
115 An annotated tag without a tagger
116 EOF
117 test_expect_success 'A: verify tag/series-A' '
118         git cat-file tag tags/series-A >actual &&
119         test_cmp expect actual
120 '
121
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`
127 EOF
128 test_expect_success \
129         'A: verify marks output' \
130         'test_cmp expect marks.out'
131
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'
139
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
147
148 from :5
149 M 755 :2 copy-of-file2
150
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
161 EOF
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`'
168
169 ###
170 ### series B
171 ###
172
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
181
182 from refs/heads/master
183 M 755 0000000000000000000000000000000000000001 zero1
184
185 INPUT_END
186 test_expect_success 'B: fail on invalid blob sha1' '
187     test_must_fail git fast-import <input
188 '
189 rm -f .git/objects/pack_* .git/objects/index_*
190
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
197
198 from refs/heads/master
199
200 INPUT_END
201 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
202     test_must_fail git fast-import <input
203 '
204 rm -f .git/objects/pack_* .git/objects/index_*
205
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
212
213 from refs/heads/master
214
215 INPUT_END
216 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
217     test_must_fail git fast-import <input
218 '
219 rm -f .git/objects/pack_* .git/objects/index_*
220
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
227
228 from refs/heads/master
229
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
237
238 ###
239 ### series C
240 ###
241
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
251
252 from refs/heads/master
253 M 644 $oldf file2/oldf
254 M 755 $newf file2/newf
255 D file3
256
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`'
269
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
274
275 second
276 EOF
277 test_expect_success \
278         'C: verify commit' \
279         'git cat-file commit branch | sed 1d >actual &&
280          test_cmp expect actual'
281
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
286 EOF
287 git diff-tree -M -r master branch >actual
288 test_expect_success \
289         'C: validate rename result' \
290         'compare_diff_raw expect actual'
291
292 ###
293 ### series D
294 ###
295
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
303
304 from refs/heads/branch^0
305 M 644 inline newdir/interesting
306 data <<EOF
307 $file5_data
308 EOF
309
310 M 755 inline newdir/exec.sh
311 data <<EOF
312 $file6_data
313 EOF
314
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'
323
324 cat >expect <<EOF
325 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A      newdir/exec.sh
326 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A      newdir/interesting
327 EOF
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'
332
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'
338
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'
344
345 ###
346 ### series E
347 ###
348
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
356
357 from refs/heads/branch^0
358
359 INPUT_END
360 test_expect_success 'E: rfc2822 date, --date-format=raw' '
361     test_must_fail git fast-import --date-format=raw <input
362 '
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'
369
370 cat >expect <<EOF
371 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
372 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
373
374 RFC 2822 type date
375 EOF
376 test_expect_success \
377         'E: verify commit' \
378         'git cat-file commit branch | sed 1,2d >actual &&
379         test_cmp expect actual'
380
381 ###
382 ### series F
383 ###
384
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
393
394 from refs/heads/branch~1
395
396 reset refs/heads/other
397 from refs/heads/branch
398
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
414                 fi
415          fi
416         '
417 test_expect_success \
418         'F: verify pack' \
419         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
420
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
426
427 losing things already?
428 EOF
429 test_expect_success \
430         'F: verify other commit' \
431         'git cat-file commit other >actual &&
432         test_cmp expect actual'
433
434 ###
435 ### series G
436 ###
437
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
446
447 from refs/heads/branch~1
448
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}`'
460
461 ###
462 ### series H
463 ###
464
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
472
473 from refs/heads/branch^0
474 M 644 inline i-will-die
475 data <<EOF
476 this file will never exist.
477 EOF
478
479 deleteall
480 M 644 inline h/e/l/lo
481 data <<EOF
482 $file5_data
483 EOF
484
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'
493
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
500 EOF
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'
505
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'
511
512 ###
513 ### series I
514 ###
515
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
522
523 from refs/heads/branch
524
525 INPUT_END
526 test_expect_success \
527     'I: export-pack-edges' \
528     'git fast-import --export-pack-edges=edges.list <input'
529
530 cat >expect <<EOF
531 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
532 EOF
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'
537
538 ###
539 ### series J
540 ###
541
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
548
549 from refs/heads/branch
550
551 reset refs/heads/J
552
553 commit refs/heads/J
554 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
555 data <<COMMIT
556 initialize J
557 COMMIT
558
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`'
567
568 ###
569 ### series K
570 ###
571
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
578
579 from refs/heads/branch
580
581 commit refs/heads/K
582 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
583 data <<COMMIT
584 redo K
585 COMMIT
586
587 from refs/heads/branch^1
588
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`'
597
598 ###
599 ### series L
600 ###
601
602 cat >input <<INPUT_END
603 blob
604 mark :1
605 data <<EOF
606 some data
607 EOF
608
609 blob
610 mark :2
611 data <<EOF
612 other data
613 EOF
614
615 commit refs/heads/L
616 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
617 data <<COMMIT
618 create L
619 COMMIT
620
621 M 644 :1 b.
622 M 644 :1 b/other
623 M 644 :1 ba
624
625 commit refs/heads/L
626 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
627 data <<COMMIT
628 update L
629 COMMIT
630
631 M 644 :2 b.
632 M 644 :2 b/other
633 M 644 :2 ba
634 INPUT_END
635
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
641
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'
647
648 ###
649 ### series M
650 ###
651
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
659
660 from refs/heads/branch^0
661 R file2/newf file2/n.e.w.f
662
663 INPUT_END
664
665 cat >expect <<EOF
666 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100   file2/newf      file2/n.e.w.f
667 EOF
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'
673
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
680
681 from refs/heads/branch^0
682 R file2/newf i/am/new/to/you
683
684 INPUT_END
685
686 cat >expect <<EOF
687 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100   file2/newf      i/am/new/to/you
688 EOF
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'
694
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
701
702 from refs/heads/M2^0
703 R i other/sub
704
705 INPUT_END
706
707 cat >expect <<EOF
708 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100   i/am/new/to/you other/sub/am/new/to/you
709 EOF
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'
715
716 ###
717 ### series N
718 ###
719
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
727
728 from refs/heads/branch^0
729 C file2/newf file2/n.e.w.f
730
731 INPUT_END
732
733 cat >expect <<EOF
734 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100   file2/newf      file2/n.e.w.f
735 EOF
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'
741
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
748
749 from refs/heads/branch^0
750 C file2 file3
751
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
757
758 M 644 inline file3/file5
759 data <<EOF
760 $file5_data
761 EOF
762
763 INPUT_END
764
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
769 EOF
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'
775
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
782
783 from refs/heads/branch^0
784 M 644 inline file2/file5
785 data <<EOF
786 $file5_data
787 EOF
788
789 C file2 file3
790 D file2/file5
791
792 INPUT_END
793
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}`'
798
799 ###
800 ### series O
801 ###
802
803 cat >input <<INPUT_END
804 #we will
805 commit refs/heads/O1
806 # -- ignore all of this text
807 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
808 # $GIT_COMMITTER_NAME has inserted here for his benefit.
809 data <<COMMIT
810 dirty directory copy
811 COMMIT
812
813 # don't forget the import blank line!
814 #
815 # yes, we started from our usual base of branch^0.
816 # i like branch^0.
817 from refs/heads/branch^0
818 # and we need to reuse file2/file5 from N3 above.
819 M 644 inline file2/file5
820 # otherwise the tree will be different
821 data <<EOF
822 $file5_data
823 EOF
824
825 # don't forget to copy file2 to file3
826 C file2 file3
827 #
828 # or to delete file5 from file2.
829 D file2/file5
830 # are we done yet?
831
832 INPUT_END
833
834 test_expect_success \
835         'O: comments are all skipped' \
836         'git fast-import <input &&
837          test `git rev-parse N3` = `git rev-parse O1`'
838
839 cat >input <<INPUT_END
840 commit refs/heads/O2
841 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
842 data <<COMMIT
843 dirty directory copy
844 COMMIT
845 from refs/heads/branch^0
846 M 644 inline file2/file5
847 data <<EOF
848 $file5_data
849 EOF
850 C file2 file3
851 D file2/file5
852
853 INPUT_END
854
855 test_expect_success \
856         'O: blank lines not necessary after data commands' \
857         'git fast-import <input &&
858          test `git rev-parse N3` = `git rev-parse O2`'
859
860 test_expect_success \
861         'O: repack before next test' \
862         'git repack -a -d'
863
864 cat >input <<INPUT_END
865 commit refs/heads/O3
866 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
867 data <<COMMIT
868 zstring
869 COMMIT
870 commit refs/heads/O3
871 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
872 data <<COMMIT
873 zof
874 COMMIT
875 checkpoint
876 commit refs/heads/O3
877 mark :5
878 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
879 data <<COMMIT
880 zempty
881 COMMIT
882 checkpoint
883 commit refs/heads/O3
884 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
885 data <<COMMIT
886 zcommits
887 COMMIT
888 reset refs/tags/O3-2nd
889 from :5
890 reset refs/tags/O3-3rd
891 from :5
892 INPUT_END
893
894 cat >expect <<INPUT_END
895 string
896 of
897 empty
898 commits
899 INPUT_END
900 test_expect_success \
901         'O: blank lines not necessary after other commands' \
902         'git fast-import <input &&
903          test 8 = `find .git/objects/pack -type f | wc -l` &&
904          test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
905          git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
906          test_cmp expect actual'
907
908 cat >input <<INPUT_END
909 commit refs/heads/O4
910 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
911 data <<COMMIT
912 zstring
913 COMMIT
914 commit refs/heads/O4
915 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
916 data <<COMMIT
917 zof
918 COMMIT
919 progress Two commits down, 2 to go!
920 commit refs/heads/O4
921 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
922 data <<COMMIT
923 zempty
924 COMMIT
925 progress Three commits down, 1 to go!
926 commit refs/heads/O4
927 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
928 data <<COMMIT
929 zcommits
930 COMMIT
931 progress I'm done!
932 INPUT_END
933 test_expect_success \
934         'O: progress outputs as requested by input' \
935         'git fast-import <input >actual &&
936          grep "progress " <input >expect &&
937          test_cmp expect actual'
938
939 ###
940 ### series P (gitlinks)
941 ###
942
943 cat >input <<INPUT_END
944 blob
945 mark :1
946 data 10
947 test file
948
949 reset refs/heads/sub
950 commit refs/heads/sub
951 mark :2
952 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
953 data 12
954 sub_initial
955 M 100644 :1 file
956
957 blob
958 mark :3
959 data <<DATAEND
960 [submodule "sub"]
961         path = sub
962         url = "`pwd`/sub"
963 DATAEND
964
965 commit refs/heads/subuse1
966 mark :4
967 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
968 data 8
969 initial
970 from refs/heads/master
971 M 100644 :3 .gitmodules
972 M 160000 :2 sub
973
974 blob
975 mark :5
976 data 20
977 test file
978 more data
979
980 commit refs/heads/sub
981 mark :6
982 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
983 data 11
984 sub_second
985 from :2
986 M 100644 :5 file
987
988 commit refs/heads/subuse1
989 mark :7
990 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
991 data 7
992 second
993 from :4
994 M 160000 :6 sub
995
996 INPUT_END
997
998 test_expect_success \
999         'P: supermodule & submodule mix' \
1000         'git fast-import <input &&
1001          git checkout subuse1 &&
1002          rm -rf sub && mkdir sub && cd sub &&
1003          git init &&
1004          git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1005          git checkout master &&
1006          cd .. &&
1007          git submodule init &&
1008          git submodule update'
1009
1010 SUBLAST=$(git rev-parse --verify sub)
1011 SUBPREV=$(git rev-parse --verify sub^)
1012
1013 cat >input <<INPUT_END
1014 blob
1015 mark :1
1016 data <<DATAEND
1017 [submodule "sub"]
1018         path = sub
1019         url = "`pwd`/sub"
1020 DATAEND
1021
1022 commit refs/heads/subuse2
1023 mark :2
1024 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1025 data 8
1026 initial
1027 from refs/heads/master
1028 M 100644 :1 .gitmodules
1029 M 160000 $SUBPREV sub
1030
1031 commit refs/heads/subuse2
1032 mark :3
1033 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1034 data 7
1035 second
1036 from :2
1037 M 160000 $SUBLAST sub
1038
1039 INPUT_END
1040
1041 test_expect_success \
1042         'P: verbatim SHA gitlinks' \
1043         'git branch -D sub &&
1044          git gc && git prune &&
1045          git fast-import <input &&
1046          test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1047
1048 test_tick
1049 cat >input <<INPUT_END
1050 commit refs/heads/subuse3
1051 mark :1
1052 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1053 data <<COMMIT
1054 corrupt
1055 COMMIT
1056
1057 from refs/heads/subuse2
1058 M 160000 inline sub
1059 data <<DATA
1060 $SUBPREV
1061 DATA
1062
1063 INPUT_END
1064
1065 test_expect_success 'P: fail on inline gitlink' '
1066     test_must_fail git fast-import <input'
1067
1068 test_tick
1069 cat >input <<INPUT_END
1070 blob
1071 mark :1
1072 data <<DATA
1073 $SUBPREV
1074 DATA
1075
1076 commit refs/heads/subuse3
1077 mark :2
1078 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1079 data <<COMMIT
1080 corrupt
1081 COMMIT
1082
1083 from refs/heads/subuse2
1084 M 160000 :1 sub
1085
1086 INPUT_END
1087
1088 test_expect_success 'P: fail on blob mark in gitlink' '
1089     test_must_fail git fast-import <input'
1090
1091 ###
1092 ### series Q (notes)
1093 ###
1094
1095 note1_data="The first note for the first commit"
1096 note2_data="The first note for the second commit"
1097 note3_data="The first note for the third commit"
1098 note1b_data="The second note for the first commit"
1099 note1c_data="The third note for the first commit"
1100 note2b_data="The second note for the second commit"
1101
1102 test_tick
1103 cat >input <<INPUT_END
1104 blob
1105 mark :2
1106 data <<EOF
1107 $file2_data
1108 EOF
1109
1110 commit refs/heads/notes-test
1111 mark :3
1112 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1113 data <<COMMIT
1114 first (:3)
1115 COMMIT
1116
1117 M 644 :2 file2
1118
1119 blob
1120 mark :4
1121 data $file4_len
1122 $file4_data
1123 commit refs/heads/notes-test
1124 mark :5
1125 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1126 data <<COMMIT
1127 second (:5)
1128 COMMIT
1129
1130 M 644 :4 file4
1131
1132 commit refs/heads/notes-test
1133 mark :6
1134 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1135 data <<COMMIT
1136 third (:6)
1137 COMMIT
1138
1139 M 644 inline file5
1140 data <<EOF
1141 $file5_data
1142 EOF
1143
1144 M 755 inline file6
1145 data <<EOF
1146 $file6_data
1147 EOF
1148
1149 blob
1150 mark :7
1151 data <<EOF
1152 $note1_data
1153 EOF
1154
1155 blob
1156 mark :8
1157 data <<EOF
1158 $note2_data
1159 EOF
1160
1161 commit refs/notes/foobar
1162 mark :9
1163 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1164 data <<COMMIT
1165 notes (:9)
1166 COMMIT
1167
1168 N :7 :3
1169 N :8 :5
1170 N inline :6
1171 data <<EOF
1172 $note3_data
1173 EOF
1174
1175 commit refs/notes/foobar
1176 mark :10
1177 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1178 data <<COMMIT
1179 notes (:10)
1180 COMMIT
1181
1182 N inline :3
1183 data <<EOF
1184 $note1b_data
1185 EOF
1186
1187 commit refs/notes/foobar2
1188 mark :11
1189 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1190 data <<COMMIT
1191 notes (:11)
1192 COMMIT
1193
1194 N inline :3
1195 data <<EOF
1196 $note1c_data
1197 EOF
1198
1199 commit refs/notes/foobar
1200 mark :12
1201 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1202 data <<COMMIT
1203 notes (:12)
1204 COMMIT
1205
1206 deleteall
1207 N inline :5
1208 data <<EOF
1209 $note2b_data
1210 EOF
1211
1212 INPUT_END
1213
1214 test_expect_success \
1215         'Q: commit notes' \
1216         'git fast-import <input &&
1217          git whatchanged notes-test'
1218 test_expect_success \
1219         'Q: verify pack' \
1220         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1221
1222 commit1=$(git rev-parse notes-test~2)
1223 commit2=$(git rev-parse notes-test^)
1224 commit3=$(git rev-parse notes-test)
1225
1226 cat >expect <<EOF
1227 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1228 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1229
1230 first (:3)
1231 EOF
1232 test_expect_success \
1233         'Q: verify first commit' \
1234         'git cat-file commit notes-test~2 | sed 1d >actual &&
1235         test_cmp expect actual'
1236
1237 cat >expect <<EOF
1238 parent $commit1
1239 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1240 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1241
1242 second (:5)
1243 EOF
1244 test_expect_success \
1245         'Q: verify second commit' \
1246         'git cat-file commit notes-test^ | sed 1d >actual &&
1247         test_cmp expect actual'
1248
1249 cat >expect <<EOF
1250 parent $commit2
1251 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1252 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1253
1254 third (:6)
1255 EOF
1256 test_expect_success \
1257         'Q: verify third commit' \
1258         'git cat-file commit notes-test | sed 1d >actual &&
1259         test_cmp expect actual'
1260
1261 cat >expect <<EOF
1262 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1263 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1264
1265 notes (:9)
1266 EOF
1267 test_expect_success \
1268         'Q: verify first notes commit' \
1269         'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1270         test_cmp expect actual'
1271
1272 cat >expect.unsorted <<EOF
1273 100644 blob $commit1
1274 100644 blob $commit2
1275 100644 blob $commit3
1276 EOF
1277 cat expect.unsorted | sort >expect
1278 test_expect_success \
1279         'Q: verify first notes tree' \
1280         'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1281          test_cmp expect actual'
1282
1283 echo "$note1_data" >expect
1284 test_expect_success \
1285         'Q: verify first note for first commit' \
1286         'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1287
1288 echo "$note2_data" >expect
1289 test_expect_success \
1290         'Q: verify first note for second commit' \
1291         'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1292
1293 echo "$note3_data" >expect
1294 test_expect_success \
1295         'Q: verify first note for third commit' \
1296         'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1297
1298 cat >expect <<EOF
1299 parent `git rev-parse --verify refs/notes/foobar~2`
1300 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1302
1303 notes (:10)
1304 EOF
1305 test_expect_success \
1306         'Q: verify second notes commit' \
1307         'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1308         test_cmp expect actual'
1309
1310 cat >expect.unsorted <<EOF
1311 100644 blob $commit1
1312 100644 blob $commit2
1313 100644 blob $commit3
1314 EOF
1315 cat expect.unsorted | sort >expect
1316 test_expect_success \
1317         'Q: verify second notes tree' \
1318         'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]*  / /" >actual &&
1319          test_cmp expect actual'
1320
1321 echo "$note1b_data" >expect
1322 test_expect_success \
1323         'Q: verify second note for first commit' \
1324         'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1325
1326 echo "$note2_data" >expect
1327 test_expect_success \
1328         'Q: verify first note for second commit' \
1329         'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1330
1331 echo "$note3_data" >expect
1332 test_expect_success \
1333         'Q: verify first note for third commit' \
1334         'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1335
1336 cat >expect <<EOF
1337 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1338 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1339
1340 notes (:11)
1341 EOF
1342 test_expect_success \
1343         'Q: verify third notes commit' \
1344         'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1345         test_cmp expect actual'
1346
1347 cat >expect.unsorted <<EOF
1348 100644 blob $commit1
1349 EOF
1350 cat expect.unsorted | sort >expect
1351 test_expect_success \
1352         'Q: verify third notes tree' \
1353         'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]*  / /" >actual &&
1354          test_cmp expect actual'
1355
1356 echo "$note1c_data" >expect
1357 test_expect_success \
1358         'Q: verify third note for first commit' \
1359         'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1360
1361 cat >expect <<EOF
1362 parent `git rev-parse --verify refs/notes/foobar^`
1363 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1364 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1365
1366 notes (:12)
1367 EOF
1368 test_expect_success \
1369         'Q: verify fourth notes commit' \
1370         'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1371         test_cmp expect actual'
1372
1373 cat >expect.unsorted <<EOF
1374 100644 blob $commit2
1375 EOF
1376 cat expect.unsorted | sort >expect
1377 test_expect_success \
1378         'Q: verify fourth notes tree' \
1379         'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]*   / /" >actual &&
1380          test_cmp expect actual'
1381
1382 echo "$note2b_data" >expect
1383 test_expect_success \
1384         'Q: verify second note for second commit' \
1385         'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1386
1387 ###
1388 ### series R (feature and option)
1389 ###
1390
1391 cat >input <<EOF
1392 feature no-such-feature-exists
1393 EOF
1394
1395 test_expect_success 'R: abort on unsupported feature' '
1396         test_must_fail git fast-import <input
1397 '
1398
1399 cat >input <<EOF
1400 feature date-format=now
1401 EOF
1402
1403 test_expect_success 'R: supported feature is accepted' '
1404         git fast-import <input
1405 '
1406
1407 cat >input << EOF
1408 blob
1409 data 3
1410 hi
1411 feature date-format=now
1412 EOF
1413
1414 test_expect_success 'R: abort on receiving feature after data command' '
1415         test_must_fail git fast-import <input
1416 '
1417
1418 cat >input << EOF
1419 feature import-marks=git.marks
1420 feature import-marks=git2.marks
1421 EOF
1422
1423 test_expect_success 'R: only one import-marks feature allowed per stream' '
1424         test_must_fail git fast-import <input
1425 '
1426
1427 cat >input << EOF
1428 feature export-marks=git.marks
1429 blob
1430 mark :1
1431 data 3
1432 hi
1433
1434 EOF
1435
1436 test_expect_success \
1437     'R: export-marks feature results in a marks file being created' \
1438     'cat input | git fast-import &&
1439     grep :1 git.marks'
1440
1441 test_expect_success \
1442     'R: export-marks options can be overriden by commandline options' \
1443     'cat input | git fast-import --export-marks=other.marks &&
1444     grep :1 other.marks'
1445
1446 cat >input << EOF
1447 feature import-marks=marks.out
1448 feature export-marks=marks.new
1449 EOF
1450
1451 test_expect_success \
1452     'R: import to output marks works without any content' \
1453     'cat input | git fast-import &&
1454     test_cmp marks.out marks.new'
1455
1456 cat >input <<EOF
1457 feature import-marks=nonexistant.marks
1458 feature export-marks=marks.new
1459 EOF
1460
1461 test_expect_success \
1462     'R: import marks prefers commandline marks file over the stream' \
1463     'cat input | git fast-import --import-marks=marks.out &&
1464     test_cmp marks.out marks.new'
1465
1466
1467 cat >input <<EOF
1468 feature import-marks=nonexistant.marks
1469 feature export-marks=combined.marks
1470 EOF
1471
1472 test_expect_success 'R: multiple --import-marks= should be honoured' '
1473     head -n2 marks.out > one.marks &&
1474     tail -n +3 marks.out > two.marks &&
1475     git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1476     test_cmp marks.out combined.marks
1477 '
1478
1479 cat >input <<EOF
1480 feature relative-marks
1481 feature import-marks=relative.in
1482 feature export-marks=relative.out
1483 EOF
1484
1485 test_expect_success 'R: feature relative-marks should be honoured' '
1486     mkdir -p .git/info/fast-import/ &&
1487     cp marks.new .git/info/fast-import/relative.in &&
1488     git fast-import <input &&
1489     test_cmp marks.new .git/info/fast-import/relative.out
1490 '
1491
1492 cat >input <<EOF
1493 feature relative-marks
1494 feature import-marks=relative.in
1495 feature no-relative-marks
1496 feature export-marks=non-relative.out
1497 EOF
1498
1499 test_expect_success 'R: feature no-relative-marks should be honoured' '
1500     git fast-import <input &&
1501     test_cmp marks.new non-relative.out
1502 '
1503
1504 cat >input << EOF
1505 option git quiet
1506 blob
1507 data 3
1508 hi
1509
1510 EOF
1511
1512 touch empty
1513
1514 test_expect_success 'R: quiet option results in no stats being output' '
1515     cat input | git fast-import 2> output &&
1516     test_cmp empty output
1517 '
1518
1519 cat >input <<EOF
1520 option git non-existing-option
1521 EOF
1522
1523 test_expect_success 'R: die on unknown option' '
1524     test_must_fail git fast-import <input
1525 '
1526
1527 test_expect_success 'R: unknown commandline options are rejected' '\
1528     test_must_fail git fast-import --non-existing-option < /dev/null
1529 '
1530
1531 cat >input <<EOF
1532 option non-existing-vcs non-existing-option
1533 EOF
1534
1535 test_expect_success 'R: ignore non-git options' '
1536     git fast-import <input
1537 '
1538
1539 ##
1540 ## R: very large blobs
1541 ##
1542 blobsize=$((2*1024*1024 + 53))
1543 test-genrandom bar $blobsize >expect
1544 cat >input <<INPUT_END
1545 commit refs/heads/big-file
1546 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1547 data <<COMMIT
1548 R - big file
1549 COMMIT
1550
1551 M 644 inline big1
1552 data $blobsize
1553 INPUT_END
1554 cat expect >>input
1555 cat >>input <<INPUT_END
1556 M 644 inline big2
1557 data $blobsize
1558 INPUT_END
1559 cat expect >>input
1560 echo >>input
1561
1562 test_expect_success \
1563         'R: blob bigger than threshold' \
1564         'test_create_repo R &&
1565          git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
1566 test_expect_success \
1567         'R: verify created pack' \
1568         ': >verify &&
1569          for p in R/.git/objects/pack/*.pack;
1570          do
1571            git verify-pack -v $p >>verify || exit;
1572          done'
1573 test_expect_success \
1574         'R: verify written objects' \
1575         'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
1576          test_cmp expect actual &&
1577          a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
1578          b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
1579          test $a = $b'
1580 test_expect_success \
1581         'R: blob appears only once' \
1582         'n=$(grep $a verify | wc -l) &&
1583          test 1 = $n'
1584
1585 test_done