3 test_description
='check svn dumpfile importer'
17 printf "%s\n" "K ${#property}" &&
18 printf "%s\n" "$property" &&
19 printf "%s\n" "V ${#value}" &&
20 printf "%s\n" "$value" &&
29 printf "%s\n" "Prop-content-length: 10" &&
30 printf "%s\n" "Text-content-length: ${#text}" &&
31 printf "%s\n" "Content-length: $((${#text} + 10))" &&
32 printf "%s\n" "" "PROPS-END" &&
38 test_expect_success
'empty dump' '
40 echo "SVN-fs-dump-format-version: 2" >input &&
41 test-svn-fe input >stream &&
42 git fast-import <stream
45 test_expect_success
'v4 dumps not supported' '
47 echo "SVN-fs-dump-format-version: 4" >v4.dump &&
48 test_must_fail test-svn-fe v4.dump >stream &&
52 test_expect_failure
'empty revision' '
54 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
55 cat >emptyrev.dump <<-\EOF &&
56 SVN-fs-dump-format-version: 3
59 Prop-content-length: 0
63 Prop-content-length: 0
67 test-svn-fe emptyrev.dump >stream &&
68 git fast-import <stream &&
69 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
70 test_cmp expect actual
73 test_expect_success
'empty properties' '
75 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
76 cat >emptyprop.dump <<-\EOF &&
77 SVN-fs-dump-format-version: 3
80 Prop-content-length: 10
86 Prop-content-length: 10
91 test-svn-fe emptyprop.dump >stream &&
92 git fast-import <stream &&
93 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
94 test_cmp expect actual
97 test_expect_success
'author name and commit message' '
99 echo "<author@example.com, author@example.com@local>" >expect.author &&
100 cat >message <<-\EOF &&
101 A concise summary of the change
103 A detailed description of the change, why it is needed, what
104 was broken and why applying this is the best course of action.
107 Details pertaining to an individual file.
111 svn:author author@example.com \
112 svn:log "$(cat message)" &&
116 echo "SVN-fs-dump-format-version: 3" &&
118 echo "Revision-number: 1" &&
119 echo Prop-content-length: $(wc -c <props) &&
120 echo Content-length: $(wc -c <props) &&
124 test-svn-fe log.dump >stream &&
125 git fast-import <stream &&
126 git log -p --format="%B" HEAD >actual.log &&
127 git log --format="<%an, %ae>" >actual.author &&
128 test_cmp message actual.log &&
129 test_cmp expect.author actual.author
132 test_expect_success
'unsupported properties are ignored' '
134 echo author >expect &&
135 cat >extraprop.dump <<-\EOF &&
136 SVN-fs-dump-format-version: 3
139 Prop-content-length: 56
152 test-svn-fe extraprop.dump >stream &&
153 git fast-import <stream &&
154 git log -p --format=%an HEAD >actual &&
155 test_cmp expect actual
158 test_expect_failure
'timestamp and empty file' '
159 echo author@example.com >expect.author &&
160 echo 1999-01-01 >expect.date &&
161 echo file >expect.files &&
165 svn:author author@example.com \
166 svn:date "1999-01-01T00:01:002.000000Z" \
167 svn:log "add empty file" &&
172 SVN-fs-dump-format-version: 3
176 echo Prop-content-length: $(wc -c <props) &&
177 echo Content-length: $(wc -c <props) &&
182 Node-path: empty-file
189 test-svn-fe emptyfile.dump >stream &&
190 git fast-import <stream &&
191 git log --format=%an HEAD >actual.author &&
192 git log --date=short --format=%ad HEAD >actual.date &&
193 git ls-tree -r --name-only HEAD >actual.files &&
194 test_cmp expect.author actual.author &&
195 test_cmp expect.date actual.date &&
196 test_cmp expect.files actual.files &&
197 git checkout HEAD empty-file &&
201 test_expect_success
'directory with files' '
203 printf "%s\n" directory/file1 directory/file2 >expect.files &&
208 svn:author author@example.com \
209 svn:date "1999-02-01T00:01:002.000000Z" \
210 svn:log "add directory with some files in it" &&
215 SVN-fs-dump-format-version: 3
219 echo Prop-content-length: $(wc -c <props) &&
220 echo Content-length: $(wc -c <props) &&
228 Prop-content-length: 10
233 Node-path: directory/file1
237 text_no_props hello &&
239 Node-path: directory/file2
245 test-svn-fe directory.dump >stream &&
246 git fast-import <stream &&
248 git ls-tree -r --name-only HEAD >actual.files &&
249 git checkout HEAD directory &&
250 test_cmp expect.files actual.files &&
251 test_cmp hello directory/file1 &&
252 test_cmp hi directory/file2
255 test_expect_success
'node without action' '
256 cat >inaction.dump <<-\EOF &&
257 SVN-fs-dump-format-version: 3
260 Prop-content-length: 10
267 Prop-content-length: 10
272 test_must_fail test-svn-fe inaction.dump
275 test_expect_success
'action: add node without text' '
276 cat >textless.dump <<-\EOF &&
277 SVN-fs-dump-format-version: 3
280 Prop-content-length: 10
288 Prop-content-length: 10
293 test_must_fail test-svn-fe textless.dump
296 test_expect_failure
'change file mode but keep old content' '
298 cat >expect <<-\EOF &&
300 :120000 100644 OBJID OBJID T greeting
302 :100644 120000 OBJID OBJID T greeting
304 :000000 100644 OBJID OBJID A greeting
306 echo "link hello" >expect.blob &&
308 cat >filemode.dump <<-\EOF &&
309 SVN-fs-dump-format-version: 3
312 Prop-content-length: 10
320 Prop-content-length: 10
321 Text-content-length: 11
328 Prop-content-length: 10
336 Prop-content-length: 33
346 Prop-content-length: 10
354 Prop-content-length: 10
359 test-svn-fe filemode.dump >stream &&
360 git fast-import <stream &&
363 git diff-tree --root --stdin |
364 sed "s/$_x40/OBJID/g"
366 git show HEAD:greeting >actual.blob &&
367 git show HEAD^:greeting >actual.target &&
368 test_cmp expect actual &&
369 test_cmp expect.blob actual.blob &&
370 test_cmp hello actual.target
373 test_expect_success
'NUL in property value' '
375 echo "commit message" >expect.message &&
378 unimportant "something with a NUL (Q)" \
379 svn:log "commit message"&&
385 SVN-fs-dump-format-version: 3
389 echo Prop-content-length: $(wc -c <props) &&
390 echo Content-length: $(wc -c <props) &&
394 test-svn-fe nulprop.dump >stream &&
395 git fast-import <stream &&
396 git diff-tree --always -s --format=%s HEAD >actual.message &&
397 test_cmp expect.message actual.message
400 test_expect_success
'NUL in log message, file content, and property name' '
401 # Caveat: svnadmin 1.6.16 (r1073529) truncates at \0 in the
402 # svn:specialQnotreally example.
404 cat >expect <<-\EOF &&
406 :100644 100644 OBJID OBJID M greeting
408 :000000 100644 OBJID OBJID A greeting
410 printf "\n%s" "something with an ASCII NUL (Q)" >expect.message &&
411 printf "%s\n" "helQo" >expect.hello1 &&
412 printf "%s\n" "link hello" >expect.hello2 &&
414 properties svn:log "something with an ASCII NUL (Q)" &&
420 SVN-fs-dump-format-version: 3
423 Prop-content-length: 10
431 Prop-content-length: 10
432 Text-content-length: 6
440 echo Prop-content-length: $(wc -c <props) &&
441 echo Content-length: $(wc -c <props) &&
449 Prop-content-length: 43
450 Text-content-length: 11
454 svn:specialQnotreally
461 test-svn-fe 8bitclean.dump >stream &&
462 git fast-import <stream &&
465 git diff-tree --root --stdin |
466 sed "s/$_x40/OBJID/g"
468 git cat-file commit HEAD | nul_to_q | sed -ne "/^\$/,\$ p" >actual.message &&
469 git cat-file blob HEAD^:greeting | nul_to_q >actual.hello1 &&
470 git cat-file blob HEAD:greeting | nul_to_q >actual.hello2 &&
471 test_cmp expect actual &&
472 test_cmp expect.message actual.message &&
473 test_cmp expect.hello1 actual.hello1 &&
474 test_cmp expect.hello2 actual.hello2
477 test_expect_success
'change file mode and reiterate content' '
479 cat >expect <<-\EOF &&
481 :120000 100644 OBJID OBJID T greeting
483 :100644 120000 OBJID OBJID T greeting
485 :000000 100644 OBJID OBJID A greeting
487 echo "link hello" >expect.blob &&
489 cat >filemode.dump <<-\EOF &&
490 SVN-fs-dump-format-version: 3
493 Prop-content-length: 10
501 Prop-content-length: 10
502 Text-content-length: 11
509 Prop-content-length: 10
517 Prop-content-length: 33
518 Text-content-length: 11
529 Prop-content-length: 10
537 Prop-content-length: 10
538 Text-content-length: 11
544 test-svn-fe filemode.dump >stream &&
545 git fast-import <stream &&
548 git diff-tree --root --stdin |
549 sed "s/$_x40/OBJID/g"
551 git show HEAD:greeting >actual.blob &&
552 git show HEAD^:greeting >actual.target &&
553 test_cmp expect actual &&
554 test_cmp expect.blob actual.blob &&
555 test_cmp hello actual.target
558 test_expect_success
'deltas not supported' '
560 # (old) h + (inline) ello + (old) \n
561 printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
566 svn:author author@example.com \
567 svn:date "1999-01-05T00:01:002.000000Z" \
568 svn:log "add greeting" &&
573 svn:author author@example.com \
574 svn:date "1999-01-06T00:01:002.000000Z" \
575 svn:log "change it" &&
579 echo SVN-fs-dump-format-version: 3 &&
581 echo Revision-number: 1 &&
582 echo Prop-content-length: $(wc -c <props) &&
583 echo Content-length: $(wc -c <props) &&
591 Prop-content-length: 10
592 Text-content-length: 3
599 echo Revision-number: 2 &&
600 echo Prop-content-length: $(wc -c <props2) &&
601 echo Content-length: $(wc -c <props2) &&
610 Prop-content-length: 10
612 echo Text-content-length: $(wc -c <delta) &&
613 echo Content-length: $((10 + $(wc -c <delta))) &&
618 test_must_fail test-svn-fe delta.dump
621 test_expect_success
'property deltas supported' '
623 cat >expect <<-\EOF &&
625 :100755 100644 OBJID OBJID M script.sh
629 svn:author author@example.com \
630 svn:date "1999-03-06T00:01:002.000000Z" \
631 svn:log "make an executable, or chmod -x it" &&
635 echo SVN-fs-dump-format-version: 3 &&
637 echo Revision-number: 1 &&
638 echo Prop-content-length: $(wc -c <revprops) &&
639 echo Content-length: $(wc -c <revprops) &&
647 Text-content-length: 0
648 Prop-content-length: 39
658 echo Revision-number: 2 &&
659 echo Prop-content-length: $(wc -c <revprops) &&
660 echo Content-length: $(wc -c <revprops) &&
669 Prop-content-length: 30
677 test-svn-fe propdelta.dump >stream &&
678 git fast-import <stream &&
681 git diff-tree --stdin |
682 sed "s/$_x40/OBJID/g"
684 test_cmp expect actual
687 test_expect_success
'properties on /' '
689 cat <<-\EOF >expect &&
692 :000000 100644 OBJID OBJID A greeting
694 sed -e "s/X$//" <<-\EOF >changeroot.dump &&
695 SVN-fs-dump-format-version: 3
698 Prop-content-length: 10
706 Text-content-length: 0
707 Prop-content-length: 10
713 Prop-content-length: 10
722 Prop-content-length: 43
732 test-svn-fe changeroot.dump >stream &&
733 git fast-import <stream &&
736 git diff-tree --root --always --stdin |
737 sed "s/$_x40/OBJID/g"
739 test_cmp expect actual
742 test_expect_success
'deltas for typechange' '
744 cat >expect <<-\EOF &&
746 :120000 100644 OBJID OBJID T test-file
748 :100755 120000 OBJID OBJID T test-file
750 :000000 100755 OBJID OBJID A test-file
752 cat >deleteprop.dump <<-\EOF &&
753 SVN-fs-dump-format-version: 3
756 Prop-content-length: 10
765 Prop-content-length: 35
766 Text-content-length: 17
777 Prop-content-length: 10
786 Prop-content-length: 53
787 Text-content-length: 17
800 Prop-content-length: 10
809 Prop-content-length: 27
810 Text-content-length: 17
818 test-svn-fe deleteprop.dump >stream &&
819 git fast-import <stream &&
822 git diff-tree --root --stdin |
823 sed "s/$_x40/OBJID/g"
825 test_cmp expect actual
829 test_expect_success
'set up svn repo' '
830 svnconf=$PWD/svnconf &&
831 mkdir -p "$svnconf" &&
834 svnadmin -h >/dev/null 2>&1 &&
835 svnadmin create simple-svn &&
836 svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
837 svn export --config-dir "$svnconf" "file://$PWD/simple-svn" simple-svnco
839 test_set_prereq SVNREPO
843 test_expect_success SVNREPO
't9135/svn.dump' '
844 git init simple-git &&
845 test-svn-fe "$TEST_DIRECTORY/t9135/svn.dump" >simple.fe &&
848 git fast-import <../simple.fe
854 git fetch ../simple-git master &&
855 git diff --exit-code FETCH_HEAD