]> git.ipfire.org Git - thirdparty/git.git/blob - t/t9010-svn-fe.sh
Start the 2.46 cycle
[thirdparty/git.git] / t / t9010-svn-fe.sh
1 #!/bin/sh
2
3 test_description='check svn dumpfile importer'
4
5 . ./test-lib.sh
6
7 if test_have_prereq !PIPE
8 then
9 skip_all="svn dumpfile importer testing requires the PIPE prerequisite"
10 test_done
11 fi
12
13 reinit_git () {
14 rm -fr .git &&
15 rm -f stream backflow &&
16 git init &&
17 mkfifo stream backflow
18 }
19
20 try_dump () {
21 input=$1 &&
22 maybe_fail_svnfe=${2:+test_$2} &&
23 maybe_fail_fi=${3:+test_$3} &&
24
25 {
26 $maybe_fail_svnfe test-svn-fe "$input" >stream 3<backflow &
27 } &&
28 $maybe_fail_fi git fast-import --cat-blob-fd=3 <stream 3>backflow &&
29 wait $!
30 }
31
32 properties () {
33 while test "$#" -ne 0
34 do
35 property="$1" &&
36 value="$2" &&
37 printf "%s\n" "K ${#property}" &&
38 printf "%s\n" "$property" &&
39 printf "%s\n" "V ${#value}" &&
40 printf "%s\n" "$value" &&
41 shift 2 ||
42 return 1
43 done
44 }
45
46 text_no_props () {
47 text="$1
48 " &&
49 printf "%s\n" "Prop-content-length: 10" &&
50 printf "%s\n" "Text-content-length: ${#text}" &&
51 printf "%s\n" "Content-length: $((${#text} + 10))" &&
52 printf "%s\n" "" "PROPS-END" &&
53 printf "%s\n" "$text"
54 }
55
56 test_expect_success 'empty dump' '
57 reinit_git &&
58 echo "SVN-fs-dump-format-version: 2" >input &&
59 try_dump input
60 '
61
62 test_expect_success 'v4 dumps not supported' '
63 reinit_git &&
64 echo "SVN-fs-dump-format-version: 4" >v4.dump &&
65 try_dump v4.dump must_fail
66 '
67
68 test_expect_failure 'empty revision' '
69 reinit_git &&
70 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
71 cat >emptyrev.dump <<-\EOF &&
72 SVN-fs-dump-format-version: 3
73
74 Revision-number: 1
75 Prop-content-length: 0
76 Content-length: 0
77
78 Revision-number: 2
79 Prop-content-length: 0
80 Content-length: 0
81
82 EOF
83 try_dump emptyrev.dump &&
84 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
85 test_cmp expect actual
86 '
87
88 test_expect_success 'empty properties' '
89 reinit_git &&
90 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
91 cat >emptyprop.dump <<-\EOF &&
92 SVN-fs-dump-format-version: 3
93
94 Revision-number: 1
95 Prop-content-length: 10
96 Content-length: 10
97
98 PROPS-END
99
100 Revision-number: 2
101 Prop-content-length: 10
102 Content-length: 10
103
104 PROPS-END
105 EOF
106 try_dump emptyprop.dump &&
107 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
108 test_cmp expect actual
109 '
110
111 test_expect_success 'author name and commit message' '
112 reinit_git &&
113 echo "<author@example.com, author@example.com@local>" >expect.author &&
114 cat >message <<-\EOF &&
115 A concise summary of the change
116
117 A detailed description of the change, why it is needed, what
118 was broken and why applying this is the best course of action.
119
120 * file.c
121 Details pertaining to an individual file.
122 EOF
123 {
124 properties \
125 svn:author author@example.com \
126 svn:log "$(cat message)" &&
127 echo PROPS-END
128 } >props &&
129 {
130 echo "SVN-fs-dump-format-version: 3" &&
131 echo &&
132 echo "Revision-number: 1" &&
133 echo Prop-content-length: $(wc -c <props) &&
134 echo Content-length: $(wc -c <props) &&
135 echo &&
136 cat props
137 } >log.dump &&
138 try_dump log.dump &&
139 git log -p --format="%B" HEAD >actual.log &&
140 git log --format="<%an, %ae>" >actual.author &&
141 test_cmp message actual.log &&
142 test_cmp expect.author actual.author
143 '
144
145 test_expect_success 'unsupported properties are ignored' '
146 reinit_git &&
147 echo author >expect &&
148 cat >extraprop.dump <<-\EOF &&
149 SVN-fs-dump-format-version: 3
150
151 Revision-number: 1
152 Prop-content-length: 56
153 Content-length: 56
154
155 K 8
156 nonsense
157 V 1
158 y
159 K 10
160 svn:author
161 V 6
162 author
163 PROPS-END
164 EOF
165 try_dump extraprop.dump &&
166 git log -p --format=%an HEAD >actual &&
167 test_cmp expect actual
168 '
169
170 test_expect_failure 'timestamp and empty file' '
171 echo author@example.com >expect.author &&
172 echo 1999-01-01 >expect.date &&
173 echo file >expect.files &&
174 reinit_git &&
175 {
176 properties \
177 svn:author author@example.com \
178 svn:date "1999-01-01T00:01:002.000000Z" \
179 svn:log "add empty file" &&
180 echo PROPS-END
181 } >props &&
182 {
183 cat <<-EOF &&
184 SVN-fs-dump-format-version: 3
185
186 Revision-number: 1
187 EOF
188 echo Prop-content-length: $(wc -c <props) &&
189 echo Content-length: $(wc -c <props) &&
190 echo &&
191 cat props &&
192 cat <<-\EOF
193
194 Node-path: empty-file
195 Node-kind: file
196 Node-action: add
197 Content-length: 0
198
199 EOF
200 } >emptyfile.dump &&
201 try_dump emptyfile.dump &&
202 git log --format=%an HEAD >actual.author &&
203 git log --date=short --format=%ad HEAD >actual.date &&
204 git ls-tree -r --name-only HEAD >actual.files &&
205 test_cmp expect.author actual.author &&
206 test_cmp expect.date actual.date &&
207 test_cmp expect.files actual.files &&
208 git checkout HEAD empty-file &&
209 test_must_be_empty file
210 '
211
212 test_expect_success 'directory with files' '
213 reinit_git &&
214 printf "%s\n" directory/file1 directory/file2 >expect.files &&
215 echo hi >hi &&
216 echo hello >hello &&
217 {
218 properties \
219 svn:author author@example.com \
220 svn:date "1999-02-01T00:01:002.000000Z" \
221 svn:log "add directory with some files in it" &&
222 echo PROPS-END
223 } >props &&
224 {
225 cat <<-EOF &&
226 SVN-fs-dump-format-version: 3
227
228 Revision-number: 1
229 EOF
230 echo Prop-content-length: $(wc -c <props) &&
231 echo Content-length: $(wc -c <props) &&
232 echo &&
233 cat props &&
234 cat <<-\EOF &&
235
236 Node-path: directory
237 Node-kind: dir
238 Node-action: add
239 Prop-content-length: 10
240 Content-length: 10
241
242 PROPS-END
243
244 Node-path: directory/file1
245 Node-kind: file
246 Node-action: add
247 EOF
248 text_no_props hello &&
249 cat <<-\EOF &&
250 Node-path: directory/file2
251 Node-kind: file
252 Node-action: add
253 EOF
254 text_no_props hi
255 } >directory.dump &&
256 try_dump directory.dump &&
257
258 git ls-tree -r --name-only HEAD >actual.files &&
259 git checkout HEAD directory &&
260 test_cmp expect.files actual.files &&
261 test_cmp hello directory/file1 &&
262 test_cmp hi directory/file2
263 '
264
265 test_expect_success 'branch name with backslash' '
266 reinit_git &&
267 sort <<-\EOF >expect.branch-files &&
268 trunk/file1
269 trunk/file2
270 "branches/UpdateFOPto094\\/file1"
271 "branches/UpdateFOPto094\\/file2"
272 EOF
273
274 echo hi >hi &&
275 echo hello >hello &&
276 {
277 properties \
278 svn:author author@example.com \
279 svn:date "1999-02-02T00:01:02.000000Z" \
280 svn:log "add directory with some files in it" &&
281 echo PROPS-END
282 } >props.setup &&
283 {
284 properties \
285 svn:author brancher@example.com \
286 svn:date "2007-12-06T21:38:34.000000Z" \
287 svn:log "Updating fop to .94 and adjust fo-stylesheets" &&
288 echo PROPS-END
289 } >props.branch &&
290 {
291 cat <<-EOF &&
292 SVN-fs-dump-format-version: 3
293
294 Revision-number: 1
295 EOF
296 echo Prop-content-length: $(wc -c <props.setup) &&
297 echo Content-length: $(wc -c <props.setup) &&
298 echo &&
299 cat props.setup &&
300 cat <<-\EOF &&
301
302 Node-path: trunk
303 Node-kind: dir
304 Node-action: add
305 Prop-content-length: 10
306 Content-length: 10
307
308 PROPS-END
309
310 Node-path: branches
311 Node-kind: dir
312 Node-action: add
313 Prop-content-length: 10
314 Content-length: 10
315
316 PROPS-END
317
318 Node-path: trunk/file1
319 Node-kind: file
320 Node-action: add
321 EOF
322 text_no_props hello &&
323 cat <<-\EOF &&
324 Node-path: trunk/file2
325 Node-kind: file
326 Node-action: add
327 EOF
328 text_no_props hi &&
329 cat <<-\EOF &&
330
331 Revision-number: 2
332 EOF
333 echo Prop-content-length: $(wc -c <props.branch) &&
334 echo Content-length: $(wc -c <props.branch) &&
335 echo &&
336 cat props.branch &&
337 cat <<-\EOF
338
339 Node-path: branches/UpdateFOPto094\
340 Node-kind: dir
341 Node-action: add
342 Node-copyfrom-rev: 1
343 Node-copyfrom-path: trunk
344
345 Node-kind: dir
346 Node-action: add
347 Prop-content-length: 34
348 Content-length: 34
349
350 K 13
351 svn:mergeinfo
352 V 0
353
354 PROPS-END
355 EOF
356 } >branch.dump &&
357 try_dump branch.dump &&
358
359 git ls-tree -r --name-only HEAD |
360 sort >actual.branch-files &&
361 test_cmp expect.branch-files actual.branch-files
362 '
363
364 test_expect_success 'node without action' '
365 reinit_git &&
366 cat >inaction.dump <<-\EOF &&
367 SVN-fs-dump-format-version: 3
368
369 Revision-number: 1
370 Prop-content-length: 10
371 Content-length: 10
372
373 PROPS-END
374
375 Node-path: directory
376 Node-kind: dir
377 Prop-content-length: 10
378 Content-length: 10
379
380 PROPS-END
381 EOF
382 try_dump inaction.dump must_fail
383 '
384
385 test_expect_success 'action: add node without text' '
386 reinit_git &&
387 cat >textless.dump <<-\EOF &&
388 SVN-fs-dump-format-version: 3
389
390 Revision-number: 1
391 Prop-content-length: 10
392 Content-length: 10
393
394 PROPS-END
395
396 Node-path: textless
397 Node-kind: file
398 Node-action: add
399 Prop-content-length: 10
400 Content-length: 10
401
402 PROPS-END
403 EOF
404 try_dump textless.dump must_fail
405 '
406
407 test_expect_failure 'change file mode but keep old content' '
408 reinit_git &&
409 cat >expect <<-\EOF &&
410 OBJID
411 :120000 100644 OBJID OBJID T greeting
412 OBJID
413 :100644 120000 OBJID OBJID T greeting
414 OBJID
415 :000000 100644 OBJID OBJID A greeting
416 EOF
417 echo "link hello" >expect.blob &&
418 echo hello >hello &&
419 cat >filemode.dump <<-\EOF &&
420 SVN-fs-dump-format-version: 3
421
422 Revision-number: 1
423 Prop-content-length: 10
424 Content-length: 10
425
426 PROPS-END
427
428 Node-path: greeting
429 Node-kind: file
430 Node-action: add
431 Prop-content-length: 10
432 Text-content-length: 11
433 Content-length: 21
434
435 PROPS-END
436 link hello
437
438 Revision-number: 2
439 Prop-content-length: 10
440 Content-length: 10
441
442 PROPS-END
443
444 Node-path: greeting
445 Node-kind: file
446 Node-action: change
447 Prop-content-length: 33
448 Content-length: 33
449
450 K 11
451 svn:special
452 V 1
453 *
454 PROPS-END
455
456 Revision-number: 3
457 Prop-content-length: 10
458 Content-length: 10
459
460 PROPS-END
461
462 Node-path: greeting
463 Node-kind: file
464 Node-action: change
465 Prop-content-length: 10
466 Content-length: 10
467
468 PROPS-END
469 EOF
470 try_dump filemode.dump &&
471 {
472 git rev-list HEAD |
473 git diff-tree --root --stdin |
474 sed "s/$OID_REGEX/OBJID/g"
475 } >actual &&
476 git show HEAD:greeting >actual.blob &&
477 git show HEAD^:greeting >actual.target &&
478 test_cmp expect actual &&
479 test_cmp expect.blob actual.blob &&
480 test_cmp hello actual.target
481 '
482
483 test_expect_success 'NUL in property value' '
484 reinit_git &&
485 echo "commit message" >expect.message &&
486 {
487 properties \
488 unimportant "something with a NUL (Q)" \
489 svn:log "commit message"&&
490 echo PROPS-END
491 } |
492 q_to_nul >props &&
493 {
494 cat <<-\EOF &&
495 SVN-fs-dump-format-version: 3
496
497 Revision-number: 1
498 EOF
499 echo Prop-content-length: $(wc -c <props) &&
500 echo Content-length: $(wc -c <props) &&
501 echo &&
502 cat props
503 } >nulprop.dump &&
504 try_dump nulprop.dump &&
505 git diff-tree --always -s --format=%s HEAD >actual.message &&
506 test_cmp expect.message actual.message
507 '
508
509 test_expect_success 'NUL in log message, file content, and property name' '
510 # Caveat: svnadmin 1.6.16 (r1073529) truncates at \0 in the
511 # svn:specialQnotreally example.
512 reinit_git &&
513 cat >expect <<-\EOF &&
514 OBJID
515 :100644 100644 OBJID OBJID M greeting
516 OBJID
517 :000000 100644 OBJID OBJID A greeting
518 EOF
519 printf "\n%s\n" "something with an ASCII NUL (Q)" >expect.message &&
520 printf "%s\n" "helQo" >expect.hello1 &&
521 printf "%s\n" "link hello" >expect.hello2 &&
522 {
523 properties svn:log "something with an ASCII NUL (Q)" &&
524 echo PROPS-END
525 } |
526 q_to_nul >props &&
527 {
528 q_to_nul <<-\EOF &&
529 SVN-fs-dump-format-version: 3
530
531 Revision-number: 1
532 Prop-content-length: 10
533 Content-length: 10
534
535 PROPS-END
536
537 Node-path: greeting
538 Node-kind: file
539 Node-action: add
540 Prop-content-length: 10
541 Text-content-length: 6
542 Content-length: 16
543
544 PROPS-END
545 helQo
546
547 Revision-number: 2
548 EOF
549 echo Prop-content-length: $(wc -c <props) &&
550 echo Content-length: $(wc -c <props) &&
551 echo &&
552 cat props &&
553 q_to_nul <<-\EOF
554
555 Node-path: greeting
556 Node-kind: file
557 Node-action: change
558 Prop-content-length: 43
559 Text-content-length: 11
560 Content-length: 54
561
562 K 21
563 svn:specialQnotreally
564 V 1
565 *
566 PROPS-END
567 link hello
568 EOF
569 } >8bitclean.dump &&
570 try_dump 8bitclean.dump &&
571 {
572 git rev-list HEAD |
573 git diff-tree --root --stdin |
574 sed "s/$OID_REGEX/OBJID/g"
575 } >actual &&
576 {
577 git cat-file commit HEAD | nul_to_q &&
578 echo
579 } |
580 sed -ne "/^\$/,\$ p" >actual.message &&
581 git cat-file blob HEAD^:greeting | nul_to_q >actual.hello1 &&
582 git cat-file blob HEAD:greeting | nul_to_q >actual.hello2 &&
583 test_cmp expect actual &&
584 test_cmp expect.message actual.message &&
585 test_cmp expect.hello1 actual.hello1 &&
586 test_cmp expect.hello2 actual.hello2
587 '
588
589 test_expect_success 'change file mode and reiterate content' '
590 reinit_git &&
591 cat >expect <<-\EOF &&
592 OBJID
593 :120000 100644 OBJID OBJID T greeting
594 OBJID
595 :100644 120000 OBJID OBJID T greeting
596 OBJID
597 :000000 100644 OBJID OBJID A greeting
598 EOF
599 echo "link hello" >expect.blob &&
600 echo hello >hello &&
601 cat >filemode2.dump <<-\EOF &&
602 SVN-fs-dump-format-version: 3
603
604 Revision-number: 1
605 Prop-content-length: 10
606 Content-length: 10
607
608 PROPS-END
609
610 Node-path: greeting
611 Node-kind: file
612 Node-action: add
613 Prop-content-length: 10
614 Text-content-length: 11
615 Content-length: 21
616
617 PROPS-END
618 link hello
619
620 Revision-number: 2
621 Prop-content-length: 10
622 Content-length: 10
623
624 PROPS-END
625
626 Node-path: greeting
627 Node-kind: file
628 Node-action: change
629 Prop-content-length: 33
630 Text-content-length: 11
631 Content-length: 44
632
633 K 11
634 svn:special
635 V 1
636 *
637 PROPS-END
638 link hello
639
640 Revision-number: 3
641 Prop-content-length: 10
642 Content-length: 10
643
644 PROPS-END
645
646 Node-path: greeting
647 Node-kind: file
648 Node-action: change
649 Prop-content-length: 10
650 Text-content-length: 11
651 Content-length: 21
652
653 PROPS-END
654 link hello
655 EOF
656 try_dump filemode2.dump &&
657 {
658 git rev-list HEAD |
659 git diff-tree --root --stdin |
660 sed "s/$OID_REGEX/OBJID/g"
661 } >actual &&
662 git show HEAD:greeting >actual.blob &&
663 git show HEAD^:greeting >actual.target &&
664 test_cmp expect actual &&
665 test_cmp expect.blob actual.blob &&
666 test_cmp hello actual.target
667 '
668
669 test_expect_success 'deltas supported' '
670 reinit_git &&
671 {
672 # (old) h + (inline) ello + (old) \n
673 printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
674 q_to_nul
675 } >delta &&
676 {
677 properties \
678 svn:author author@example.com \
679 svn:date "1999-01-05T00:01:002.000000Z" \
680 svn:log "add greeting" &&
681 echo PROPS-END
682 } >props &&
683 {
684 properties \
685 svn:author author@example.com \
686 svn:date "1999-01-06T00:01:002.000000Z" \
687 svn:log "change it" &&
688 echo PROPS-END
689 } >props2 &&
690 {
691 echo SVN-fs-dump-format-version: 3 &&
692 echo &&
693 echo Revision-number: 1 &&
694 echo Prop-content-length: $(wc -c <props) &&
695 echo Content-length: $(wc -c <props) &&
696 echo &&
697 cat props &&
698 cat <<-\EOF &&
699
700 Node-path: hello
701 Node-kind: file
702 Node-action: add
703 Prop-content-length: 10
704 Text-content-length: 3
705 Content-length: 13
706
707 PROPS-END
708 hi
709
710 EOF
711 echo Revision-number: 2 &&
712 echo Prop-content-length: $(wc -c <props2) &&
713 echo Content-length: $(wc -c <props2) &&
714 echo &&
715 cat props2 &&
716 cat <<-\EOF &&
717
718 Node-path: hello
719 Node-kind: file
720 Node-action: change
721 Text-delta: true
722 Prop-content-length: 10
723 EOF
724 echo Text-content-length: $(wc -c <delta) &&
725 echo Content-length: $((10 + $(wc -c <delta))) &&
726 echo &&
727 echo PROPS-END &&
728 cat delta
729 } >delta.dump &&
730 try_dump delta.dump
731 '
732
733 test_expect_success 'property deltas supported' '
734 reinit_git &&
735 cat >expect <<-\EOF &&
736 OBJID
737 :100755 100644 OBJID OBJID M script.sh
738 EOF
739 {
740 properties \
741 svn:author author@example.com \
742 svn:date "1999-03-06T00:01:002.000000Z" \
743 svn:log "make an executable, or chmod -x it" &&
744 echo PROPS-END
745 } >revprops &&
746 {
747 echo SVN-fs-dump-format-version: 3 &&
748 echo &&
749 echo Revision-number: 1 &&
750 echo Prop-content-length: $(wc -c <revprops) &&
751 echo Content-length: $(wc -c <revprops) &&
752 echo &&
753 cat revprops &&
754 echo &&
755 cat <<-\EOF &&
756 Node-path: script.sh
757 Node-kind: file
758 Node-action: add
759 Text-content-length: 0
760 Prop-content-length: 39
761 Content-length: 39
762
763 K 14
764 svn:executable
765 V 4
766 true
767 PROPS-END
768
769 EOF
770 echo Revision-number: 2 &&
771 echo Prop-content-length: $(wc -c <revprops) &&
772 echo Content-length: $(wc -c <revprops) &&
773 echo &&
774 cat revprops &&
775 echo &&
776 cat <<-\EOF
777 Node-path: script.sh
778 Node-kind: file
779 Node-action: change
780 Prop-delta: true
781 Prop-content-length: 30
782 Content-length: 30
783
784 D 14
785 svn:executable
786 PROPS-END
787 EOF
788 } >propdelta.dump &&
789 try_dump propdelta.dump &&
790 {
791 git rev-list HEAD |
792 git diff-tree --stdin |
793 sed "s/$OID_REGEX/OBJID/g"
794 } >actual &&
795 test_cmp expect actual
796 '
797
798 test_expect_success 'properties on /' '
799 reinit_git &&
800 cat <<-\EOF >expect &&
801 OBJID
802 OBJID
803 :000000 100644 OBJID OBJID A greeting
804 EOF
805 sed -e "s/X$//" <<-\EOF >changeroot.dump &&
806 SVN-fs-dump-format-version: 3
807
808 Revision-number: 1
809 Prop-content-length: 10
810 Content-length: 10
811
812 PROPS-END
813
814 Node-path: greeting
815 Node-kind: file
816 Node-action: add
817 Text-content-length: 0
818 Prop-content-length: 10
819 Content-length: 10
820
821 PROPS-END
822
823 Revision-number: 2
824 Prop-content-length: 10
825 Content-length: 10
826
827 PROPS-END
828
829 Node-path: X
830 Node-kind: dir
831 Node-action: change
832 Prop-delta: true
833 Prop-content-length: 43
834 Content-length: 43
835
836 K 10
837 svn:ignore
838 V 11
839 build-area
840
841 PROPS-END
842 EOF
843 try_dump changeroot.dump &&
844 {
845 git rev-list HEAD |
846 git diff-tree --root --always --stdin |
847 sed "s/$OID_REGEX/OBJID/g"
848 } >actual &&
849 test_cmp expect actual
850 '
851
852 test_expect_success 'deltas for typechange' '
853 reinit_git &&
854 cat >expect <<-\EOF &&
855 OBJID
856 :120000 100644 OBJID OBJID T test-file
857 OBJID
858 :100755 120000 OBJID OBJID T test-file
859 OBJID
860 :000000 100755 OBJID OBJID A test-file
861 EOF
862 cat >deleteprop.dump <<-\EOF &&
863 SVN-fs-dump-format-version: 3
864
865 Revision-number: 1
866 Prop-content-length: 10
867 Content-length: 10
868
869 PROPS-END
870
871 Node-path: test-file
872 Node-kind: file
873 Node-action: add
874 Prop-delta: true
875 Prop-content-length: 35
876 Text-content-length: 17
877 Content-length: 52
878
879 K 14
880 svn:executable
881 V 0
882
883 PROPS-END
884 link testing 123
885
886 Revision-number: 2
887 Prop-content-length: 10
888 Content-length: 10
889
890 PROPS-END
891
892 Node-path: test-file
893 Node-kind: file
894 Node-action: change
895 Prop-delta: true
896 Prop-content-length: 53
897 Text-content-length: 17
898 Content-length: 70
899
900 K 11
901 svn:special
902 V 1
903 *
904 D 14
905 svn:executable
906 PROPS-END
907 link testing 231
908
909 Revision-number: 3
910 Prop-content-length: 10
911 Content-length: 10
912
913 PROPS-END
914
915 Node-path: test-file
916 Node-kind: file
917 Node-action: change
918 Prop-delta: true
919 Prop-content-length: 27
920 Text-content-length: 17
921 Content-length: 44
922
923 D 11
924 svn:special
925 PROPS-END
926 link testing 321
927 EOF
928 try_dump deleteprop.dump &&
929 {
930 git rev-list HEAD |
931 git diff-tree --root --stdin |
932 sed "s/$OID_REGEX/OBJID/g"
933 } >actual &&
934 test_cmp expect actual
935 '
936
937 test_expect_success 'deltas need not consume the whole preimage' '
938 reinit_git &&
939 cat >expect <<-\EOF &&
940 OBJID
941 :120000 100644 OBJID OBJID T postimage
942 OBJID
943 :100644 120000 OBJID OBJID T postimage
944 OBJID
945 :000000 100644 OBJID OBJID A postimage
946 EOF
947 echo "first preimage" >expect.1 &&
948 printf target >expect.2 &&
949 printf lnk >expect.3 &&
950 {
951 printf "SVNQ%b%b%b" "QQ\017\001\017" "\0217" "first preimage\n" |
952 q_to_nul
953 } >delta.1 &&
954 {
955 properties svn:special "*" &&
956 echo PROPS-END
957 } >symlink.props &&
958 {
959 printf "SVNQ%b%b%b" "Q\002\013\004\012" "\0201\001\001\0211" "lnk target" |
960 q_to_nul
961 } >delta.2 &&
962 {
963 printf "SVNQ%b%b" "Q\004\003\004Q" "\001Q\002\002" |
964 q_to_nul
965 } >delta.3 &&
966 {
967 cat <<-\EOF &&
968 SVN-fs-dump-format-version: 3
969
970 Revision-number: 1
971 Prop-content-length: 10
972 Content-length: 10
973
974 PROPS-END
975
976 Node-path: postimage
977 Node-kind: file
978 Node-action: add
979 Text-delta: true
980 Prop-content-length: 10
981 EOF
982 echo Text-content-length: $(wc -c <delta.1) &&
983 echo Content-length: $((10 + $(wc -c <delta.1))) &&
984 echo &&
985 echo PROPS-END &&
986 cat delta.1 &&
987 cat <<-\EOF &&
988
989 Revision-number: 2
990 Prop-content-length: 10
991 Content-length: 10
992
993 PROPS-END
994
995 Node-path: postimage
996 Node-kind: file
997 Node-action: change
998 Text-delta: true
999 EOF
1000 echo Prop-content-length: $(wc -c <symlink.props) &&
1001 echo Text-content-length: $(wc -c <delta.2) &&
1002 echo Content-length: $(($(wc -c <symlink.props) + $(wc -c <delta.2))) &&
1003 echo &&
1004 cat symlink.props &&
1005 cat delta.2 &&
1006 cat <<-\EOF &&
1007
1008 Revision-number: 3
1009 Prop-content-length: 10
1010 Content-length: 10
1011
1012 PROPS-END
1013
1014 Node-path: postimage
1015 Node-kind: file
1016 Node-action: change
1017 Text-delta: true
1018 Prop-content-length: 10
1019 EOF
1020 echo Text-content-length: $(wc -c <delta.3) &&
1021 echo Content-length: $((10 + $(wc -c <delta.3))) &&
1022 echo &&
1023 echo PROPS-END &&
1024 cat delta.3 &&
1025 echo
1026 } >deltapartial.dump &&
1027 try_dump deltapartial.dump &&
1028 {
1029 git rev-list HEAD |
1030 git diff-tree --root --stdin |
1031 sed "s/$OID_REGEX/OBJID/g"
1032 } >actual &&
1033 test_cmp expect actual &&
1034 git show HEAD:postimage >actual.3 &&
1035 git show HEAD^:postimage >actual.2 &&
1036 git show HEAD^^:postimage >actual.1 &&
1037 test_cmp expect.1 actual.1 &&
1038 test_cmp expect.2 actual.2 &&
1039 test_cmp expect.3 actual.3
1040 '
1041
1042 test_expect_success 'no hang for delta trying to read past end of preimage' '
1043 reinit_git &&
1044 {
1045 # COPY 1
1046 printf "SVNQ%b%b" "Q\001\001\002Q" "\001Q" |
1047 q_to_nul
1048 } >greedy.delta &&
1049 {
1050 cat <<-\EOF &&
1051 SVN-fs-dump-format-version: 3
1052
1053 Revision-number: 1
1054 Prop-content-length: 10
1055 Content-length: 10
1056
1057 PROPS-END
1058
1059 Node-path: bootstrap
1060 Node-kind: file
1061 Node-action: add
1062 Text-delta: true
1063 Prop-content-length: 10
1064 EOF
1065 echo Text-content-length: $(wc -c <greedy.delta) &&
1066 echo Content-length: $((10 + $(wc -c <greedy.delta))) &&
1067 echo &&
1068 echo PROPS-END &&
1069 cat greedy.delta &&
1070 echo
1071 } >greedydelta.dump &&
1072 try_dump greedydelta.dump must_fail might_fail
1073 '
1074
1075 test_expect_success 'set up svn repo' '
1076 svnconf=$PWD/svnconf &&
1077 mkdir -p "$svnconf" &&
1078
1079 if
1080 svnadmin -h >/dev/null 2>&1 &&
1081 svnadmin create simple-svn &&
1082 svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
1083 svn export --config-dir "$svnconf" "file://$PWD/simple-svn" simple-svnco
1084 then
1085 test_set_prereq SVNREPO
1086 fi
1087 '
1088
1089 test_expect_success SVNREPO 't9135/svn.dump' '
1090 mkdir -p simple-git &&
1091 (
1092 cd simple-git &&
1093 reinit_git &&
1094 try_dump "$TEST_DIRECTORY/t9135/svn.dump"
1095 ) &&
1096 (
1097 cd simple-svnco &&
1098 git init &&
1099 git add . &&
1100 git fetch ../simple-git master &&
1101 git diff --exit-code FETCH_HEAD
1102 )
1103 '
1104
1105 test_done