Merge branch 'maint-1.5.4' into maint
[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 . ../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 INPUT_END
60 test_expect_success \
61     'A: create pack from stdin' \
62     'git-fast-import --export-marks=marks.out <input &&
63          git whatchanged master'
64 test_expect_success \
65         'A: verify pack' \
66         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
67
68 cat >expect <<EOF
69 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
70 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
71
72 initial
73 EOF
74 test_expect_success \
75         'A: verify commit' \
76         'git cat-file commit master | sed 1d >actual &&
77         git diff expect actual'
78
79 cat >expect <<EOF
80 100644 blob file2
81 100644 blob file3
82 100755 blob file4
83 EOF
84 test_expect_success \
85         'A: verify tree' \
86         'git cat-file -p master^{tree} | sed "s/ [0-9a-f]*      / /" >actual &&
87          git diff expect actual'
88
89 echo "$file2_data" >expect
90 test_expect_success \
91         'A: verify file2' \
92         'git cat-file blob master:file2 >actual && git diff expect actual'
93
94 echo "$file3_data" >expect
95 test_expect_success \
96         'A: verify file3' \
97         'git cat-file blob master:file3 >actual && git diff expect actual'
98
99 printf "$file4_data" >expect
100 test_expect_success \
101         'A: verify file4' \
102         'git cat-file blob master:file4 >actual && git diff expect actual'
103
104 cat >expect <<EOF
105 :2 `git rev-parse --verify master:file2`
106 :3 `git rev-parse --verify master:file3`
107 :4 `git rev-parse --verify master:file4`
108 :5 `git rev-parse --verify master^0`
109 EOF
110 test_expect_success \
111         'A: verify marks output' \
112         'git diff expect marks.out'
113
114 test_expect_success \
115         'A: verify marks import' \
116         'git-fast-import \
117                 --import-marks=marks.out \
118                 --export-marks=marks.new \
119                 </dev/null &&
120         git diff -u expect marks.new'
121
122 test_tick
123 cat >input <<INPUT_END
124 commit refs/heads/verify--import-marks
125 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
126 data <<COMMIT
127 recreate from :5
128 COMMIT
129
130 from :5
131 M 755 :2 copy-of-file2
132
133 INPUT_END
134 test_expect_success \
135         'A: verify marks import does not crash' \
136         'git-fast-import --import-marks=marks.out <input &&
137          git whatchanged verify--import-marks'
138 test_expect_success \
139         'A: verify pack' \
140         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
141 cat >expect <<EOF
142 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A      copy-of-file2
143 EOF
144 git diff-tree -M -r master verify--import-marks >actual
145 test_expect_success \
146         'A: verify diff' \
147         'compare_diff_raw expect actual &&
148          test `git rev-parse --verify master:file2` \
149             = `git rev-parse --verify verify--import-marks:copy-of-file2`'
150
151 ###
152 ### series B
153 ###
154
155 test_tick
156 cat >input <<INPUT_END
157 commit refs/heads/branch
158 mark :1
159 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
160 data <<COMMIT
161 corrupt
162 COMMIT
163
164 from refs/heads/master
165 M 755 0000000000000000000000000000000000000001 zero1
166
167 INPUT_END
168 test_expect_success 'B: fail on invalid blob sha1' '
169     ! git-fast-import <input
170 '
171 rm -f .git/objects/pack_* .git/objects/index_*
172
173 cat >input <<INPUT_END
174 commit .badbranchname
175 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
176 data <<COMMIT
177 corrupt
178 COMMIT
179
180 from refs/heads/master
181
182 INPUT_END
183 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
184     ! git-fast-import <input
185 '
186 rm -f .git/objects/pack_* .git/objects/index_*
187
188 cat >input <<INPUT_END
189 commit bad[branch]name
190 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
191 data <<COMMIT
192 corrupt
193 COMMIT
194
195 from refs/heads/master
196
197 INPUT_END
198 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
199     ! git-fast-import <input
200 '
201 rm -f .git/objects/pack_* .git/objects/index_*
202
203 cat >input <<INPUT_END
204 commit TEMP_TAG
205 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
206 data <<COMMIT
207 tag base
208 COMMIT
209
210 from refs/heads/master
211
212 INPUT_END
213 test_expect_success \
214     'B: accept branch name "TEMP_TAG"' \
215     'git-fast-import <input &&
216          test -f .git/TEMP_TAG &&
217          test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
218 rm -f .git/TEMP_TAG
219
220 ###
221 ### series C
222 ###
223
224 newf=`echo hi newf | git-hash-object -w --stdin`
225 oldf=`git rev-parse --verify master:file2`
226 test_tick
227 cat >input <<INPUT_END
228 commit refs/heads/branch
229 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
230 data <<COMMIT
231 second
232 COMMIT
233
234 from refs/heads/master
235 M 644 $oldf file2/oldf
236 M 755 $newf file2/newf
237 D file3
238
239 INPUT_END
240 test_expect_success \
241     'C: incremental import create pack from stdin' \
242     'git-fast-import <input &&
243          git whatchanged branch'
244 test_expect_success \
245         'C: verify pack' \
246         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
247 test_expect_success \
248         'C: validate reuse existing blob' \
249         'test $newf = `git rev-parse --verify branch:file2/newf`
250          test $oldf = `git rev-parse --verify branch:file2/oldf`'
251
252 cat >expect <<EOF
253 parent `git rev-parse --verify master^0`
254 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
255 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
256
257 second
258 EOF
259 test_expect_success \
260         'C: verify commit' \
261         'git cat-file commit branch | sed 1d >actual &&
262          git diff expect actual'
263
264 cat >expect <<EOF
265 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A      file2/newf
266 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100   file2   file2/oldf
267 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D      file3
268 EOF
269 git diff-tree -M -r master branch >actual
270 test_expect_success \
271         'C: validate rename result' \
272         'compare_diff_raw expect actual'
273
274 ###
275 ### series D
276 ###
277
278 test_tick
279 cat >input <<INPUT_END
280 commit refs/heads/branch
281 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
282 data <<COMMIT
283 third
284 COMMIT
285
286 from refs/heads/branch^0
287 M 644 inline newdir/interesting
288 data <<EOF
289 $file5_data
290 EOF
291
292 M 755 inline newdir/exec.sh
293 data <<EOF
294 $file6_data
295 EOF
296
297 INPUT_END
298 test_expect_success \
299     'D: inline data in commit' \
300     'git-fast-import <input &&
301          git whatchanged branch'
302 test_expect_success \
303         'D: verify pack' \
304         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
305
306 cat >expect <<EOF
307 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A      newdir/exec.sh
308 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A      newdir/interesting
309 EOF
310 git diff-tree -M -r branch^ branch >actual
311 test_expect_success \
312         'D: validate new files added' \
313         'compare_diff_raw expect actual'
314
315 echo "$file5_data" >expect
316 test_expect_success \
317         'D: verify file5' \
318         'git cat-file blob branch:newdir/interesting >actual &&
319          git diff expect actual'
320
321 echo "$file6_data" >expect
322 test_expect_success \
323         'D: verify file6' \
324         'git cat-file blob branch:newdir/exec.sh >actual &&
325          git diff expect actual'
326
327 ###
328 ### series E
329 ###
330
331 cat >input <<INPUT_END
332 commit refs/heads/branch
333 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
334 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
335 data <<COMMIT
336 RFC 2822 type date
337 COMMIT
338
339 from refs/heads/branch^0
340
341 INPUT_END
342 test_expect_success 'E: rfc2822 date, --date-format=raw' '
343     ! git-fast-import --date-format=raw <input
344 '
345 test_expect_success \
346     'E: rfc2822 date, --date-format=rfc2822' \
347     'git-fast-import --date-format=rfc2822 <input'
348 test_expect_success \
349         'E: verify pack' \
350         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
351
352 cat >expect <<EOF
353 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
354 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
355
356 RFC 2822 type date
357 EOF
358 test_expect_success \
359         'E: verify commit' \
360         'git cat-file commit branch | sed 1,2d >actual &&
361         git diff expect actual'
362
363 ###
364 ### series F
365 ###
366
367 old_branch=`git rev-parse --verify branch^0`
368 test_tick
369 cat >input <<INPUT_END
370 commit refs/heads/branch
371 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
372 data <<COMMIT
373 losing things already?
374 COMMIT
375
376 from refs/heads/branch~1
377
378 reset refs/heads/other
379 from refs/heads/branch
380
381 INPUT_END
382 test_expect_success \
383     'F: non-fast-forward update skips' \
384     'if git-fast-import <input
385          then
386                 echo BAD gfi did not fail
387                 return 1
388          else
389                 if test $old_branch = `git rev-parse --verify branch^0`
390                 then
391                         : branch unaffected and failure returned
392                         return 0
393                 else
394                         echo BAD gfi changed branch $old_branch
395                         return 1
396                 fi
397          fi
398         '
399 test_expect_success \
400         'F: verify pack' \
401         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
402
403 cat >expect <<EOF
404 tree `git rev-parse branch~1^{tree}`
405 parent `git rev-parse branch~1`
406 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
407 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
408
409 losing things already?
410 EOF
411 test_expect_success \
412         'F: verify other commit' \
413         'git cat-file commit other >actual &&
414         git diff expect actual'
415
416 ###
417 ### series G
418 ###
419
420 old_branch=`git rev-parse --verify branch^0`
421 test_tick
422 cat >input <<INPUT_END
423 commit refs/heads/branch
424 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
425 data <<COMMIT
426 losing things already?
427 COMMIT
428
429 from refs/heads/branch~1
430
431 INPUT_END
432 test_expect_success \
433     'G: non-fast-forward update forced' \
434     'git-fast-import --force <input'
435 test_expect_success \
436         'G: verify pack' \
437         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
438 test_expect_success \
439         'G: branch changed, but logged' \
440         'test $old_branch != `git rev-parse --verify branch^0` &&
441          test $old_branch = `git rev-parse --verify branch@{1}`'
442
443 ###
444 ### series H
445 ###
446
447 test_tick
448 cat >input <<INPUT_END
449 commit refs/heads/H
450 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
451 data <<COMMIT
452 third
453 COMMIT
454
455 from refs/heads/branch^0
456 M 644 inline i-will-die
457 data <<EOF
458 this file will never exist.
459 EOF
460
461 deleteall
462 M 644 inline h/e/l/lo
463 data <<EOF
464 $file5_data
465 EOF
466
467 INPUT_END
468 test_expect_success \
469     'H: deletall, add 1' \
470     'git-fast-import <input &&
471          git whatchanged H'
472 test_expect_success \
473         'H: verify pack' \
474         'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
475
476 cat >expect <<EOF
477 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D      file2/newf
478 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D      file2/oldf
479 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D      file4
480 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100   newdir/interesting      h/e/l/lo
481 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D      newdir/exec.sh
482 EOF
483 git diff-tree -M -r H^ H >actual
484 test_expect_success \
485         'H: validate old files removed, new files added' \
486         'compare_diff_raw expect actual'
487
488 echo "$file5_data" >expect
489 test_expect_success \
490         'H: verify file' \
491         'git cat-file blob H:h/e/l/lo >actual &&
492          git diff expect actual'
493
494 ###
495 ### series I
496 ###
497
498 cat >input <<INPUT_END
499 commit refs/heads/export-boundary
500 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
501 data <<COMMIT
502 we have a border.  its only 40 characters wide.
503 COMMIT
504
505 from refs/heads/branch
506
507 INPUT_END
508 test_expect_success \
509     'I: export-pack-edges' \
510     'git-fast-import --export-pack-edges=edges.list <input'
511
512 cat >expect <<EOF
513 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
514 EOF
515 test_expect_success \
516         'I: verify edge list' \
517         'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
518          git diff expect actual'
519
520 ###
521 ### series J
522 ###
523
524 cat >input <<INPUT_END
525 commit refs/heads/J
526 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
527 data <<COMMIT
528 create J
529 COMMIT
530
531 from refs/heads/branch
532
533 reset refs/heads/J
534
535 commit refs/heads/J
536 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
537 data <<COMMIT
538 initialize J
539 COMMIT
540
541 INPUT_END
542 test_expect_success \
543     'J: reset existing branch creates empty commit' \
544     'git-fast-import <input'
545 test_expect_success \
546         'J: branch has 1 commit, empty tree' \
547         'test 1 = `git rev-list J | wc -l` &&
548          test 0 = `git ls-tree J | wc -l`'
549
550 ###
551 ### series K
552 ###
553
554 cat >input <<INPUT_END
555 commit refs/heads/K
556 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
557 data <<COMMIT
558 create K
559 COMMIT
560
561 from refs/heads/branch
562
563 commit refs/heads/K
564 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
565 data <<COMMIT
566 redo K
567 COMMIT
568
569 from refs/heads/branch^1
570
571 INPUT_END
572 test_expect_success \
573     'K: reinit branch with from' \
574     'git-fast-import <input'
575 test_expect_success \
576     'K: verify K^1 = branch^1' \
577     'test `git rev-parse --verify branch^1` \
578                 = `git rev-parse --verify K^1`'
579
580 ###
581 ### series L
582 ###
583
584 cat >input <<INPUT_END
585 blob
586 mark :1
587 data <<EOF
588 some data
589 EOF
590
591 blob
592 mark :2
593 data <<EOF
594 other data
595 EOF
596
597 commit refs/heads/L
598 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
599 data <<COMMIT
600 create L
601 COMMIT
602
603 M 644 :1 b.
604 M 644 :1 b/other
605 M 644 :1 ba
606
607 commit refs/heads/L
608 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
609 data <<COMMIT
610 update L
611 COMMIT
612
613 M 644 :2 b.
614 M 644 :2 b/other
615 M 644 :2 ba
616 INPUT_END
617
618 cat >expect <<EXPECT_END
619 :100644 100644 4268632... 55d3a52... M  b.
620 :040000 040000 0ae5cac... 443c768... M  b
621 :100644 100644 4268632... 55d3a52... M  ba
622 EXPECT_END
623
624 test_expect_success \
625     'L: verify internal tree sorting' \
626         'git-fast-import <input &&
627          git diff-tree --abbrev --raw L^ L >output &&
628          git diff expect output'
629
630 ###
631 ### series M
632 ###
633
634 test_tick
635 cat >input <<INPUT_END
636 commit refs/heads/M1
637 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
638 data <<COMMIT
639 file rename
640 COMMIT
641
642 from refs/heads/branch^0
643 R file2/newf file2/n.e.w.f
644
645 INPUT_END
646
647 cat >expect <<EOF
648 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100   file2/newf      file2/n.e.w.f
649 EOF
650 test_expect_success \
651         'M: rename file in same subdirectory' \
652         'git-fast-import <input &&
653          git diff-tree -M -r M1^ M1 >actual &&
654          compare_diff_raw expect actual'
655
656 cat >input <<INPUT_END
657 commit refs/heads/M2
658 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
659 data <<COMMIT
660 file rename
661 COMMIT
662
663 from refs/heads/branch^0
664 R file2/newf i/am/new/to/you
665
666 INPUT_END
667
668 cat >expect <<EOF
669 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100   file2/newf      i/am/new/to/you
670 EOF
671 test_expect_success \
672         'M: rename file to new subdirectory' \
673         'git-fast-import <input &&
674          git diff-tree -M -r M2^ M2 >actual &&
675          compare_diff_raw expect actual'
676
677 cat >input <<INPUT_END
678 commit refs/heads/M3
679 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
680 data <<COMMIT
681 file rename
682 COMMIT
683
684 from refs/heads/M2^0
685 R i other/sub
686
687 INPUT_END
688
689 cat >expect <<EOF
690 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100   i/am/new/to/you other/sub/am/new/to/you
691 EOF
692 test_expect_success \
693         'M: rename subdirectory to new subdirectory' \
694         'git-fast-import <input &&
695          git diff-tree -M -r M3^ M3 >actual &&
696          compare_diff_raw expect actual'
697
698 ###
699 ### series N
700 ###
701
702 test_tick
703 cat >input <<INPUT_END
704 commit refs/heads/N1
705 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
706 data <<COMMIT
707 file copy
708 COMMIT
709
710 from refs/heads/branch^0
711 C file2/newf file2/n.e.w.f
712
713 INPUT_END
714
715 cat >expect <<EOF
716 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100   file2/newf      file2/n.e.w.f
717 EOF
718 test_expect_success \
719         'N: copy file in same subdirectory' \
720         'git-fast-import <input &&
721          git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
722          compare_diff_raw expect actual'
723
724 cat >input <<INPUT_END
725 commit refs/heads/N2
726 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
727 data <<COMMIT
728 clean directory copy
729 COMMIT
730
731 from refs/heads/branch^0
732 C file2 file3
733
734 commit refs/heads/N2
735 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
736 data <<COMMIT
737 modify directory copy
738 COMMIT
739
740 M 644 inline file3/file5
741 data <<EOF
742 $file5_data
743 EOF
744
745 INPUT_END
746
747 cat >expect <<EOF
748 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100   newdir/interesting      file3/file5
749 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100   file2/newf      file3/newf
750 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100   file2/oldf      file3/oldf
751 EOF
752 test_expect_success \
753         'N: copy then modify subdirectory' \
754         'git-fast-import <input &&
755          git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
756          compare_diff_raw expect actual'
757
758 cat >input <<INPUT_END
759 commit refs/heads/N3
760 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
761 data <<COMMIT
762 dirty directory copy
763 COMMIT
764
765 from refs/heads/branch^0
766 M 644 inline file2/file5
767 data <<EOF
768 $file5_data
769 EOF
770
771 C file2 file3
772 D file2/file5
773
774 INPUT_END
775
776 test_expect_success \
777         'N: copy dirty subdirectory' \
778         'git-fast-import <input &&
779          test `git-rev-parse N2^{tree}` = `git-rev-parse N3^{tree}`'
780
781 ###
782 ### series O
783 ###
784
785 cat >input <<INPUT_END
786 #we will
787 commit refs/heads/O1
788 # -- ignore all of this text
789 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
790 # $GIT_COMMITTER_NAME has inserted here for his benefit.
791 data <<COMMIT
792 dirty directory copy
793 COMMIT
794
795 # don't forget the import blank line!
796 #
797 # yes, we started from our usual base of branch^0.
798 # i like branch^0.
799 from refs/heads/branch^0
800 # and we need to reuse file2/file5 from N3 above.
801 M 644 inline file2/file5
802 # otherwise the tree will be different
803 data <<EOF
804 $file5_data
805 EOF
806
807 # don't forget to copy file2 to file3
808 C file2 file3
809 #
810 # or to delete file5 from file2.
811 D file2/file5
812 # are we done yet?
813
814 INPUT_END
815
816 test_expect_success \
817         'O: comments are all skipped' \
818         'git-fast-import <input &&
819          test `git-rev-parse N3` = `git-rev-parse O1`'
820
821 cat >input <<INPUT_END
822 commit refs/heads/O2
823 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
824 data <<COMMIT
825 dirty directory copy
826 COMMIT
827 from refs/heads/branch^0
828 M 644 inline file2/file5
829 data <<EOF
830 $file5_data
831 EOF
832 C file2 file3
833 D file2/file5
834
835 INPUT_END
836
837 test_expect_success \
838         'O: blank lines not necessary after data commands' \
839         'git-fast-import <input &&
840          test `git-rev-parse N3` = `git-rev-parse O2`'
841
842 test_expect_success \
843         'O: repack before next test' \
844         'git repack -a -d'
845
846 cat >input <<INPUT_END
847 commit refs/heads/O3
848 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
849 data <<COMMIT
850 zstring
851 COMMIT
852 commit refs/heads/O3
853 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
854 data <<COMMIT
855 zof
856 COMMIT
857 checkpoint
858 commit refs/heads/O3
859 mark :5
860 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
861 data <<COMMIT
862 zempty
863 COMMIT
864 checkpoint
865 commit refs/heads/O3
866 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
867 data <<COMMIT
868 zcommits
869 COMMIT
870 reset refs/tags/O3-2nd
871 from :5
872 reset refs/tags/O3-3rd
873 from :5
874 INPUT_END
875
876 cat >expect <<INPUT_END
877 string
878 of
879 empty
880 commits
881 INPUT_END
882 test_expect_success \
883         'O: blank lines not necessary after other commands' \
884         'git-fast-import <input &&
885          test 8 = `find .git/objects/pack -type f | wc -l` &&
886          test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
887          git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
888          git diff expect actual'
889
890 cat >input <<INPUT_END
891 commit refs/heads/O4
892 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
893 data <<COMMIT
894 zstring
895 COMMIT
896 commit refs/heads/O4
897 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
898 data <<COMMIT
899 zof
900 COMMIT
901 progress Two commits down, 2 to go!
902 commit refs/heads/O4
903 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
904 data <<COMMIT
905 zempty
906 COMMIT
907 progress Three commits down, 1 to go!
908 commit refs/heads/O4
909 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
910 data <<COMMIT
911 zcommits
912 COMMIT
913 progress I'm done!
914 INPUT_END
915 test_expect_success \
916         'O: progress outputs as requested by input' \
917         'git-fast-import <input >actual &&
918          grep "progress " <input >expect &&
919          git diff expect actual'
920
921 test_done