fast-import: filemodify after M 040000 <tree> "" crashes
[git/jnareb-git.git] / t / t9300-fast-import.sh
blob1df11adc907aac13b33c3f0e5dbf60467f597e3f
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`'
169 test_tick
170 mt=$(git hash-object --stdin < /dev/null)
171 : >input.blob
172 : >marks.exp
173 : >tree.exp
175 cat >input.commit <<EOF
176 commit refs/heads/verify--dump-marks
177 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
178 data <<COMMIT
179 test the sparse array dumping routines with exponentially growing marks
180 COMMIT
187 while test "$i" -lt 27; do
188 cat >>input.blob <<EOF
189 blob
190 mark :$l
191 data 0
192 blob
193 mark :$m
194 data 0
195 blob
196 mark :$n
197 data 0
199 echo "M 100644 :$l l$i" >>input.commit
200 echo "M 100644 :$m m$i" >>input.commit
201 echo "M 100644 :$n n$i" >>input.commit
203 echo ":$l $mt" >>marks.exp
204 echo ":$m $mt" >>marks.exp
205 echo ":$n $mt" >>marks.exp
207 printf "100644 blob $mt\tl$i\n" >>tree.exp
208 printf "100644 blob $mt\tm$i\n" >>tree.exp
209 printf "100644 blob $mt\tn$i\n" >>tree.exp
211 l=$(($l + $l))
212 m=$(($m + $m))
213 n=$(($l + $n))
215 i=$((1 + $i))
216 done
218 sort tree.exp > tree.exp_s
220 test_expect_success 'A: export marks with large values' '
221 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
222 git ls-tree refs/heads/verify--dump-marks >tree.out &&
223 test_cmp tree.exp_s tree.out &&
224 test_cmp marks.exp marks.large'
227 ### series B
230 test_tick
231 cat >input <<INPUT_END
232 commit refs/heads/branch
233 mark :1
234 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
235 data <<COMMIT
236 corrupt
237 COMMIT
239 from refs/heads/master
240 M 755 0000000000000000000000000000000000000001 zero1
242 INPUT_END
243 test_expect_success 'B: fail on invalid blob sha1' '
244 test_must_fail git fast-import <input
246 rm -f .git/objects/pack_* .git/objects/index_*
248 cat >input <<INPUT_END
249 commit .badbranchname
250 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
251 data <<COMMIT
252 corrupt
253 COMMIT
255 from refs/heads/master
257 INPUT_END
258 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
259 test_must_fail git fast-import <input
261 rm -f .git/objects/pack_* .git/objects/index_*
263 cat >input <<INPUT_END
264 commit bad[branch]name
265 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
266 data <<COMMIT
267 corrupt
268 COMMIT
270 from refs/heads/master
272 INPUT_END
273 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
274 test_must_fail git fast-import <input
276 rm -f .git/objects/pack_* .git/objects/index_*
278 cat >input <<INPUT_END
279 commit TEMP_TAG
280 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
281 data <<COMMIT
282 tag base
283 COMMIT
285 from refs/heads/master
287 INPUT_END
288 test_expect_success \
289 'B: accept branch name "TEMP_TAG"' \
290 'git fast-import <input &&
291 test -f .git/TEMP_TAG &&
292 test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
293 rm -f .git/TEMP_TAG
296 ### series C
299 newf=`echo hi newf | git hash-object -w --stdin`
300 oldf=`git rev-parse --verify master:file2`
301 test_tick
302 cat >input <<INPUT_END
303 commit refs/heads/branch
304 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
305 data <<COMMIT
306 second
307 COMMIT
309 from refs/heads/master
310 M 644 $oldf file2/oldf
311 M 755 $newf file2/newf
312 D file3
314 INPUT_END
315 test_expect_success \
316 'C: incremental import create pack from stdin' \
317 'git fast-import <input &&
318 git whatchanged branch'
319 test_expect_success \
320 'C: verify pack' \
321 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
322 test_expect_success \
323 'C: validate reuse existing blob' \
324 'test $newf = `git rev-parse --verify branch:file2/newf`
325 test $oldf = `git rev-parse --verify branch:file2/oldf`'
327 cat >expect <<EOF
328 parent `git rev-parse --verify master^0`
329 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
330 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
332 second
334 test_expect_success \
335 'C: verify commit' \
336 'git cat-file commit branch | sed 1d >actual &&
337 test_cmp expect actual'
339 cat >expect <<EOF
340 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
341 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
342 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
344 git diff-tree -M -r master branch >actual
345 test_expect_success \
346 'C: validate rename result' \
347 'compare_diff_raw expect actual'
350 ### series D
353 test_tick
354 cat >input <<INPUT_END
355 commit refs/heads/branch
356 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
357 data <<COMMIT
358 third
359 COMMIT
361 from refs/heads/branch^0
362 M 644 inline newdir/interesting
363 data <<EOF
364 $file5_data
367 M 755 inline newdir/exec.sh
368 data <<EOF
369 $file6_data
372 INPUT_END
373 test_expect_success \
374 'D: inline data in commit' \
375 'git fast-import <input &&
376 git whatchanged branch'
377 test_expect_success \
378 'D: verify pack' \
379 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
381 cat >expect <<EOF
382 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
383 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
385 git diff-tree -M -r branch^ branch >actual
386 test_expect_success \
387 'D: validate new files added' \
388 'compare_diff_raw expect actual'
390 echo "$file5_data" >expect
391 test_expect_success \
392 'D: verify file5' \
393 'git cat-file blob branch:newdir/interesting >actual &&
394 test_cmp expect actual'
396 echo "$file6_data" >expect
397 test_expect_success \
398 'D: verify file6' \
399 'git cat-file blob branch:newdir/exec.sh >actual &&
400 test_cmp expect actual'
403 ### series E
406 cat >input <<INPUT_END
407 commit refs/heads/branch
408 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
409 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
410 data <<COMMIT
411 RFC 2822 type date
412 COMMIT
414 from refs/heads/branch^0
416 INPUT_END
417 test_expect_success 'E: rfc2822 date, --date-format=raw' '
418 test_must_fail git fast-import --date-format=raw <input
420 test_expect_success \
421 'E: rfc2822 date, --date-format=rfc2822' \
422 'git fast-import --date-format=rfc2822 <input'
423 test_expect_success \
424 'E: verify pack' \
425 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
427 cat >expect <<EOF
428 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
429 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
431 RFC 2822 type date
433 test_expect_success \
434 'E: verify commit' \
435 'git cat-file commit branch | sed 1,2d >actual &&
436 test_cmp expect actual'
439 ### series F
442 old_branch=`git rev-parse --verify branch^0`
443 test_tick
444 cat >input <<INPUT_END
445 commit refs/heads/branch
446 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
447 data <<COMMIT
448 losing things already?
449 COMMIT
451 from refs/heads/branch~1
453 reset refs/heads/other
454 from refs/heads/branch
456 INPUT_END
457 test_expect_success \
458 'F: non-fast-forward update skips' \
459 'if git fast-import <input
460 then
461 echo BAD gfi did not fail
462 return 1
463 else
464 if test $old_branch = `git rev-parse --verify branch^0`
465 then
466 : branch unaffected and failure returned
467 return 0
468 else
469 echo BAD gfi changed branch $old_branch
470 return 1
474 test_expect_success \
475 'F: verify pack' \
476 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
478 cat >expect <<EOF
479 tree `git rev-parse branch~1^{tree}`
480 parent `git rev-parse branch~1`
481 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
482 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
484 losing things already?
486 test_expect_success \
487 'F: verify other commit' \
488 'git cat-file commit other >actual &&
489 test_cmp expect actual'
492 ### series G
495 old_branch=`git rev-parse --verify branch^0`
496 test_tick
497 cat >input <<INPUT_END
498 commit refs/heads/branch
499 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
500 data <<COMMIT
501 losing things already?
502 COMMIT
504 from refs/heads/branch~1
506 INPUT_END
507 test_expect_success \
508 'G: non-fast-forward update forced' \
509 'git fast-import --force <input'
510 test_expect_success \
511 'G: verify pack' \
512 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
513 test_expect_success \
514 'G: branch changed, but logged' \
515 'test $old_branch != `git rev-parse --verify branch^0` &&
516 test $old_branch = `git rev-parse --verify branch@{1}`'
519 ### series H
522 test_tick
523 cat >input <<INPUT_END
524 commit refs/heads/H
525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
526 data <<COMMIT
527 third
528 COMMIT
530 from refs/heads/branch^0
531 M 644 inline i-will-die
532 data <<EOF
533 this file will never exist.
536 deleteall
537 M 644 inline h/e/l/lo
538 data <<EOF
539 $file5_data
542 INPUT_END
543 test_expect_success \
544 'H: deletall, add 1' \
545 'git fast-import <input &&
546 git whatchanged H'
547 test_expect_success \
548 'H: verify pack' \
549 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
551 cat >expect <<EOF
552 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
553 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
554 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
555 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
556 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
558 git diff-tree -M -r H^ H >actual
559 test_expect_success \
560 'H: validate old files removed, new files added' \
561 'compare_diff_raw expect actual'
563 echo "$file5_data" >expect
564 test_expect_success \
565 'H: verify file' \
566 'git cat-file blob H:h/e/l/lo >actual &&
567 test_cmp expect actual'
570 ### series I
573 cat >input <<INPUT_END
574 commit refs/heads/export-boundary
575 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
576 data <<COMMIT
577 we have a border. its only 40 characters wide.
578 COMMIT
580 from refs/heads/branch
582 INPUT_END
583 test_expect_success \
584 'I: export-pack-edges' \
585 'git fast-import --export-pack-edges=edges.list <input'
587 cat >expect <<EOF
588 .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
590 test_expect_success \
591 'I: verify edge list' \
592 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
593 test_cmp expect actual'
596 ### series J
599 cat >input <<INPUT_END
600 commit refs/heads/J
601 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
602 data <<COMMIT
603 create J
604 COMMIT
606 from refs/heads/branch
608 reset refs/heads/J
610 commit refs/heads/J
611 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
612 data <<COMMIT
613 initialize J
614 COMMIT
616 INPUT_END
617 test_expect_success \
618 'J: reset existing branch creates empty commit' \
619 'git fast-import <input'
620 test_expect_success \
621 'J: branch has 1 commit, empty tree' \
622 'test 1 = `git rev-list J | wc -l` &&
623 test 0 = `git ls-tree J | wc -l`'
626 ### series K
629 cat >input <<INPUT_END
630 commit refs/heads/K
631 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
632 data <<COMMIT
633 create K
634 COMMIT
636 from refs/heads/branch
638 commit refs/heads/K
639 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
640 data <<COMMIT
641 redo K
642 COMMIT
644 from refs/heads/branch^1
646 INPUT_END
647 test_expect_success \
648 'K: reinit branch with from' \
649 'git fast-import <input'
650 test_expect_success \
651 'K: verify K^1 = branch^1' \
652 'test `git rev-parse --verify branch^1` \
653 = `git rev-parse --verify K^1`'
656 ### series L
659 cat >input <<INPUT_END
660 blob
661 mark :1
662 data <<EOF
663 some data
666 blob
667 mark :2
668 data <<EOF
669 other data
672 commit refs/heads/L
673 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
674 data <<COMMIT
675 create L
676 COMMIT
678 M 644 :1 b.
679 M 644 :1 b/other
680 M 644 :1 ba
682 commit refs/heads/L
683 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
684 data <<COMMIT
685 update L
686 COMMIT
688 M 644 :2 b.
689 M 644 :2 b/other
690 M 644 :2 ba
691 INPUT_END
693 cat >expect <<EXPECT_END
694 :100644 100644 4268632... 55d3a52... M b.
695 :040000 040000 0ae5cac... 443c768... M b
696 :100644 100644 4268632... 55d3a52... M ba
697 EXPECT_END
699 test_expect_success \
700 'L: verify internal tree sorting' \
701 'git fast-import <input &&
702 git diff-tree --abbrev --raw L^ L >output &&
703 test_cmp expect output'
706 ### series M
709 test_tick
710 cat >input <<INPUT_END
711 commit refs/heads/M1
712 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
713 data <<COMMIT
714 file rename
715 COMMIT
717 from refs/heads/branch^0
718 R file2/newf file2/n.e.w.f
720 INPUT_END
722 cat >expect <<EOF
723 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
725 test_expect_success \
726 'M: rename file in same subdirectory' \
727 'git fast-import <input &&
728 git diff-tree -M -r M1^ M1 >actual &&
729 compare_diff_raw expect actual'
731 cat >input <<INPUT_END
732 commit refs/heads/M2
733 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
734 data <<COMMIT
735 file rename
736 COMMIT
738 from refs/heads/branch^0
739 R file2/newf i/am/new/to/you
741 INPUT_END
743 cat >expect <<EOF
744 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
746 test_expect_success \
747 'M: rename file to new subdirectory' \
748 'git fast-import <input &&
749 git diff-tree -M -r M2^ M2 >actual &&
750 compare_diff_raw expect actual'
752 cat >input <<INPUT_END
753 commit refs/heads/M3
754 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
755 data <<COMMIT
756 file rename
757 COMMIT
759 from refs/heads/M2^0
760 R i other/sub
762 INPUT_END
764 cat >expect <<EOF
765 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
767 test_expect_success \
768 'M: rename subdirectory to new subdirectory' \
769 'git fast-import <input &&
770 git diff-tree -M -r M3^ M3 >actual &&
771 compare_diff_raw expect actual'
774 ### series N
777 test_tick
778 cat >input <<INPUT_END
779 commit refs/heads/N1
780 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
781 data <<COMMIT
782 file copy
783 COMMIT
785 from refs/heads/branch^0
786 C file2/newf file2/n.e.w.f
788 INPUT_END
790 cat >expect <<EOF
791 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
793 test_expect_success \
794 'N: copy file in same subdirectory' \
795 'git fast-import <input &&
796 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
797 compare_diff_raw expect actual'
799 cat >input <<INPUT_END
800 commit refs/heads/N2
801 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
802 data <<COMMIT
803 clean directory copy
804 COMMIT
806 from refs/heads/branch^0
807 C file2 file3
809 commit refs/heads/N2
810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
811 data <<COMMIT
812 modify directory copy
813 COMMIT
815 M 644 inline file3/file5
816 data <<EOF
817 $file5_data
820 INPUT_END
822 cat >expect <<EOF
823 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
824 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
825 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
827 test_expect_success \
828 'N: copy then modify subdirectory' \
829 'git fast-import <input &&
830 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
831 compare_diff_raw expect actual'
833 cat >input <<INPUT_END
834 commit refs/heads/N3
835 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
836 data <<COMMIT
837 dirty directory copy
838 COMMIT
840 from refs/heads/branch^0
841 M 644 inline file2/file5
842 data <<EOF
843 $file5_data
846 C file2 file3
847 D file2/file5
849 INPUT_END
851 test_expect_success \
852 'N: copy dirty subdirectory' \
853 'git fast-import <input &&
854 test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
856 test_expect_success \
857 'N: copy directory by id' \
858 'cat >expect <<-\EOF &&
859 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
860 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
862 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
863 cat >input <<-INPUT_END &&
864 commit refs/heads/N4
865 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
866 data <<COMMIT
867 copy by tree hash
868 COMMIT
870 from refs/heads/branch^0
871 M 040000 $subdir file3
872 INPUT_END
873 git fast-import <input &&
874 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
875 compare_diff_raw expect actual'
877 test_expect_success \
878 'N: copy root directory by tree hash' \
879 'cat >expect <<-\EOF &&
880 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
881 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
883 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
884 cat >input <<-INPUT_END &&
885 commit refs/heads/N6
886 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
887 data <<COMMIT
888 copy root directory by tree hash
889 COMMIT
891 from refs/heads/branch^0
892 M 040000 $root ""
893 INPUT_END
894 git fast-import <input &&
895 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
896 compare_diff_raw expect actual'
898 test_expect_success \
899 'N: modify copied tree' \
900 'cat >expect <<-\EOF &&
901 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
902 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
903 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
905 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
906 cat >input <<-INPUT_END &&
907 commit refs/heads/N5
908 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
909 data <<COMMIT
910 copy by tree hash
911 COMMIT
913 from refs/heads/branch^0
914 M 040000 $subdir file3
916 commit refs/heads/N5
917 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
918 data <<COMMIT
919 modify directory copy
920 COMMIT
922 M 644 inline file3/file5
923 data <<EOF
924 $file5_data
926 INPUT_END
927 git fast-import <input &&
928 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
929 compare_diff_raw expect actual'
931 test_expect_success \
932 'N: copy to root by id and modify' \
933 'echo "hello, world" >expect.foo &&
934 echo hello >expect.bar &&
935 git fast-import <<-SETUP_END &&
936 commit refs/heads/N7
937 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
938 data <<COMMIT
939 hello, tree
940 COMMIT
942 deleteall
943 M 644 inline foo/bar
944 data <<EOF
945 hello
947 SETUP_END
949 tree=$(git rev-parse --verify N7:) &&
950 git fast-import <<-INPUT_END &&
951 commit refs/heads/N8
952 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
953 data <<COMMIT
954 copy to root by id and modify
955 COMMIT
957 M 040000 $tree ""
958 M 644 inline foo/foo
959 data <<EOF
960 hello, world
962 INPUT_END
963 git show N8:foo/foo >actual.foo &&
964 git show N8:foo/bar >actual.bar &&
965 test_cmp expect.foo actual.foo &&
966 test_cmp expect.bar actual.bar'
969 ### series O
972 cat >input <<INPUT_END
973 #we will
974 commit refs/heads/O1
975 # -- ignore all of this text
976 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
977 # $GIT_COMMITTER_NAME has inserted here for his benefit.
978 data <<COMMIT
979 dirty directory copy
980 COMMIT
982 # don't forget the import blank line!
984 # yes, we started from our usual base of branch^0.
985 # i like branch^0.
986 from refs/heads/branch^0
987 # and we need to reuse file2/file5 from N3 above.
988 M 644 inline file2/file5
989 # otherwise the tree will be different
990 data <<EOF
991 $file5_data
994 # don't forget to copy file2 to file3
995 C file2 file3
997 # or to delete file5 from file2.
998 D file2/file5
999 # are we done yet?
1001 INPUT_END
1003 test_expect_success \
1004 'O: comments are all skipped' \
1005 'git fast-import <input &&
1006 test `git rev-parse N3` = `git rev-parse O1`'
1008 cat >input <<INPUT_END
1009 commit refs/heads/O2
1010 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1011 data <<COMMIT
1012 dirty directory copy
1013 COMMIT
1014 from refs/heads/branch^0
1015 M 644 inline file2/file5
1016 data <<EOF
1017 $file5_data
1019 C file2 file3
1020 D file2/file5
1022 INPUT_END
1024 test_expect_success \
1025 'O: blank lines not necessary after data commands' \
1026 'git fast-import <input &&
1027 test `git rev-parse N3` = `git rev-parse O2`'
1029 test_expect_success \
1030 'O: repack before next test' \
1031 'git repack -a -d'
1033 cat >input <<INPUT_END
1034 commit refs/heads/O3
1035 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1036 data <<COMMIT
1037 zstring
1038 COMMIT
1039 commit refs/heads/O3
1040 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1041 data <<COMMIT
1043 COMMIT
1044 checkpoint
1045 commit refs/heads/O3
1046 mark :5
1047 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1048 data <<COMMIT
1049 zempty
1050 COMMIT
1051 checkpoint
1052 commit refs/heads/O3
1053 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1054 data <<COMMIT
1055 zcommits
1056 COMMIT
1057 reset refs/tags/O3-2nd
1058 from :5
1059 reset refs/tags/O3-3rd
1060 from :5
1061 INPUT_END
1063 cat >expect <<INPUT_END
1064 string
1066 empty
1067 commits
1068 INPUT_END
1069 test_expect_success \
1070 'O: blank lines not necessary after other commands' \
1071 'git fast-import <input &&
1072 test 8 = `find .git/objects/pack -type f | wc -l` &&
1073 test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
1074 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1075 test_cmp expect actual'
1077 cat >input <<INPUT_END
1078 commit refs/heads/O4
1079 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1080 data <<COMMIT
1081 zstring
1082 COMMIT
1083 commit refs/heads/O4
1084 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1085 data <<COMMIT
1087 COMMIT
1088 progress Two commits down, 2 to go!
1089 commit refs/heads/O4
1090 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1091 data <<COMMIT
1092 zempty
1093 COMMIT
1094 progress Three commits down, 1 to go!
1095 commit refs/heads/O4
1096 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1097 data <<COMMIT
1098 zcommits
1099 COMMIT
1100 progress I'm done!
1101 INPUT_END
1102 test_expect_success \
1103 'O: progress outputs as requested by input' \
1104 'git fast-import <input >actual &&
1105 grep "progress " <input >expect &&
1106 test_cmp expect actual'
1109 ### series P (gitlinks)
1112 cat >input <<INPUT_END
1113 blob
1114 mark :1
1115 data 10
1116 test file
1118 reset refs/heads/sub
1119 commit refs/heads/sub
1120 mark :2
1121 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1122 data 12
1123 sub_initial
1124 M 100644 :1 file
1126 blob
1127 mark :3
1128 data <<DATAEND
1129 [submodule "sub"]
1130 path = sub
1131 url = "`pwd`/sub"
1132 DATAEND
1134 commit refs/heads/subuse1
1135 mark :4
1136 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1137 data 8
1138 initial
1139 from refs/heads/master
1140 M 100644 :3 .gitmodules
1141 M 160000 :2 sub
1143 blob
1144 mark :5
1145 data 20
1146 test file
1147 more data
1149 commit refs/heads/sub
1150 mark :6
1151 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1152 data 11
1153 sub_second
1154 from :2
1155 M 100644 :5 file
1157 commit refs/heads/subuse1
1158 mark :7
1159 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1160 data 7
1161 second
1162 from :4
1163 M 160000 :6 sub
1165 INPUT_END
1167 test_expect_success \
1168 'P: supermodule & submodule mix' \
1169 'git fast-import <input &&
1170 git checkout subuse1 &&
1171 rm -rf sub && mkdir sub && (cd sub &&
1172 git init &&
1173 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1174 git checkout master) &&
1175 git submodule init &&
1176 git submodule update'
1178 SUBLAST=$(git rev-parse --verify sub)
1179 SUBPREV=$(git rev-parse --verify sub^)
1181 cat >input <<INPUT_END
1182 blob
1183 mark :1
1184 data <<DATAEND
1185 [submodule "sub"]
1186 path = sub
1187 url = "`pwd`/sub"
1188 DATAEND
1190 commit refs/heads/subuse2
1191 mark :2
1192 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1193 data 8
1194 initial
1195 from refs/heads/master
1196 M 100644 :1 .gitmodules
1197 M 160000 $SUBPREV sub
1199 commit refs/heads/subuse2
1200 mark :3
1201 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1202 data 7
1203 second
1204 from :2
1205 M 160000 $SUBLAST sub
1207 INPUT_END
1209 test_expect_success \
1210 'P: verbatim SHA gitlinks' \
1211 'git branch -D sub &&
1212 git gc && git prune &&
1213 git fast-import <input &&
1214 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
1216 test_tick
1217 cat >input <<INPUT_END
1218 commit refs/heads/subuse3
1219 mark :1
1220 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1221 data <<COMMIT
1222 corrupt
1223 COMMIT
1225 from refs/heads/subuse2
1226 M 160000 inline sub
1227 data <<DATA
1228 $SUBPREV
1229 DATA
1231 INPUT_END
1233 test_expect_success 'P: fail on inline gitlink' '
1234 test_must_fail git fast-import <input'
1236 test_tick
1237 cat >input <<INPUT_END
1238 blob
1239 mark :1
1240 data <<DATA
1241 $SUBPREV
1242 DATA
1244 commit refs/heads/subuse3
1245 mark :2
1246 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1247 data <<COMMIT
1248 corrupt
1249 COMMIT
1251 from refs/heads/subuse2
1252 M 160000 :1 sub
1254 INPUT_END
1256 test_expect_success 'P: fail on blob mark in gitlink' '
1257 test_must_fail git fast-import <input'
1260 ### series Q (notes)
1263 note1_data="The first note for the first commit"
1264 note2_data="The first note for the second commit"
1265 note3_data="The first note for the third commit"
1266 note1b_data="The second note for the first commit"
1267 note1c_data="The third note for the first commit"
1268 note2b_data="The second note for the second commit"
1270 test_tick
1271 cat >input <<INPUT_END
1272 blob
1273 mark :2
1274 data <<EOF
1275 $file2_data
1278 commit refs/heads/notes-test
1279 mark :3
1280 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1281 data <<COMMIT
1282 first (:3)
1283 COMMIT
1285 M 644 :2 file2
1287 blob
1288 mark :4
1289 data $file4_len
1290 $file4_data
1291 commit refs/heads/notes-test
1292 mark :5
1293 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1294 data <<COMMIT
1295 second (:5)
1296 COMMIT
1298 M 644 :4 file4
1300 commit refs/heads/notes-test
1301 mark :6
1302 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1303 data <<COMMIT
1304 third (:6)
1305 COMMIT
1307 M 644 inline file5
1308 data <<EOF
1309 $file5_data
1312 M 755 inline file6
1313 data <<EOF
1314 $file6_data
1317 blob
1318 mark :7
1319 data <<EOF
1320 $note1_data
1323 blob
1324 mark :8
1325 data <<EOF
1326 $note2_data
1329 commit refs/notes/foobar
1330 mark :9
1331 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1332 data <<COMMIT
1333 notes (:9)
1334 COMMIT
1336 N :7 :3
1337 N :8 :5
1338 N inline :6
1339 data <<EOF
1340 $note3_data
1343 commit refs/notes/foobar
1344 mark :10
1345 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1346 data <<COMMIT
1347 notes (:10)
1348 COMMIT
1350 N inline :3
1351 data <<EOF
1352 $note1b_data
1355 commit refs/notes/foobar2
1356 mark :11
1357 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1358 data <<COMMIT
1359 notes (:11)
1360 COMMIT
1362 N inline :3
1363 data <<EOF
1364 $note1c_data
1367 commit refs/notes/foobar
1368 mark :12
1369 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1370 data <<COMMIT
1371 notes (:12)
1372 COMMIT
1374 deleteall
1375 N inline :5
1376 data <<EOF
1377 $note2b_data
1380 INPUT_END
1382 test_expect_success \
1383 'Q: commit notes' \
1384 'git fast-import <input &&
1385 git whatchanged notes-test'
1386 test_expect_success \
1387 'Q: verify pack' \
1388 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1390 commit1=$(git rev-parse notes-test~2)
1391 commit2=$(git rev-parse notes-test^)
1392 commit3=$(git rev-parse notes-test)
1394 cat >expect <<EOF
1395 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1396 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1398 first (:3)
1400 test_expect_success \
1401 'Q: verify first commit' \
1402 'git cat-file commit notes-test~2 | sed 1d >actual &&
1403 test_cmp expect actual'
1405 cat >expect <<EOF
1406 parent $commit1
1407 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1408 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1410 second (:5)
1412 test_expect_success \
1413 'Q: verify second commit' \
1414 'git cat-file commit notes-test^ | sed 1d >actual &&
1415 test_cmp expect actual'
1417 cat >expect <<EOF
1418 parent $commit2
1419 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1420 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1422 third (:6)
1424 test_expect_success \
1425 'Q: verify third commit' \
1426 'git cat-file commit notes-test | sed 1d >actual &&
1427 test_cmp expect actual'
1429 cat >expect <<EOF
1430 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1431 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1433 notes (:9)
1435 test_expect_success \
1436 'Q: verify first notes commit' \
1437 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1438 test_cmp expect actual'
1440 cat >expect.unsorted <<EOF
1441 100644 blob $commit1
1442 100644 blob $commit2
1443 100644 blob $commit3
1445 cat expect.unsorted | sort >expect
1446 test_expect_success \
1447 'Q: verify first notes tree' \
1448 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1449 test_cmp expect actual'
1451 echo "$note1_data" >expect
1452 test_expect_success \
1453 'Q: verify first note for first commit' \
1454 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
1456 echo "$note2_data" >expect
1457 test_expect_success \
1458 'Q: verify first note for second commit' \
1459 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
1461 echo "$note3_data" >expect
1462 test_expect_success \
1463 'Q: verify first note for third commit' \
1464 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
1466 cat >expect <<EOF
1467 parent `git rev-parse --verify refs/notes/foobar~2`
1468 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1469 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1471 notes (:10)
1473 test_expect_success \
1474 'Q: verify second notes commit' \
1475 'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1476 test_cmp expect actual'
1478 cat >expect.unsorted <<EOF
1479 100644 blob $commit1
1480 100644 blob $commit2
1481 100644 blob $commit3
1483 cat expect.unsorted | sort >expect
1484 test_expect_success \
1485 'Q: verify second notes tree' \
1486 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1487 test_cmp expect actual'
1489 echo "$note1b_data" >expect
1490 test_expect_success \
1491 'Q: verify second note for first commit' \
1492 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
1494 echo "$note2_data" >expect
1495 test_expect_success \
1496 'Q: verify first note for second commit' \
1497 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
1499 echo "$note3_data" >expect
1500 test_expect_success \
1501 'Q: verify first note for third commit' \
1502 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
1504 cat >expect <<EOF
1505 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1506 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1508 notes (:11)
1510 test_expect_success \
1511 'Q: verify third notes commit' \
1512 'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
1513 test_cmp expect actual'
1515 cat >expect.unsorted <<EOF
1516 100644 blob $commit1
1518 cat expect.unsorted | sort >expect
1519 test_expect_success \
1520 'Q: verify third notes tree' \
1521 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1522 test_cmp expect actual'
1524 echo "$note1c_data" >expect
1525 test_expect_success \
1526 'Q: verify third note for first commit' \
1527 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
1529 cat >expect <<EOF
1530 parent `git rev-parse --verify refs/notes/foobar^`
1531 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1534 notes (:12)
1536 test_expect_success \
1537 'Q: verify fourth notes commit' \
1538 'git cat-file commit refs/notes/foobar | sed 1d >actual &&
1539 test_cmp expect actual'
1541 cat >expect.unsorted <<EOF
1542 100644 blob $commit2
1544 cat expect.unsorted | sort >expect
1545 test_expect_success \
1546 'Q: verify fourth notes tree' \
1547 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1548 test_cmp expect actual'
1550 echo "$note2b_data" >expect
1551 test_expect_success \
1552 'Q: verify second note for second commit' \
1553 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
1556 ### series R (feature and option)
1559 cat >input <<EOF
1560 feature no-such-feature-exists
1563 test_expect_success 'R: abort on unsupported feature' '
1564 test_must_fail git fast-import <input
1567 cat >input <<EOF
1568 feature date-format=now
1571 test_expect_success 'R: supported feature is accepted' '
1572 git fast-import <input
1575 cat >input << EOF
1576 blob
1577 data 3
1579 feature date-format=now
1582 test_expect_success 'R: abort on receiving feature after data command' '
1583 test_must_fail git fast-import <input
1586 cat >input << EOF
1587 feature import-marks=git.marks
1588 feature import-marks=git2.marks
1591 test_expect_success 'R: only one import-marks feature allowed per stream' '
1592 test_must_fail git fast-import <input
1595 cat >input << EOF
1596 feature export-marks=git.marks
1597 blob
1598 mark :1
1599 data 3
1604 test_expect_success \
1605 'R: export-marks feature results in a marks file being created' \
1606 'cat input | git fast-import &&
1607 grep :1 git.marks'
1609 test_expect_success \
1610 'R: export-marks options can be overriden by commandline options' \
1611 'cat input | git fast-import --export-marks=other.marks &&
1612 grep :1 other.marks'
1614 cat >input << EOF
1615 feature import-marks=marks.out
1616 feature export-marks=marks.new
1619 test_expect_success \
1620 'R: import to output marks works without any content' \
1621 'cat input | git fast-import &&
1622 test_cmp marks.out marks.new'
1624 cat >input <<EOF
1625 feature import-marks=nonexistant.marks
1626 feature export-marks=marks.new
1629 test_expect_success \
1630 'R: import marks prefers commandline marks file over the stream' \
1631 'cat input | git fast-import --import-marks=marks.out &&
1632 test_cmp marks.out marks.new'
1635 cat >input <<EOF
1636 feature import-marks=nonexistant.marks
1637 feature export-marks=combined.marks
1640 test_expect_success 'R: multiple --import-marks= should be honoured' '
1641 head -n2 marks.out > one.marks &&
1642 tail -n +3 marks.out > two.marks &&
1643 git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
1644 test_cmp marks.out combined.marks
1647 cat >input <<EOF
1648 feature relative-marks
1649 feature import-marks=relative.in
1650 feature export-marks=relative.out
1653 test_expect_success 'R: feature relative-marks should be honoured' '
1654 mkdir -p .git/info/fast-import/ &&
1655 cp marks.new .git/info/fast-import/relative.in &&
1656 git fast-import <input &&
1657 test_cmp marks.new .git/info/fast-import/relative.out
1660 cat >input <<EOF
1661 feature relative-marks
1662 feature import-marks=relative.in
1663 feature no-relative-marks
1664 feature export-marks=non-relative.out
1667 test_expect_success 'R: feature no-relative-marks should be honoured' '
1668 git fast-import <input &&
1669 test_cmp marks.new non-relative.out
1672 cat >input << EOF
1673 option git quiet
1674 blob
1675 data 3
1680 touch empty
1682 test_expect_success 'R: quiet option results in no stats being output' '
1683 cat input | git fast-import 2> output &&
1684 test_cmp empty output
1687 cat >input <<EOF
1688 option git non-existing-option
1691 test_expect_success 'R: die on unknown option' '
1692 test_must_fail git fast-import <input
1695 test_expect_success 'R: unknown commandline options are rejected' '\
1696 test_must_fail git fast-import --non-existing-option < /dev/null
1699 cat >input <<EOF
1700 option non-existing-vcs non-existing-option
1703 test_expect_success 'R: ignore non-git options' '
1704 git fast-import <input
1708 ## R: very large blobs
1710 blobsize=$((2*1024*1024 + 53))
1711 test-genrandom bar $blobsize >expect
1712 cat >input <<INPUT_END
1713 commit refs/heads/big-file
1714 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1715 data <<COMMIT
1716 R - big file
1717 COMMIT
1719 M 644 inline big1
1720 data $blobsize
1721 INPUT_END
1722 cat expect >>input
1723 cat >>input <<INPUT_END
1724 M 644 inline big2
1725 data $blobsize
1726 INPUT_END
1727 cat expect >>input
1728 echo >>input
1730 test_expect_success \
1731 'R: blob bigger than threshold' \
1732 'test_create_repo R &&
1733 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
1734 test_expect_success \
1735 'R: verify created pack' \
1736 ': >verify &&
1737 for p in R/.git/objects/pack/*.pack;
1739 git verify-pack -v $p >>verify || exit;
1740 done'
1741 test_expect_success \
1742 'R: verify written objects' \
1743 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
1744 test_cmp expect actual &&
1745 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
1746 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
1747 test $a = $b'
1748 test_expect_success \
1749 'R: blob appears only once' \
1750 'n=$(grep $a verify | wc -l) &&
1751 test 1 = $n'
1753 test_done