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=${2:+test_$2} &&
24 $maybe_fail test-svn-fe "$input" >stream 3<backflow &
26 git fast-import --cat-blob-fd=3 <stream 3>backflow &&
35 printf "%s\n" "K ${#property}" &&
36 printf "%s\n" "$property" &&
37 printf "%s\n" "V ${#value}" &&
38 printf "%s\n" "$value" &&
47 printf "%s\n" "Prop-content-length: 10" &&
48 printf "%s\n" "Text-content-length: ${#text}" &&
49 printf "%s\n" "Content-length: $((${#text} + 10))" &&
50 printf "%s\n" "" "PROPS-END" &&
56 test_expect_success 'setup: have pipes?' '
64 test_expect_success PIPE 'empty dump' '
66 echo "SVN-fs-dump-format-version: 2" >input &&
70 test_expect_success PIPE 'v4 dumps not supported' '
72 echo "SVN-fs-dump-format-version: 4" >v4.dump &&
73 try_dump v4.dump must_fail
76 test_expect_failure PIPE 'empty revision' '
78 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
79 cat >emptyrev.dump <<-\EOF &&
80 SVN-fs-dump-format-version: 3
83 Prop-content-length: 0
87 Prop-content-length: 0
91 try_dump emptyrev.dump &&
92 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
93 test_cmp expect actual
96 test_expect_success PIPE 'empty properties' '
98 printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
99 cat >emptyprop.dump <<-\EOF &&
100 SVN-fs-dump-format-version: 3
103 Prop-content-length: 10
109 Prop-content-length: 10
114 try_dump emptyprop.dump &&
115 git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
116 test_cmp expect actual
119 test_expect_success PIPE 'author name and commit message' '
121 echo "<author@example.com, author@example.com@local>" >expect.author &&
122 cat >message <<-\EOF &&
123 A concise summary of the change
125 A detailed description of the change, why it is needed, what
126 was broken and why applying this is the best course of action.
129 Details pertaining to an individual file.
133 svn:author author@example.com \
134 svn:log "$(cat message)" &&
138 echo "SVN-fs-dump-format-version: 3" &&
140 echo "Revision-number: 1" &&
141 echo Prop-content-length: $(wc -c <props) &&
142 echo Content-length: $(wc -c <props) &&
147 git log -p --format="%B" HEAD >actual.log &&
148 git log --format="<%an, %ae>" >actual.author &&
149 test_cmp message actual.log &&
150 test_cmp expect.author actual.author
153 test_expect_success PIPE 'unsupported properties are ignored' '
155 echo author >expect &&
156 cat >extraprop.dump <<-\EOF &&
157 SVN-fs-dump-format-version: 3
160 Prop-content-length: 56
173 try_dump extraprop.dump &&
174 git log -p --format=%an HEAD >actual &&
175 test_cmp expect actual
178 test_expect_failure PIPE 'timestamp and empty file' '
179 echo author@example.com >expect.author &&
180 echo 1999-01-01 >expect.date &&
181 echo file >expect.files &&
185 svn:author author@example.com \
186 svn:date "1999-01-01T00:01:002.000000Z" \
187 svn:log "add empty file" &&
192 SVN-fs-dump-format-version: 3
196 echo Prop-content-length: $(wc -c <props) &&
197 echo Content-length: $(wc -c <props) &&
202 Node-path: empty-file
209 try_dump emptyfile.dump &&
210 git log --format=%an HEAD >actual.author &&
211 git log --date=short --format=%ad HEAD >actual.date &&
212 git ls-tree -r --name-only HEAD >actual.files &&
213 test_cmp expect.author actual.author &&
214 test_cmp expect.date actual.date &&
215 test_cmp expect.files actual.files &&
216 git checkout HEAD empty-file &&
220 test_expect_success PIPE 'directory with files' '
222 printf "%s\n" directory/file1 directory/file2 >expect.files &&
227 svn:author author@example.com \
228 svn:date "1999-02-01T00:01:002.000000Z" \
229 svn:log "add directory with some files in it" &&
234 SVN-fs-dump-format-version: 3
238 echo Prop-content-length: $(wc -c <props) &&
239 echo Content-length: $(wc -c <props) &&
247 Prop-content-length: 10
252 Node-path: directory/file1
256 text_no_props hello &&
258 Node-path: directory/file2
264 try_dump directory.dump &&
266 git ls-tree -r --name-only HEAD >actual.files &&
267 git checkout HEAD directory &&
268 test_cmp expect.files actual.files &&
269 test_cmp hello directory/file1 &&
270 test_cmp hi directory/file2
273 test_expect_success PIPE 'node without action' '
275 cat >inaction.dump <<-\EOF &&
276 SVN-fs-dump-format-version: 3
279 Prop-content-length: 10
286 Prop-content-length: 10
291 try_dump inaction.dump must_fail
294 test_expect_success PIPE 'action: add node without text' '
296 cat >textless.dump <<-\EOF &&
297 SVN-fs-dump-format-version: 3
300 Prop-content-length: 10
308 Prop-content-length: 10
313 try_dump textless.dump must_fail
316 test_expect_failure PIPE 'change file mode but keep old content' '
318 cat >expect <<-\EOF &&
320 :120000 100644 OBJID OBJID T greeting
322 :100644 120000 OBJID OBJID T greeting
324 :000000 100644 OBJID OBJID A greeting
326 echo "link hello" >expect.blob &&
328 cat >filemode.dump <<-\EOF &&
329 SVN-fs-dump-format-version: 3
332 Prop-content-length: 10
340 Prop-content-length: 10
341 Text-content-length: 11
348 Prop-content-length: 10
356 Prop-content-length: 33
366 Prop-content-length: 10
374 Prop-content-length: 10
379 try_dump filemode.dump &&
382 git diff-tree --root --stdin |
383 sed "s/$_x40/OBJID/g"
385 git show HEAD:greeting >actual.blob &&
386 git show HEAD^:greeting >actual.target &&
387 test_cmp expect actual &&
388 test_cmp expect.blob actual.blob &&
389 test_cmp hello actual.target
392 test_expect_success PIPE 'change file mode and reiterate content' '
394 cat >expect <<-\EOF &&
396 :120000 100644 OBJID OBJID T greeting
398 :100644 120000 OBJID OBJID T greeting
400 :000000 100644 OBJID OBJID A greeting
402 echo "link hello" >expect.blob &&
404 cat >filemode2.dump <<-\EOF &&
405 SVN-fs-dump-format-version: 3
408 Prop-content-length: 10
416 Prop-content-length: 10
417 Text-content-length: 11
424 Prop-content-length: 10
432 Prop-content-length: 33
433 Text-content-length: 11
444 Prop-content-length: 10
452 Prop-content-length: 10
453 Text-content-length: 11
459 try_dump filemode2.dump &&
462 git diff-tree --root --stdin |
463 sed "s/$_x40/OBJID/g"
465 git show HEAD:greeting >actual.blob &&
466 git show HEAD^:greeting >actual.target &&
467 test_cmp expect actual &&
468 test_cmp expect.blob actual.blob &&
469 test_cmp hello actual.target
472 test_expect_success PIPE 'deltas not supported' '
475 # (old) h + (inline) ello + (old) \n
476 printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
481 svn:author author@example.com \
482 svn:date "1999-01-05T00:01:002.000000Z" \
483 svn:log "add greeting" &&
488 svn:author author@example.com \
489 svn:date "1999-01-06T00:01:002.000000Z" \
490 svn:log "change it" &&
494 echo SVN-fs-dump-format-version: 3 &&
496 echo Revision-number: 1 &&
497 echo Prop-content-length: $(wc -c <props) &&
498 echo Content-length: $(wc -c <props) &&
506 Prop-content-length: 10
507 Text-content-length: 3
514 echo Revision-number: 2 &&
515 echo Prop-content-length: $(wc -c <props2) &&
516 echo Content-length: $(wc -c <props2) &&
525 Prop-content-length: 10
527 echo Text-content-length: $(wc -c <delta) &&
528 echo Content-length: $((10 + $(wc -c <delta))) &&
533 test_must_fail try_dump delta.dump
536 test_expect_success PIPE 'property deltas supported' '
538 cat >expect <<-\EOF &&
540 :100755 100644 OBJID OBJID M script.sh
544 svn:author author@example.com \
545 svn:date "1999-03-06T00:01:002.000000Z" \
546 svn:log "make an executable, or chmod -x it" &&
550 echo SVN-fs-dump-format-version: 3 &&
552 echo Revision-number: 1 &&
553 echo Prop-content-length: $(wc -c <revprops) &&
554 echo Content-length: $(wc -c <revprops) &&
562 Text-content-length: 0
563 Prop-content-length: 39
573 echo Revision-number: 2 &&
574 echo Prop-content-length: $(wc -c <revprops) &&
575 echo Content-length: $(wc -c <revprops) &&
584 Prop-content-length: 30
592 try_dump propdelta.dump &&
595 git diff-tree --stdin |
596 sed "s/$_x40/OBJID/g"
598 test_cmp expect actual
601 test_expect_success PIPE 'properties on /' '
603 cat <<-\EOF >expect &&
606 :000000 100644 OBJID OBJID A greeting
608 sed -e "s/X$//" <<-\EOF >changeroot.dump &&
609 SVN-fs-dump-format-version: 3
612 Prop-content-length: 10
620 Text-content-length: 0
621 Prop-content-length: 10
627 Prop-content-length: 10
636 Prop-content-length: 43
646 try_dump changeroot.dump &&
649 git diff-tree --root --always --stdin |
650 sed "s/$_x40/OBJID/g"
652 test_cmp expect actual
655 test_expect_success PIPE 'deltas for typechange' '
657 cat >expect <<-\EOF &&
659 :120000 100644 OBJID OBJID T test-file
661 :100755 120000 OBJID OBJID T test-file
663 :000000 100755 OBJID OBJID A test-file
665 cat >deleteprop.dump <<-\EOF &&
666 SVN-fs-dump-format-version: 3
669 Prop-content-length: 10
678 Prop-content-length: 35
679 Text-content-length: 17
690 Prop-content-length: 10
699 Prop-content-length: 53
700 Text-content-length: 17
713 Prop-content-length: 10
722 Prop-content-length: 27
723 Text-content-length: 17
731 try_dump deleteprop.dump &&
734 git diff-tree --root --stdin |
735 sed "s/$_x40/OBJID/g"
737 test_cmp expect actual
741 test_expect_success 'set up svn repo' '
742 svnconf=$PWD/svnconf &&
743 mkdir -p "$svnconf" &&
746 svnadmin -h >/dev/null 2>&1 &&
747 svnadmin create simple-svn &&
748 svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
749 svn export --config-dir "$svnconf" "file://$PWD/simple-svn" simple-svnco
751 test_set_prereq SVNREPO
755 test_expect_success SVNREPO,PIPE 't9135/svn.dump' '
756 mkdir -p simple-git &&
760 try_dump "$TEST_DIRECTORY/t9135/svn.dump"
766 git fetch ../simple-git master &&
767 git diff --exit-code FETCH_HEAD