blob: be5372ab3bee5220af03723ce6aedf518a5e7417 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
#!/bin/sh
test_description='check svn dumpfile importer'
. ./lib-git-svn.sh
reinit_git () {
rm -fr .git &&
git init
}
properties () {
while test "$#" -ne 0
do
property="$1" &&
value="$2" &&
printf "%s\n" "K ${#property}" &&
printf "%s\n" "$property" &&
printf "%s\n" "V ${#value}" &&
printf "%s\n" "$value" &&
shift 2 ||
return 1
done
}
text_no_props () {
text="$1
" &&
printf "%s\n" "Prop-content-length: 10" &&
printf "%s\n" "Text-content-length: ${#text}" &&
printf "%s\n" "Content-length: $((${#text} + 10))" &&
printf "%s\n" "" "PROPS-END" &&
printf "%s\n" "$text"
}
>empty
test_expect_success 'empty dump' '
reinit_git &&
echo "SVN-fs-dump-format-version: 2" >input &&
test-svn-fe input >stream &&
git fast-import <stream
'
test_expect_success 'v4 dumps not supported' '
reinit_git &&
echo "SVN-fs-dump-format-version: 4" >v4.dump &&
test_must_fail test-svn-fe v4.dump >stream &&
test_cmp empty stream
'
test_expect_failure 'empty revision' '
reinit_git &&
printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
cat >emptyrev.dump <<-\EOF &&
SVN-fs-dump-format-version: 3
Revision-number: 1
Prop-content-length: 0
Content-length: 0
Revision-number: 2
Prop-content-length: 0
Content-length: 0
EOF
test-svn-fe emptyrev.dump >stream &&
git fast-import <stream &&
git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
test_cmp expect actual
'
test_expect_success 'empty properties' '
reinit_git &&
printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
cat >emptyprop.dump <<-\EOF &&
SVN-fs-dump-format-version: 3
Revision-number: 1
Prop-content-length: 10
Content-length: 10
PROPS-END
Revision-number: 2
Prop-content-length: 10
Content-length: 10
PROPS-END
EOF
test-svn-fe emptyprop.dump >stream &&
git fast-import <stream &&
git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
test_cmp expect actual
'
test_expect_success 'author name and commit message' '
reinit_git &&
echo "<author@example.com, author@example.com@local>" >expect.author &&
cat >message <<-\EOF &&
A concise summary of the change
A detailed description of the change, why it is needed, what
was broken and why applying this is the best course of action.
* file.c
Details pertaining to an individual file.
EOF
{
properties \
svn:author author@example.com \
svn:log "$(cat message)" &&
echo PROPS-END
} >props &&
{
echo "SVN-fs-dump-format-version: 3" &&
echo &&
echo "Revision-number: 1" &&
echo Prop-content-length: $(wc -c <props) &&
echo Content-length: $(wc -c <props) &&
echo &&
cat props
} >log.dump &&
test-svn-fe log.dump >stream &&
git fast-import <stream &&
git log -p --format="%B" HEAD >actual.log &&
git log --format="<%an, %ae>" >actual.author &&
test_cmp message actual.log &&
test_cmp expect.author actual.author
'
test_expect_success 'unsupported properties are ignored' '
reinit_git &&
echo author >expect &&
cat >extraprop.dump <<-\EOF &&
SVN-fs-dump-format-version: 3
Revision-number: 1
Prop-content-length: 56
Content-length: 56
K 8
nonsense
V 1
y
K 10
svn:author
V 6
author
PROPS-END
EOF
test-svn-fe extraprop.dump >stream &&
git fast-import <stream &&
git log -p --format=%an HEAD >actual &&
test_cmp expect actual
'
test_expect_failure 'timestamp and empty file' '
echo author@example.com >expect.author &&
echo 1999-01-01 >expect.date &&
echo file >expect.files &&
reinit_git &&
{
properties \
svn:author author@example.com \
svn:date "1999-01-01T00:01:002.000000Z" \
svn:log "add empty file" &&
echo PROPS-END
} >props &&
{
cat <<-EOF &&
SVN-fs-dump-format-version: 3
Revision-number: 1
EOF
echo Prop-content-length: $(wc -c <props) &&
echo Content-length: $(wc -c <props) &&
echo &&
cat props &&
cat <<-\EOF
Node-path: empty-file
Node-kind: file
Node-action: add
Content-length: 0
EOF
} >emptyfile.dump &&
test-svn-fe emptyfile.dump >stream &&
git fast-import <stream &&
git log --format=%an HEAD >actual.author &&
git log --date=short --format=%ad HEAD >actual.date &&
git ls-tree -r --name-only HEAD >actual.files &&
test_cmp expect.author actual.author &&
test_cmp expect.date actual.date &&
test_cmp expect.files actual.files &&
git checkout HEAD empty-file &&
test_cmp empty file
'
test_expect_success 'directory with files' '
reinit_git &&
printf "%s\n" directory/file1 directory/file2 >expect.files &&
echo hi >hi &&
echo hello >hello &&
{
properties \
svn:author author@example.com \
svn:date "1999-02-01T00:01:002.000000Z" \
svn:log "add directory with some files in it" &&
echo PROPS-END
} >props &&
{
cat <<-EOF &&
SVN-fs-dump-format-version: 3
Revision-number: 1
EOF
echo Prop-content-length: $(wc -c <props) &&
echo Content-length: $(wc -c <props) &&
echo &&
cat props &&
cat <<-\EOF &&
Node-path: directory
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10
PROPS-END
Node-path: directory/file1
Node-kind: file
Node-action: add
EOF
text_no_props hello &&
cat <<-\EOF &&
Node-path: directory/file2
Node-kind: file
Node-action: add
EOF
text_no_props hi
} >directory.dump &&
test-svn-fe directory.dump >stream &&
git fast-import <stream &&
git ls-tree -r --name-only HEAD >actual.files &&
git checkout HEAD directory &&
test_cmp expect.files actual.files &&
test_cmp hello directory/file1 &&
test_cmp hi directory/file2
'
test_expect_success 'deltas not supported' '
{
# (old) h + (inline) ello + (old) \n
printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
q_to_nul
} >delta &&
{
properties \
svn:author author@example.com \
svn:date "1999-01-05T00:01:002.000000Z" \
svn:log "add greeting" &&
echo PROPS-END
} >props &&
{
properties \
svn:author author@example.com \
svn:date "1999-01-06T00:01:002.000000Z" \
svn:log "change it" &&
echo PROPS-END
} >props2 &&
{
echo SVN-fs-dump-format-version: 3 &&
echo &&
echo Revision-number: 1 &&
echo Prop-content-length: $(wc -c <props) &&
echo Content-length: $(wc -c <props) &&
echo &&
cat props &&
cat <<-\EOF &&
Node-path: hello
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 3
Content-length: 13
PROPS-END
hi
EOF
echo Revision-number: 2 &&
echo Prop-content-length: $(wc -c <props2) &&
echo Content-length: $(wc -c <props2) &&
echo &&
cat props2 &&
cat <<-\EOF &&
Node-path: hello
Node-kind: file
Node-action: change
Text-delta: true
Prop-content-length: 10
EOF
echo Text-content-length: $(wc -c <delta) &&
echo Content-length: $((10 + $(wc -c <delta))) &&
echo &&
echo PROPS-END &&
cat delta
} >delta.dump &&
test_must_fail test-svn-fe delta.dump
'
test_expect_success 'property deltas not supported' '
{
properties \
svn:author author@example.com \
svn:date "1999-03-06T00:01:002.000000Z" \
svn:log "make an executable, or chmod -x it" &&
echo PROPS-END
} >revprops &&
{
echo SVN-fs-dump-format-version: 3 &&
echo &&
echo Revision-number: 1 &&
echo Prop-content-length: $(wc -c <revprops) &&
echo Content-length: $(wc -c <revprops) &&
echo &&
cat revprops &&
echo &&
cat <<-\EOF &&
Node-path: script.sh
Node-kind: file
Node-action: add
Text-content-length: 0
Prop-content-length: 39
Content-length: 39
K 14
svn:executable
V 4
true
PROPS-END
EOF
echo Revision-number: 2 &&
echo Prop-content-length: $(wc -c <revprops) &&
echo Content-length: $(wc -c <revprops) &&
echo &&
cat revprops &&
echo &&
cat <<-\EOF
Node-path: script.sh
Node-kind: file
Node-action: change
Prop-delta: true
Prop-content-length: 30
Content-length: 30
D 14
svn:executable
PROPS-END
EOF
} >propdelta.dump &&
test_must_fail test-svn-fe propdelta.dump
'
test_expect_success 't9135/svn.dump' '
svnadmin create simple-svn &&
svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
svn_cmd export "file://$PWD/simple-svn" simple-svnco &&
git init simple-git &&
test-svn-fe "$TEST_DIRECTORY/t9135/svn.dump" >simple.fe &&
(
cd simple-git &&
git fast-import <../simple.fe
) &&
(
cd simple-svnco &&
git init &&
git add . &&
git fetch ../simple-git master &&
git diff --exit-code FETCH_HEAD
)
'
test_done
|