vcs-svn: quote paths correctly for ls command
This bug was found while importing rev 601865 of ASF. [jn: with test] Signed-off-by: David Barr <david.barr@cordelta.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
David Barr committed
Dec 12, 2010 at 03:59 UTC
e43581120843f6f55f411af470faf806e052ad9d
4 files changed
+112
-1
t/t9010-svn-fe.sh
+99
@@ -270,6 +270,105 @@ test_expect_success PIPE 'directory with files' '
270
test_cmp hi directory/file2
271
'
272
273
+test_expect_success PIPE 'branch name with backslash' '
274
+ reinit_git &&
275
+ sort <<-\EOF >expect.branch-files &&
276
+ trunk/file1
277
+ trunk/file2
278
+ "branches/UpdateFOPto094\\/file1"
279
+ "branches/UpdateFOPto094\\/file2"
280
+ EOF
281
+
282
+ echo hi >hi &&
283
+ echo hello >hello &&
284
+ {
285
+ properties \
286
+ svn:author author@example.com \
287
+ svn:date "1999-02-02T00:01:02.000000Z" \
288
+ svn:log "add directory with some files in it" &&
289
+ echo PROPS-END
290
+ } >props.setup &&
291
+ {
292
+ properties \
293
+ svn:author brancher@example.com \
294
+ svn:date "2007-12-06T21:38:34.000000Z" \
295
+ svn:log "Updating fop to .94 and adjust fo-stylesheets" &&
296
+ echo PROPS-END
297
+ } >props.branch &&
298
+ {
299
+ cat <<-EOF &&
300
+ SVN-fs-dump-format-version: 3
301
+
302
+ Revision-number: 1
303
+ EOF
304
+ echo Prop-content-length: $(wc -c <props.setup) &&
305
+ echo Content-length: $(wc -c <props.setup) &&
306
+ echo &&
307
+ cat props.setup &&
308
+ cat <<-\EOF &&
309
+
310
+ Node-path: trunk
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: branches
319
+ Node-kind: dir
320
+ Node-action: add
321
+ Prop-content-length: 10
322
+ Content-length: 10
323
+
324
+ PROPS-END
325
+
326
+ Node-path: trunk/file1
327
+ Node-kind: file
328
+ Node-action: add
329
+ EOF
330
+ text_no_props hello &&
331
+ cat <<-\EOF &&
332
+ Node-path: trunk/file2
333
+ Node-kind: file
334
+ Node-action: add
335
+ EOF
336
+ text_no_props hi &&
337
+ cat <<-\EOF &&
338
+
339
+ Revision-number: 2
340
+ EOF
341
+ echo Prop-content-length: $(wc -c <props.branch) &&
342
+ echo Content-length: $(wc -c <props.branch) &&
343
+ echo &&
344
+ cat props.branch &&
345
+ cat <<-\EOF
346
+
347
+ Node-path: branches/UpdateFOPto094\
348
+ Node-kind: dir
349
+ Node-action: add
350
+ Node-copyfrom-rev: 1
351
+ Node-copyfrom-path: trunk
352
+
353
+ Node-kind: dir
354
+ Node-action: add
355
+ Prop-content-length: 34
356
+ Content-length: 34
357
+
358
+ K 13
359
+ svn:mergeinfo
360
+ V 0
361
+
362
+ PROPS-END
363
+ EOF
364
+ } >branch.dump &&
365
+ try_dump branch.dump &&
366
+
367
+ git ls-tree -r --name-only HEAD |
368
+ sort >actual.branch-files &&
369
+ test_cmp expect.branch-files actual.branch-files
370
+'
371
+
372
test_expect_success PIPE 'node without action' '
373
reinit_git &&
374
cat >inaction.dump <<-\EOF &&
vcs-svn/fast_export.c
+1
-1
@@ -107,7 +107,7 @@ static void ls_from_active_commit(uint32_t depth, const uint32_t *path)
107
{
108
/* ls "path/to/file" */
109
printf("ls \"");
110
- pool_print_seq(depth, path, '/', stdout);
110
+ pool_print_seq_q(depth, path, '/', stdout);
111
printf("\"\n");
112
fflush(stdout);
113
}
vcs-svn/string_pool.c
+11
@@ -4,6 +4,7 @@
4
*/
5
6
#include "git-compat-util.h"
7
+#include "quote.h"
8
#include "trp.h"
9
#include "obj_pool.h"
10
#include "string_pool.h"
@@ -75,6 +76,16 @@ void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream)
76
}
77
}
78
79
+void pool_print_seq_q(uint32_t len, const uint32_t *seq, char delim, FILE *stream)
80
+{
81
+ uint32_t i;
82
+ for (i = 0; i < len && ~seq[i]; i++) {
83
+ quote_c_style(pool_fetch(seq[i]), NULL, stream, 1);
84
+ if (i < len - 1 && ~seq[i + 1])
85
+ fputc(delim, stream);
86
+ }
87
+}
88
+
89
uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str)
90
{
91
char *context = NULL;
vcs-svn/string_pool.h
+1
@@ -5,6 +5,7 @@ uint32_t pool_intern(const char *key);
5
const char *pool_fetch(uint32_t entry);
6
uint32_t pool_tok_r(char *str, const char *delim, char **saveptr);
7
void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream);
8
+void pool_print_seq_q(uint32_t len, const uint32_t *seq, char delim, FILE *stream);
9
uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str);
10
void pool_reset(void);
11