vcs-svn: do not initialize report_buffer twice

When importing from a dump with deltas, first fast_export_init calls buffer_fdinit, and then init_report_buffer calls fdopen once again when processing the first delta. The second initialization is redundant and leaks a FILE *. Remove the redundant on-demand initialization to fix this. Initializing directly in fast_export_init is simpler and lets the caller pass an int specifying which fd to use instead of hard-coding REPORT_FILENO. Signed-off-by: Dmitry Ivankov <divanorama@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

Dmitry Ivankov committed Jun 20, 2011 at 14:22 UTC c5f1fbe7bc6b29f3343a168461ee70816ddebec2
1 file changed -12
vcs-svn/fast_export.c
-12
@@ -14,7 +14,6 @@
14 #include "line_buffer.h"
15
16 #define MAX_GITSVN_LINE_LEN 4096
17 -#define REPORT_FILENO 3
17
18 static uint32_t first_commit_done;
19 static struct line_buffer postimage = LINE_BUFFER_INIT;
@@ -30,15 +29,6 @@ static int init_postimage(void)
29 return buffer_tmpfile_init(&postimage);
30 }
31
33 -static int init_report_buffer(int fd)
34 -{
35 - static int report_buffer_initialized;
36 - if (report_buffer_initialized)
37 - return 0;
38 - report_buffer_initialized = 1;
39 - return buffer_fdinit(&report_buffer, fd);
40 -}
41 -
32 void fast_export_init(int fd)
33 {
34 if (buffer_fdinit(&report_buffer, fd))
@@ -203,8 +193,6 @@ static long apply_delta(off_t len, struct line_buffer *input,
193
194 if (init_postimage() || !(out = buffer_tmpfile_rewind(&postimage)))
195 die("cannot open temporary file for blob retrieval");
206 - if (init_report_buffer(REPORT_FILENO))
207 - die("cannot open fd 3 for feedback from fast-import");
196 if (old_data) {
197 const char *response;
198 printf("cat-blob %s\n", old_data);