X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=vcs-svn%2Fsvndump.c;h=bc792223b2638bce4196eb0dc6626beb32f48da4;hb=c51477229ee4c7846d40a447860b5bf94aa1103d;hp=ea5b128e4f205cd95694839ca9eb9b072333fa99;hpb=6fe519a91cc7131931ca50fedcdeb8e41453c892;p=git.git diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index ea5b128e4..bc792223b 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -13,6 +13,7 @@ #include "line_buffer.h" #include "string_pool.h" #include "strbuf.h" +#include "svndump.h" /* * Compare start of string to literal of equal length; @@ -83,7 +84,7 @@ static void reset_dump_ctx(const char *url) } static void handle_property(const struct strbuf *key_buf, - const char *val, uint32_t len, + struct strbuf *val, uint32_t *type_set) { const char *key = key_buf->buf; @@ -95,23 +96,23 @@ static void handle_property(const struct strbuf *key_buf, break; if (!val) die("invalid dump: unsets svn:log"); - strbuf_reset(&rev_ctx.log); - strbuf_add(&rev_ctx.log, val, len); + strbuf_swap(&rev_ctx.log, val); break; case sizeof("svn:author"): if (constcmp(key, "svn:author")) break; - strbuf_reset(&rev_ctx.author); - if (val) - strbuf_add(&rev_ctx.author, val, len); + if (!val) + strbuf_reset(&rev_ctx.author); + else + strbuf_swap(&rev_ctx.author, val); break; case sizeof("svn:date"): if (constcmp(key, "svn:date")) break; if (!val) die("invalid dump: unsets svn:date"); - if (parse_date_basic(val, &rev_ctx.timestamp, NULL)) - warning("invalid timestamp: %s", val); + if (parse_date_basic(val->buf, &rev_ctx.timestamp, NULL)) + warning("invalid timestamp: %s", val->buf); break; case sizeof("svn:executable"): case sizeof("svn:special"): @@ -147,6 +148,7 @@ static void die_short_read(void) static void read_props(void) { static struct strbuf key = STRBUF_INIT; + static struct strbuf val = STRBUF_INIT; const char *t; /* * NEEDSWORK: to support simple mode changes like @@ -163,15 +165,15 @@ static void read_props(void) uint32_t type_set = 0; while ((t = buffer_read_line(&input)) && strcmp(t, "PROPS-END")) { uint32_t len; - const char *val; const char type = t[0]; int ch; if (!type || t[1] != ' ') die("invalid property line: %s\n", t); len = atoi(&t[2]); - val = buffer_read_string(&input, len); - if (!val || strlen(val) != len) + strbuf_reset(&val); + buffer_read_binary(&input, &val, len); + if (val.len < len) die_short_read(); /* Discard trailing newline. */ @@ -179,22 +181,17 @@ static void read_props(void) if (ch == EOF) die_short_read(); if (ch != '\n') - die("invalid dump: expected newline after %s", val); + die("invalid dump: expected newline after %s", val.buf); switch (type) { case 'K': + strbuf_swap(&key, &val); + continue; case 'D': - strbuf_reset(&key); - if (val) - strbuf_add(&key, val, len); - if (type == 'K') - continue; - assert(type == 'D'); - val = NULL; - len = 0; - /* fall through */ + handle_property(&val, NULL, &type_set); + continue; case 'V': - handle_property(&key, val, len, &type_set); + handle_property(&key, &val, &type_set); strbuf_reset(&key); continue; default: @@ -218,7 +215,8 @@ static void handle_node(void) if (have_text || have_props || node_ctx.srcRev) die("invalid dump: deletion node has " "copyfrom info, text, or properties"); - return repo_delete(node_ctx.dst); + repo_delete(node_ctx.dst); + return; } if (node_ctx.action == NODEACT_REPLACE) { repo_delete(node_ctx.dst); @@ -278,7 +276,7 @@ static void handle_revision(void) { if (rev_ctx.revision) repo_commit(rev_ctx.revision, rev_ctx.author.buf, - rev_ctx.log.buf, dump_ctx.uuid.buf, dump_ctx.url.buf, + &rev_ctx.log, dump_ctx.uuid.buf, dump_ctx.url.buf, rev_ctx.timestamp); }