3 test_description
='check svn dumpfile importer'
8 if ! test_declared_prereq PIPE
10 echo >&4 "reinit_git: need to declare PIPE prerequisite"
14 rm -f stream backflow
&&
16 mkfifo stream backflow
21 maybe_fail_svnfe
=${2:+test_$2} &&
22 maybe_fail_fi
=${3:+test_$3} &&
25 $maybe_fail_svnfe test-svn-fe
"$input" >stream
3<backflow
&
27 $maybe_fail_fi git fast-import
--cat-blob-fd=3 <stream
3>backflow
&&
36 printf "%s\n" "K ${#property}" &&
37 printf "%s\n" "$property" &&
38 printf "%s\n" "V ${#value}" &&
39 printf "%s\n" "$value" &&
48 printf "%s\n" "Prop-content-length: 10" &&
49 printf "%s\n" "Text-content-length: ${#text}" &&
50 printf "%s\n" "Content-length: $((${#text} + 10))" &&
51 printf "%s\n" "" "PROPS-END" &&
57 test_expect_success PIPE
'empty dump' '
59 echo "SVN-fs-dump-format-version: 2" >input &&
63 test_expect_success PIPE
'v4 dumps not supported' '
65 echo "SVN-fs-dump-format-version: 4" >v4.dump &&
66 try_dump v4.dump must_fail
69 test_expect_failure PIPE
'empty revision' '
71 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
72 cat >emptyrev.dump <<-\EOF &&
73 SVN-fs-dump-format-version: 3
76 Prop-content-length: 0
80 Prop-content-length: 0
84 try_dump emptyrev.dump &&
85 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
86 test_cmp expect actual
89 test_expect_success PIPE
'empty properties' '
91 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
92 cat >emptyprop.dump <<-\EOF &&
93 SVN-fs-dump-format-version: 3
96 Prop-content-length: 10
102 Prop-content-length: 10
107 try_dump emptyprop.dump &&
108 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
109 test_cmp expect actual
112 test_expect_success PIPE
'author name and commit message' '
114 echo "<author@example.com, author@example.com@local>" >expect.author &&
115 cat >message <<-\EOF &&
116 A concise summary of the change
118 A detailed description of the change, why it is needed, what
119 was broken and why applying this is the best course of action.
122 Details pertaining to an individual file.
126 svn:author author@example.com \
127 svn:log "$(cat message)" &&
131 echo "SVN-fs-dump-format-version: 3" &&
133 echo "Revision-number: 1" &&
134 echo Prop-content-length: $(wc -c <props) &&
135 echo Content-length: $(wc -c <props) &&
140 git log -p --format="%B" HEAD >actual.log &&
141 git log --format="<%an, %ae>" >actual.author &&
142 test_cmp message actual.log &&
143 test_cmp expect.author actual.author
146 test_expect_success PIPE
'unsupported properties are ignored' '
148 echo author >expect &&
149 cat >extraprop.dump <<-\EOF &&
150 SVN-fs-dump-format-version: 3
153 Prop-content-length: 56
166 try_dump extraprop.dump &&
167 git log -p --format=%an HEAD >actual &&
168 test_cmp expect actual
171 test_expect_failure PIPE
'timestamp and empty file' '
172 echo author@example.com >expect.author &&
173 echo 1999-01-01 >expect.date &&
174 echo file >expect.files &&
178 svn:author author@example.com \
179 svn:date "1999-01-01T00:01:002.000000Z" \
180 svn:log "add empty file" &&
185 SVN-fs-dump-format-version: 3
189 echo Prop-content-length: $(wc -c <props) &&
190 echo Content-length: $(wc -c <props) &&
195 Node-path: empty-file
202 try_dump emptyfile.dump &&
203 git log --format=%an HEAD >actual.author &&
204 git log --date=short --format=%ad HEAD >actual.date &&
205 git ls-tree -r --name-only HEAD >actual.files &&
206 test_cmp expect.author actual.author &&
207 test_cmp expect.date actual.date &&
208 test_cmp expect.files actual.files &&
209 git checkout HEAD empty-file &&
213 test_expect_success PIPE
'directory with files' '
215 printf "%s\n" directory/file1 directory/file2 >expect.files &&
220 svn:author author@example.com \
221 svn:date "1999-02-01T00:01:002.000000Z" \
222 svn:log "add directory with some files in it" &&
227 SVN-fs-dump-format-version: 3
231 echo Prop-content-length: $(wc -c <props) &&
232 echo Content-length: $(wc -c <props) &&
240 Prop-content-length: 10
245 Node-path: directory/file1
249 text_no_props hello &&
251 Node-path: directory/file2
257 try_dump directory.dump &&
259 git ls-tree -r --name-only HEAD >actual.files &&
260 git checkout HEAD directory &&
261 test_cmp expect.files actual.files &&
262 test_cmp hello directory/file1 &&
263 test_cmp hi directory/file2
266 test_expect_success PIPE
'branch name with backslash' '
268 sort <<-\EOF >expect.branch-files &&
271 "branches/UpdateFOPto094\\/file1"
272 "branches/UpdateFOPto094\\/file2"
279 svn:author author@example.com \
280 svn:date "1999-02-02T00:01:02.000000Z" \
281 svn:log "add directory with some files in it" &&
286 svn:author brancher@example.com \
287 svn:date "2007-12-06T21:38:34.000000Z" \
288 svn:log "Updating fop to .94 and adjust fo-stylesheets" &&
293 SVN-fs-dump-format-version: 3
297 echo Prop-content-length: $(wc -c <props.setup) &&
298 echo Content-length: $(wc -c <props.setup) &&
306 Prop-content-length: 10
314 Prop-content-length: 10
319 Node-path: trunk/file1
323 text_no_props hello &&
325 Node-path: trunk/file2
334 echo Prop-content-length: $(wc -c <props.branch) &&
335 echo Content-length: $(wc -c <props.branch) &&
340 Node-path: branches/UpdateFOPto094\
344 Node-copyfrom-path: trunk
348 Prop-content-length: 34
358 try_dump branch.dump &&
360 git ls-tree -r --name-only HEAD |
361 sort >actual.branch-files &&
362 test_cmp expect.branch-files actual.branch-files
365 test_expect_success PIPE
'node without action' '
367 cat >inaction.dump <<-\EOF &&
368 SVN-fs-dump-format-version: 3
371 Prop-content-length: 10
378 Prop-content-length: 10
383 try_dump inaction.dump must_fail
386 test_expect_success PIPE
'action: add node without text' '
388 cat >textless.dump <<-\EOF &&
389 SVN-fs-dump-format-version: 3
392 Prop-content-length: 10
400 Prop-content-length: 10
405 try_dump textless.dump must_fail
408 test_expect_failure PIPE
'change file mode but keep old content' '
410 cat >expect <<-\EOF &&
412 :120000 100644 OBJID OBJID T greeting
414 :100644 120000 OBJID OBJID T greeting
416 :000000 100644 OBJID OBJID A greeting
418 echo "link hello" >expect.blob &&
420 cat >filemode.dump <<-\EOF &&
421 SVN-fs-dump-format-version: 3
424 Prop-content-length: 10
432 Prop-content-length: 10
433 Text-content-length: 11
440 Prop-content-length: 10
448 Prop-content-length: 33
458 Prop-content-length: 10
466 Prop-content-length: 10
471 try_dump filemode.dump &&
474 git diff-tree --root --stdin |
475 sed "s/$_x40/OBJID/g"
477 git show HEAD:greeting >actual.blob &&
478 git show HEAD^:greeting >actual.target &&
479 test_cmp expect actual &&
480 test_cmp expect.blob actual.blob &&
481 test_cmp hello actual.target
484 test_expect_success PIPE
'NUL in property value' '
486 echo "commit message" >expect.message &&
489 unimportant "something with a NUL (Q)" \
490 svn:log "commit message"&&
496 SVN-fs-dump-format-version: 3
500 echo Prop-content-length: $(wc -c <props) &&
501 echo Content-length: $(wc -c <props) &&
505 try_dump nulprop.dump &&
506 git diff-tree --always -s --format=%s HEAD >actual.message &&
507 test_cmp expect.message actual.message
510 test_expect_success PIPE
'NUL in log message, file content, and property name' '
511 # Caveat: svnadmin 1.6.16 (r1073529) truncates at \0 in the
512 # svn:specialQnotreally example.
514 cat >expect <<-\EOF &&
516 :100644 100644 OBJID OBJID M greeting
518 :000000 100644 OBJID OBJID A greeting
520 printf "\n%s\n" "something with an ASCII NUL (Q)" >expect.message &&
521 printf "%s\n" "helQo" >expect.hello1 &&
522 printf "%s\n" "link hello" >expect.hello2 &&
524 properties svn:log "something with an ASCII NUL (Q)" &&
530 SVN-fs-dump-format-version: 3
533 Prop-content-length: 10
541 Prop-content-length: 10
542 Text-content-length: 6
550 echo Prop-content-length: $(wc -c <props) &&
551 echo Content-length: $(wc -c <props) &&
559 Prop-content-length: 43
560 Text-content-length: 11
564 svn:specialQnotreally
571 try_dump 8bitclean.dump &&
574 git diff-tree --root --stdin |
575 sed "s/$_x40/OBJID/g"
578 git cat-file commit HEAD | nul_to_q &&
581 sed -ne "/^\$/,\$ p" >actual.message &&
582 git cat-file blob HEAD^:greeting | nul_to_q >actual.hello1 &&
583 git cat-file blob HEAD:greeting | nul_to_q >actual.hello2 &&
584 test_cmp expect actual &&
585 test_cmp expect.message actual.message &&
586 test_cmp expect.hello1 actual.hello1 &&
587 test_cmp expect.hello2 actual.hello2
590 test_expect_success PIPE
'change file mode and reiterate content' '
592 cat >expect <<-\EOF &&
594 :120000 100644 OBJID OBJID T greeting
596 :100644 120000 OBJID OBJID T greeting
598 :000000 100644 OBJID OBJID A greeting
600 echo "link hello" >expect.blob &&
602 cat >filemode2.dump <<-\EOF &&
603 SVN-fs-dump-format-version: 3
606 Prop-content-length: 10
614 Prop-content-length: 10
615 Text-content-length: 11
622 Prop-content-length: 10
630 Prop-content-length: 33
631 Text-content-length: 11
642 Prop-content-length: 10
650 Prop-content-length: 10
651 Text-content-length: 11
657 try_dump filemode2.dump &&
660 git diff-tree --root --stdin |
661 sed "s/$_x40/OBJID/g"
663 git show HEAD:greeting >actual.blob &&
664 git show HEAD^:greeting >actual.target &&
665 test_cmp expect actual &&
666 test_cmp expect.blob actual.blob &&
667 test_cmp hello actual.target
670 test_expect_success PIPE
'deltas supported' '
673 # (old) h + (inline) ello + (old) \n
674 printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
679 svn:author author@example.com \
680 svn:date "1999-01-05T00:01:002.000000Z" \
681 svn:log "add greeting" &&
686 svn:author author@example.com \
687 svn:date "1999-01-06T00:01:002.000000Z" \
688 svn:log "change it" &&
692 echo SVN-fs-dump-format-version: 3 &&
694 echo Revision-number: 1 &&
695 echo Prop-content-length: $(wc -c <props) &&
696 echo Content-length: $(wc -c <props) &&
704 Prop-content-length: 10
705 Text-content-length: 3
712 echo Revision-number: 2 &&
713 echo Prop-content-length: $(wc -c <props2) &&
714 echo Content-length: $(wc -c <props2) &&
723 Prop-content-length: 10
725 echo Text-content-length: $(wc -c <delta) &&
726 echo Content-length: $((10 + $(wc -c <delta))) &&
734 test_expect_success PIPE
'property deltas supported' '
736 cat >expect <<-\EOF &&
738 :100755 100644 OBJID OBJID M script.sh
742 svn:author author@example.com \
743 svn:date "1999-03-06T00:01:002.000000Z" \
744 svn:log "make an executable, or chmod -x it" &&
748 echo SVN-fs-dump-format-version: 3 &&
750 echo Revision-number: 1 &&
751 echo Prop-content-length: $(wc -c <revprops) &&
752 echo Content-length: $(wc -c <revprops) &&
760 Text-content-length: 0
761 Prop-content-length: 39
771 echo Revision-number: 2 &&
772 echo Prop-content-length: $(wc -c <revprops) &&
773 echo Content-length: $(wc -c <revprops) &&
782 Prop-content-length: 30
790 try_dump propdelta.dump &&
793 git diff-tree --stdin |
794 sed "s/$_x40/OBJID/g"
796 test_cmp expect actual
799 test_expect_success PIPE
'properties on /' '
801 cat <<-\EOF >expect &&
804 :000000 100644 OBJID OBJID A greeting
806 sed -e "s/X$//" <<-\EOF >changeroot.dump &&
807 SVN-fs-dump-format-version: 3
810 Prop-content-length: 10
818 Text-content-length: 0
819 Prop-content-length: 10
825 Prop-content-length: 10
834 Prop-content-length: 43
844 try_dump changeroot.dump &&
847 git diff-tree --root --always --stdin |
848 sed "s/$_x40/OBJID/g"
850 test_cmp expect actual
853 test_expect_success PIPE
'deltas for typechange' '
855 cat >expect <<-\EOF &&
857 :120000 100644 OBJID OBJID T test-file
859 :100755 120000 OBJID OBJID T test-file
861 :000000 100755 OBJID OBJID A test-file
863 cat >deleteprop.dump <<-\EOF &&
864 SVN-fs-dump-format-version: 3
867 Prop-content-length: 10
876 Prop-content-length: 35
877 Text-content-length: 17
888 Prop-content-length: 10
897 Prop-content-length: 53
898 Text-content-length: 17
911 Prop-content-length: 10
920 Prop-content-length: 27
921 Text-content-length: 17
929 try_dump deleteprop.dump &&
932 git diff-tree --root --stdin |
933 sed "s/$_x40/OBJID/g"
935 test_cmp expect actual
938 test_expect_success PIPE
'deltas need not consume the whole preimage' '
940 cat >expect <<-\EOF &&
942 :120000 100644 OBJID OBJID T postimage
944 :100644 120000 OBJID OBJID T postimage
946 :000000 100644 OBJID OBJID A postimage
948 echo "first preimage" >expect.1 &&
949 printf target >expect.2 &&
950 printf lnk >expect.3 &&
952 printf "SVNQ%b%b%b" "QQ\017\001\017" "\0217" "first preimage\n" |
956 properties svn:special "*" &&
960 printf "SVNQ%b%b%b" "Q\002\013\004\012" "\0201\001\001\0211" "lnk target" |
964 printf "SVNQ%b%b" "Q\004\003\004Q" "\001Q\002\002" |
969 SVN-fs-dump-format-version: 3
972 Prop-content-length: 10
981 Prop-content-length: 10
983 echo Text-content-length: $(wc -c <delta.1) &&
984 echo Content-length: $((10 + $(wc -c <delta.1))) &&
991 Prop-content-length: 10
1001 echo Prop-content-length: $(wc -c <symlink.props) &&
1002 echo Text-content-length: $(wc -c <delta.2) &&
1003 echo Content-length: $(($(wc -c <symlink.props) + $(wc -c <delta.2))) &&
1005 cat symlink.props &&
1010 Prop-content-length: 10
1015 Node-path: postimage
1019 Prop-content-length: 10
1021 echo Text-content-length: $(wc -c <delta.3) &&
1022 echo Content-length: $((10 + $(wc -c <delta.3))) &&
1027 } >deltapartial.dump &&
1028 try_dump deltapartial.dump &&
1031 git diff-tree --root --stdin |
1032 sed "s/$_x40/OBJID/g"
1034 test_cmp expect actual &&
1035 git show HEAD:postimage >actual.3 &&
1036 git show HEAD^:postimage >actual.2 &&
1037 git show HEAD^^:postimage >actual.1 &&
1038 test_cmp expect.1 actual.1 &&
1039 test_cmp expect.2 actual.2 &&
1040 test_cmp expect.3 actual.3
1043 test_expect_success PIPE
'no hang for delta trying to read past end of preimage' '
1047 printf "SVNQ%b%b" "Q\001\001\002Q" "\001Q" |
1052 SVN-fs-dump-format-version: 3
1055 Prop-content-length: 10
1060 Node-path: bootstrap
1064 Prop-content-length: 10
1066 echo Text-content-length: $(wc -c <greedy.delta) &&
1067 echo Content-length: $((10 + $(wc -c <greedy.delta))) &&
1072 } >greedydelta.dump &&
1073 try_dump greedydelta.dump must_fail might_fail
1076 test_expect_success
'set up svn repo' '
1077 svnconf=$PWD/svnconf &&
1078 mkdir -p "$svnconf" &&
1081 svnadmin -h >/dev/null 2>&1 &&
1082 svnadmin create simple-svn &&
1083 svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
1084 svn export --config-dir "$svnconf" "file://$PWD/simple-svn" simple-svnco
1086 test_set_prereq SVNREPO
1090 test_expect_success SVNREPO
,PIPE
't9135/svn.dump' '
1091 mkdir -p simple-git &&
1095 try_dump "$TEST_DIRECTORY/t9135/svn.dump"
1101 git fetch ../simple-git master &&
1102 git diff --exit-code FETCH_HEAD