Skip to content

Commit e435811

Browse files
barrbrainjrn
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]>
1 parent 723b7a2 commit e435811

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed

t/t9010-svn-fe.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,105 @@ test_expect_success PIPE 'directory with files' '
270270
test_cmp hi directory/file2
271271
'
272272

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 [email protected] \
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 [email protected] \
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+
273372
test_expect_success PIPE 'node without action' '
274373
reinit_git &&
275374
cat >inaction.dump <<-\EOF &&

vcs-svn/fast_export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static void ls_from_active_commit(uint32_t depth, const uint32_t *path)
107107
{
108108
/* ls "path/to/file" */
109109
printf("ls \"");
110-
pool_print_seq(depth, path, '/', stdout);
110+
pool_print_seq_q(depth, path, '/', stdout);
111111
printf("\"\n");
112112
fflush(stdout);
113113
}

vcs-svn/string_pool.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "git-compat-util.h"
7+
#include "quote.h"
78
#include "trp.h"
89
#include "obj_pool.h"
910
#include "string_pool.h"
@@ -75,6 +76,16 @@ void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream)
7576
}
7677
}
7778

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+
7889
uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str)
7990
{
8091
char *context = NULL;

vcs-svn/string_pool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ uint32_t pool_intern(const char *key);
55
const char *pool_fetch(uint32_t entry);
66
uint32_t pool_tok_r(char *str, const char *delim, char **saveptr);
77
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);
89
uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str);
910
void pool_reset(void);
1011

0 commit comments

Comments
 (0)