Skip to content

Commit fd871b9

Browse files
flyingflogitster
authored andcommitted
Add svndump_init_fd to allow reading dumps from arbitrary FDs
The existing function only allows reading from a filename or from stdin. Allow passing of a FD and an additional FD for the back report pipe. This allows us to retrieve the name of the pipe in the caller. Signed-off-by: Florian Achleitner <[email protected]> Acked-by: David Michael Barr <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48ea9f9 commit fd871b9

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

vcs-svn/svndump.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,9 @@ void svndump_read(const char *url)
468468
end_revision();
469469
}
470470

471-
int svndump_init(const char *filename)
471+
static void init(int report_fd)
472472
{
473-
if (buffer_init(&input, filename))
474-
return error("cannot open %s: %s", filename, strerror(errno));
475-
fast_export_init(REPORT_FILENO);
473+
fast_export_init(report_fd);
476474
strbuf_init(&dump_ctx.uuid, 4096);
477475
strbuf_init(&dump_ctx.url, 4096);
478476
strbuf_init(&rev_ctx.log, 4096);
@@ -482,6 +480,22 @@ int svndump_init(const char *filename)
482480
reset_dump_ctx(NULL);
483481
reset_rev_ctx(0);
484482
reset_node_ctx(NULL);
483+
return;
484+
}
485+
486+
int svndump_init(const char *filename)
487+
{
488+
if (buffer_init(&input, filename))
489+
return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno));
490+
init(REPORT_FILENO);
491+
return 0;
492+
}
493+
494+
int svndump_init_fd(int in_fd, int back_fd)
495+
{
496+
if(buffer_fdinit(&input, xdup(in_fd)))
497+
return error("cannot open fd %d: %s", in_fd, strerror(errno));
498+
init(xdup(back_fd));
485499
return 0;
486500
}
487501

vcs-svn/svndump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define SVNDUMP_H_
33

44
int svndump_init(const char *filename);
5+
int svndump_init_fd(int in_fd, int back_fd);
56
void svndump_read(const char *url);
67
void svndump_deinit(void);
78
void svndump_reset(void);

0 commit comments

Comments
 (0)