Merge branch 'mg/maint-difftool-vim-readonly'
[gitweb.git] / vcs-svn / svndump.c
index 1669d0fa5e01d54150981c861920d7b6d122392d..ee7c0bb2ea869c66cdbab4f4f23a0d2207e6b27d 100644 (file)
@@ -30,6 +30,8 @@
 /* Create memory pool for log messages */
 obj_pool_gen(log, char, 4096)
 
+static struct line_buffer input = LINE_BUFFER_INIT;
+
 static char *log_copy(uint32_t length, const char *log)
 {
        char *buffer;
@@ -164,7 +166,7 @@ static void read_props(void)
         * symlink and executable bits separately instead.
         */
        uint32_t type_set = 0;
-       while ((t = buffer_read_line()) && strcmp(t, "PROPS-END")) {
+       while ((t = buffer_read_line(&input)) && strcmp(t, "PROPS-END")) {
                uint32_t len;
                const char *val;
                const char type = t[0];
@@ -172,8 +174,8 @@ static void read_props(void)
                if (!type || t[1] != ' ')
                        die("invalid property line: %s\n", t);
                len = atoi(&t[2]);
-               val = buffer_read_string(len);
-               buffer_skip_bytes(1);   /* Discard trailing newline. */
+               val = buffer_read_string(&input, len);
+               buffer_skip_bytes(&input, 1);   /* Discard trailing newline. */
 
                switch (type) {
                case 'K':
@@ -250,7 +252,8 @@ static void handle_node(void)
                        repo_modify_path(node_ctx.dst, node_ctx.type, mark);
        }
        if (mark)
-               fast_export_blob(node_ctx.type, mark, node_ctx.textLength);
+               fast_export_blob(node_ctx.type, mark,
+                                node_ctx.textLength, &input);
 }
 
 static void handle_revision(void)
@@ -269,7 +272,7 @@ void svndump_read(const char *url)
        uint32_t key;
 
        reset_dump_ctx(pool_intern(url));
-       while ((t = buffer_read_line())) {
+       while ((t = buffer_read_line(&input))) {
                val = strstr(t, ": ");
                if (!val)
                        continue;
@@ -280,7 +283,7 @@ void svndump_read(const char *url)
                if (key == keys.svn_fs_dump_format_version) {
                        dump_ctx.version = atoi(val);
                        if (dump_ctx.version > 3)
-                               die("expected svn dump format version <= 3, found %d",
+                               die("expected svn dump format version <= 3, found %"PRIu32,
                                    dump_ctx.version);
                } else if (key == keys.uuid) {
                        dump_ctx.uuid = pool_intern(val);
@@ -330,7 +333,7 @@ void svndump_read(const char *url)
                        node_ctx.prop_delta = !strcmp(val, "true");
                } else if (key == keys.content_length) {
                        len = atoi(val);
-                       buffer_read_line();
+                       buffer_read_line(&input);
                        if (active_ctx == REV_CTX) {
                                read_props();
                        } else if (active_ctx == NODE_CTX) {
@@ -338,7 +341,7 @@ void svndump_read(const char *url)
                                active_ctx = REV_CTX;
                        } else {
                                fprintf(stderr, "Unexpected content length header: %"PRIu32"\n", len);
-                               buffer_skip_bytes(len);
+                               buffer_skip_bytes(&input, len);
                        }
                }
        }
@@ -350,7 +353,7 @@ void svndump_read(const char *url)
 
 int svndump_init(const char *filename)
 {
-       if (buffer_init(filename))
+       if (buffer_init(&input, filename))
                return error("cannot open %s: %s", filename, strerror(errno));
        repo_init();
        reset_dump_ctx(~0);
@@ -367,7 +370,7 @@ void svndump_deinit(void)
        reset_dump_ctx(~0);
        reset_rev_ctx(0);
        reset_node_ctx(NULL);
-       if (buffer_deinit())
+       if (buffer_deinit(&input))
                fprintf(stderr, "Input error\n");
        if (ferror(stdout))
                fprintf(stderr, "Output error\n");
@@ -376,7 +379,7 @@ void svndump_deinit(void)
 void svndump_reset(void)
 {
        log_reset();
-       buffer_reset();
+       buffer_reset(&input);
        repo_reset();
        reset_dump_ctx(~0);
        reset_rev_ctx(0);