From: Jonathan Nieder Date: Thu, 26 May 2011 07:12:14 +0000 (-0500) Subject: Merge branch 'db/svn-fe-code-purge' into svn-fe X-Git-Tag: v1.7.12-rc0~41^2~13^2~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c19d653c4fcdc93169507c09f8f66ebffbdbb9a5?ds=inline;hp=-c Merge branch 'db/svn-fe-code-purge' into svn-fe * db/svn-fe-code-purge: vcs-svn: drop obj_pool vcs-svn: drop treap vcs-svn: drop string_pool vcs-svn: pass paths through to fast-import Conflicts: vcs-svn/fast_export.c vcs-svn/fast_export.h vcs-svn/repo_tree.c vcs-svn/repo_tree.h vcs-svn/string_pool.c vcs-svn/svndump.c vcs-svn/trp.txt --- c19d653c4fcdc93169507c09f8f66ebffbdbb9a5 diff --combined .gitignore index 2cf3ca5808,789f922c36..fa0c763774 --- a/.gitignore +++ b/.gitignore @@@ -43,6 -43,7 +43,6 @@@ /git-fast-export /git-fast-import /git-fetch -/git-fetch--tool /git-fetch-pack /git-filter-branch /git-fmt-merge-msg @@@ -106,6 -107,7 +106,6 @@@ /git-reflog /git-relink /git-remote -/git-remote-curl /git-remote-http /git-remote-https /git-remote-ftp @@@ -169,16 -171,13 +169,13 @@@ /test-line-buffer /test-match-trees /test-mktemp - /test-obj-pool /test-parse-options /test-path-utils /test-run-command /test-sha1 /test-sigchain - /test-string-pool /test-subprocess /test-svn-fe - /test-treap /common-cmds.h *.tar.gz *.dsc diff --combined Makefile index cbc3fce2d5,b802ae97b2..91e20d29c6 --- a/Makefile +++ b/Makefile @@@ -45,6 -45,11 +45,6 @@@ all: # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks # d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7). # -# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.) -# do not support the 'size specifiers' introduced by C99, namely ll, hh, -# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). -# some C compilers supported these specifiers prior to C99 as an extension. -# # Define NO_STRCASESTR if you don't have strcasestr. # # Define NO_MEMMEM if you don't have memmem. @@@ -211,11 -216,6 +211,11 @@@ # # Define NO_REGEX if you have no or inferior regex support in your C library. # +# Define GETTEXT_POISON if you are debugging the choice of strings marked +# for translation. In a GETTEXT_POISON build, you can turn all strings marked +# for translation into gibberish by setting the GIT_GETTEXT_POISON variable +# (to any value) in your environment. +# # Define JSMIN to point to JavaScript minifier that functions as # a filter to have gitweb.js minified. # @@@ -316,7 -316,6 +316,7 @@@ INSTALL = instal RPMBUILD = rpmbuild TCL_PATH = tclsh TCLTK_PATH = wish +XGETTEXT = xgettext PTHREAD_LIBS = -lpthread PTHREAD_CFLAGS = GCOV = gcov @@@ -425,16 -424,13 +425,13 @@@ TEST_PROGRAMS_NEED_X += test-dump-cache TEST_PROGRAMS_NEED_X += test-genrandom TEST_PROGRAMS_NEED_X += test-line-buffer TEST_PROGRAMS_NEED_X += test-match-trees - TEST_PROGRAMS_NEED_X += test-obj-pool TEST_PROGRAMS_NEED_X += test-parse-options TEST_PROGRAMS_NEED_X += test-path-utils TEST_PROGRAMS_NEED_X += test-run-command TEST_PROGRAMS_NEED_X += test-sha1 TEST_PROGRAMS_NEED_X += test-sigchain - TEST_PROGRAMS_NEED_X += test-string-pool TEST_PROGRAMS_NEED_X += test-subprocess TEST_PROGRAMS_NEED_X += test-svn-fe - TEST_PROGRAMS_NEED_X += test-treap TEST_PROGRAMS_NEED_X += test-index-version TEST_PROGRAMS_NEED_X += test-mktemp @@@ -516,7 -512,6 +513,7 @@@ LIB_H += diff. LIB_H += dir.h LIB_H += exec_cmd.h LIB_H += fsck.h +LIB_H += gettext.h LIB_H += git-compat-util.h LIB_H += graph.h LIB_H += grep.h @@@ -873,6 -868,7 +870,6 @@@ ifeq ($(uname_S),SunOS NO_UNSETENV = YesPlease NO_SETENV = YesPlease NO_STRLCPY = YesPlease - NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease GIT_TEST_CMP = cmp endif @@@ -883,18 -879,21 +880,18 @@@ NO_UNSETENV = YesPlease NO_SETENV = YesPlease NO_STRLCPY = YesPlease - NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease GIT_TEST_CMP = cmp endif ifeq ($(uname_R),5.8) NO_UNSETENV = YesPlease NO_SETENV = YesPlease - NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease GIT_TEST_CMP = cmp endif ifeq ($(uname_R),5.9) NO_UNSETENV = YesPlease NO_SETENV = YesPlease - NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease GIT_TEST_CMP = cmp endif @@@ -1040,7 -1039,6 +1037,7 @@@ ifeq ($(uname_S),HP-UX NO_UNSETENV = YesPlease NO_HSTRERROR = YesPlease NO_SYS_SELECT_H = YesPlease + NO_FNMATCH_CASEFOLD = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease NO_NSEC = YesPlease ifeq ($(uname_R),B.11.00) @@@ -1074,6 -1072,7 +1071,6 @@@ ifeq ($(uname_S),Windows NO_MEMMEM = YesPlease # NEEDS_LIBICONV = YesPlease NO_ICONV = YesPlease - NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease NO_STRTOULL = YesPlease NO_MKDTEMP = YesPlease @@@ -1150,6 -1149,7 +1147,6 @@@ ifneq (,$(findstring MINGW,$(uname_S)) NO_MEMMEM = YesPlease NEEDS_LIBICONV = YesPlease OLD_ICONV = YesPlease - NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease NO_MKDTEMP = YesPlease NO_MKSTEMPS = YesPlease @@@ -1352,6 -1352,9 +1349,6 @@@ endi ifdef NO_NSEC BASIC_CFLAGS += -DNO_NSEC endif -ifdef NO_C99_FORMAT - BASIC_CFLAGS += -DNO_C99_FORMAT -endif ifdef SNPRINTF_RETURNS_BOGUS COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS COMPAT_OBJS += compat/snprintf.o @@@ -1363,10 -1366,6 +1360,10 @@@ endi ifdef NO_SYMLINK_HEAD BASIC_CFLAGS += -DNO_SYMLINK_HEAD endif +ifdef GETTEXT_POISON + LIB_OBJS += gettext.o + BASIC_CFLAGS += -DGETTEXT_POISON +endif ifdef NO_STRCASESTR COMPAT_CFLAGS += -DNO_STRCASESTR COMPAT_OBJS += compat/strcasestr.o @@@ -1578,7 -1577,6 +1575,7 @@@ ifndef QUIET_BUILT_IN = @echo ' ' BUILTIN $@; QUIET_GEN = @echo ' ' GEN $@; QUIET_LNCP = @echo ' ' LN/CP $@; + QUIET_XGETTEXT = @echo ' ' XGETTEXT $@; QUIET_GCOV = @echo ' ' GCOV $@; QUIET_SUBDIR0 = +@subdir= QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ @@@ -1837,10 -1835,9 +1834,9 @@@ ifndef NO_CUR endif XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \ xdiff/xmerge.o xdiff/xpatience.o - VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \ - vcs-svn/repo_tree.o vcs-svn/fast_export.o vcs-svn/svndump.o - VCSSVN_TEST_OBJS = test-obj-pool.o test-string-pool.o \ - test-line-buffer.o test-treap.o + VCSSVN_OBJS = vcs-svn/line_buffer.o vcs-svn/repo_tree.o \ + vcs-svn/fast_export.o vcs-svn/svndump.o + VCSSVN_TEST_OBJS = test-line-buffer.o OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS) dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d) @@@ -1964,7 -1961,6 +1960,6 @@@ xdiff-interface.o $(XDIFF_OBJS): xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \ - vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h \ vcs-svn/line_buffer.h vcs-svn/repo_tree.h vcs-svn/fast_export.h \ vcs-svn/svndump.h @@@ -2046,21 -2042,6 +2041,21 @@@ info pdf: $(MAKE) -C Documentation pdf +XGETTEXT_FLAGS = \ + --force-po \ + --add-comments \ + --msgid-bugs-address="Git Mailing List " \ + --from-code=UTF-8 +XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \ + --keyword=_ --keyword=N_ --keyword="Q_:1,2" +LOCALIZED_C := $(C_OBJ:o=c) + +po/git.pot: $(LOCALIZED_C) + $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \ + mv $@+ $@ + +pot: po/git.pot + $(ETAGS_TARGET): FORCE $(RM) $(ETAGS_TARGET) $(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET) @@@ -2102,7 -2083,6 +2097,7 @@@ endi ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@ endif + @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@ ### Detect Tck/Tk interpreter path changes ifndef NO_TCLTK @@@ -2148,8 -2128,6 +2143,6 @@@ test-line-buffer$X: vcs-svn/lib. test-parse-options$X: parse-options.o - test-string-pool$X: vcs-svn/lib.a - test-svn-fe$X: vcs-svn/lib.a .PRECIOUS: $(TEST_OBJS) @@@ -2163,7 -2141,7 +2156,7 @@@ check-sha1:: test-sha1$ check: common-cmds.h if sparse; \ then \ - for i in *.c; \ + for i in $(patsubst %.o, %.c, $(GIT_OBJS)); \ do \ sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \ done; \ @@@ -2328,7 -2306,6 +2321,7 @@@ dist-doc distclean: clean $(RM) configure + $(RM) po/git.pot clean: $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \ diff --combined vcs-svn/fast_export.c index ff980b3a2a,ec323e9b39..33e853d9cd --- a/vcs-svn/fast_export.c +++ b/vcs-svn/fast_export.c @@@ -4,10 -4,11 +4,11 @@@ */ #include "git-compat-util.h" + #include "strbuf.h" + #include "quote.h" #include "fast_export.h" #include "line_buffer.h" #include "repo_tree.h" - #include "string_pool.h" #include "strbuf.h" #define MAX_GITSVN_LINE_LEN 4096 @@@ -32,41 -33,39 +33,41 @@@ void fast_export_reset(void buffer_reset(&report_buffer); } - void fast_export_delete(uint32_t depth, const uint32_t *path) + void fast_export_delete(const char *path) { - printf("D \""); - pool_print_seq_q(depth, path, '/', stdout); - printf("\"\n"); + putchar('D'); + putchar(' '); + quote_c_style(path, NULL, stdout, 0); + putchar('\n'); } - static void fast_export_truncate(uint32_t depth, const uint32_t *path, uint32_t mode) + static void fast_export_truncate(const char *path, uint32_t mode) { - fast_export_modify(depth, path, mode, "inline"); + fast_export_modify(path, mode, "inline"); printf("data 0\n\n"); } - void fast_export_modify(uint32_t depth, const uint32_t *path, uint32_t mode, - const char *dataref) + void fast_export_modify(const char *path, uint32_t mode, const char *dataref) { /* Mode must be 100644, 100755, 120000, or 160000. */ if (!dataref) { - fast_export_truncate(depth, path, mode); + fast_export_truncate(path, mode); return; } - printf("M %06"PRIo32" %s \"", mode, dataref); - pool_print_seq_q(depth, path, '/', stdout); - printf("\"\n"); + printf("M %06"PRIo32" %s ", mode, dataref); + quote_c_style(path, NULL, stdout, 0); + putchar('\n'); } static char gitsvnline[MAX_GITSVN_LINE_LEN]; -void fast_export_begin_commit(uint32_t revision, const char *author, char *log, +void fast_export_begin_commit(uint32_t revision, const char *author, + const struct strbuf *log, const char *uuid, const char *url, unsigned long timestamp) { + static const struct strbuf empty = STRBUF_INIT; if (!log) - log = ""; + log = ∅ if (*uuid && *url) { snprintf(gitsvnline, MAX_GITSVN_LINE_LEN, "\n\ngit-svn-id: %s@%"PRIu32" %s\n", @@@ -80,10 -79,9 +81,10 @@@ *author ? author : "nobody", *author ? author : "nobody", *uuid ? uuid : "local", timestamp); - printf("data %"PRIu32"\n%s%s\n", - (uint32_t) (strlen(log) + strlen(gitsvnline)), - log, gitsvnline); + printf("data %"PRIuMAX"\n", + (uintmax_t) (log->len + strlen(gitsvnline))); + fwrite(log->buf, log->len, 1, stdout); + printf("%s\n", gitsvnline); if (!first_commit_done) { if (revision > 1) printf("from :%"PRIu32"\n", revision - 1); @@@ -96,20 -94,20 +97,20 @@@ void fast_export_end_commit(uint32_t re printf("progress Imported commit %"PRIu32".\n\n", revision); } - static void ls_from_rev(uint32_t rev, uint32_t depth, const uint32_t *path) + static void ls_from_rev(uint32_t rev, const char *path) { /* ls :5 path/to/old/file */ - printf("ls :%"PRIu32" \"", rev); - pool_print_seq_q(depth, path, '/', stdout); - printf("\"\n"); + printf("ls :%"PRIu32" ", rev); + quote_c_style(path, NULL, stdout, 0); + putchar('\n'); fflush(stdout); } - static void ls_from_active_commit(uint32_t depth, const uint32_t *path) + static void ls_from_active_commit(const char *path) { /* ls "path/to/file" */ printf("ls \""); - pool_print_seq_q(depth, path, '/', stdout); + quote_c_style(path, NULL, stdout, 1); printf("\"\n"); fflush(stdout); } @@@ -186,16 -184,15 +187,15 @@@ static int parse_ls_response(const cha return 0; } - int fast_export_ls_rev(uint32_t rev, uint32_t depth, const uint32_t *path, + int fast_export_ls_rev(uint32_t rev, const char *path, uint32_t *mode, struct strbuf *dataref) { - ls_from_rev(rev, depth, path); + ls_from_rev(rev, path); return parse_ls_response(get_response_line(), mode, dataref); } - int fast_export_ls(uint32_t depth, const uint32_t *path, - uint32_t *mode, struct strbuf *dataref) + int fast_export_ls(const char *path, uint32_t *mode, struct strbuf *dataref) { - ls_from_active_commit(depth, path); + ls_from_active_commit(path); return parse_ls_response(get_response_line(), mode, dataref); } diff --combined vcs-svn/fast_export.h index 9c522d177d,12b0bbb419..2d392e370d --- a/vcs-svn/fast_export.h +++ b/vcs-svn/fast_export.h @@@ -8,19 -8,18 +8,18 @@@ void fast_export_init(int fd) void fast_export_deinit(void); void fast_export_reset(void); - void fast_export_delete(uint32_t depth, const uint32_t *path); - void fast_export_modify(uint32_t depth, const uint32_t *path, - uint32_t mode, const char *dataref); + void fast_export_delete(const char *path); + void fast_export_modify(const char *path, uint32_t mode, const char *dataref); -void fast_export_begin_commit(uint32_t revision, const char *author, char *log, - const char *uuid, const char *url, - unsigned long timestamp); +void fast_export_begin_commit(uint32_t revision, const char *author, + const struct strbuf *log, const char *uuid, + const char *url, unsigned long timestamp); void fast_export_end_commit(uint32_t revision); void fast_export_data(uint32_t mode, uint32_t len, struct line_buffer *input); /* If there is no such file at that rev, returns -1, errno == ENOENT. */ - int fast_export_ls_rev(uint32_t rev, uint32_t depth, const uint32_t *path, + int fast_export_ls_rev(uint32_t rev, const char *path, uint32_t *mode_out, struct strbuf *dataref_out); - int fast_export_ls(uint32_t depth, const uint32_t *path, + int fast_export_ls(const char *path, uint32_t *mode_out, struct strbuf *dataref_out); #endif diff --combined vcs-svn/repo_tree.c index 1681b654d1,f2466bc634..67d27f0b6c --- a/vcs-svn/repo_tree.c +++ b/vcs-svn/repo_tree.c @@@ -8,41 -8,57 +8,41 @@@ #include "repo_tree.h" #include "fast_export.h" - const char *repo_read_path(const uint32_t *path, uint32_t *mode_out) -const char *repo_read_path(const char *path) ++const char *repo_read_path(const char *path, uint32_t *mode_out) { int err; - uint32_t dummy; static struct strbuf buf = STRBUF_INIT; strbuf_reset(&buf); - err = fast_export_ls(REPO_MAX_PATH_DEPTH, path, mode_out, &buf); - err = fast_export_ls(path, &dummy, &buf); ++ err = fast_export_ls(path, mode_out, &buf); if (err) { if (errno != ENOENT) die_errno("BUG: unexpected fast_export_ls error"); + /* Treat missing paths as directories. */ + *mode_out = REPO_MODE_DIR; return NULL; } return buf.buf; } - void repo_copy(uint32_t revision, const uint32_t *src, const uint32_t *dst) -uint32_t repo_read_mode(const char *path) -{ - int err; - uint32_t result; - static struct strbuf dummy = STRBUF_INIT; - - strbuf_reset(&dummy); - err = fast_export_ls(path, &result, &dummy); - if (err) { - if (errno != ENOENT) - die_errno("BUG: unexpected fast_export_ls error"); - /* Treat missing paths as directories. */ - return REPO_MODE_DIR; - } - return result; -} - + void repo_copy(uint32_t revision, const char *src, const char *dst) { int err; uint32_t mode; static struct strbuf data = STRBUF_INIT; strbuf_reset(&data); - err = fast_export_ls_rev(revision, REPO_MAX_PATH_DEPTH, src, &mode, &data); + err = fast_export_ls_rev(revision, src, &mode, &data); if (err) { if (errno != ENOENT) die_errno("BUG: unexpected fast_export_ls_rev error"); - fast_export_delete(REPO_MAX_PATH_DEPTH, dst); + fast_export_delete(dst); return; } - fast_export_modify(REPO_MAX_PATH_DEPTH, dst, mode, data.buf); + fast_export_modify(dst, mode, data.buf); } - void repo_delete(uint32_t *path) + void repo_delete(const char *path) { - fast_export_delete(REPO_MAX_PATH_DEPTH, path); + fast_export_delete(path); } diff --combined vcs-svn/repo_tree.h index ce69fa7e58,44e6e8fabc..889c6a3c95 --- a/vcs-svn/repo_tree.h +++ b/vcs-svn/repo_tree.h @@@ -1,23 -1,21 +1,20 @@@ #ifndef REPO_TREE_H_ #define REPO_TREE_H_ -#include "git-compat-util.h" +struct strbuf; #define REPO_MODE_DIR 0040000 #define REPO_MODE_BLB 0100644 #define REPO_MODE_EXE 0100755 #define REPO_MODE_LNK 0120000 - #define REPO_MAX_PATH_LEN 4096 - #define REPO_MAX_PATH_DEPTH 1000 - uint32_t next_blob_mark(void); - void repo_copy(uint32_t revision, const uint32_t *src, const uint32_t *dst); - void repo_add(uint32_t *path, uint32_t mode, uint32_t blob_mark); - const char *repo_read_path(const uint32_t *path, uint32_t *mode_out); - void repo_delete(uint32_t *path); + void repo_copy(uint32_t revision, const char *src, const char *dst); + void repo_add(const char *path, uint32_t mode, uint32_t blob_mark); -const char *repo_read_path(const char *path); -uint32_t repo_read_mode(const char *path); ++const char *repo_read_path(const char *path, uint32_t *mode_out); + void repo_delete(const char *path); void repo_commit(uint32_t revision, const char *author, - char *log, const char *uuid, const char *url, + const struct strbuf *log, const char *uuid, const char *url, long unsigned timestamp); void repo_diff(uint32_t r1, uint32_t r2); void repo_init(void); diff --combined vcs-svn/svndump.c index 35a8af3c9f,363503d4ea..11c59f18bf --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@@ -11,17 -11,16 +11,16 @@@ #include "repo_tree.h" #include "fast_export.h" #include "line_buffer.h" - #include "string_pool.h" #include "strbuf.h" -#define REPORT_FILENO 3 - /* * Compare start of string to literal of equal length; * must be guarded by length test. */ #define constcmp(s, ref) memcmp(s, ref, sizeof(ref) - 1) +#define REPORT_FILENO 3 + #define NODEACT_REPLACE 4 #define NODEACT_DELETE 3 #define NODEACT_ADD 2 @@@ -41,7 -40,7 +40,7 @@@ static struct line_buffer input = LINE_ static struct { uint32_t action, propLength, textLength, srcRev, type; - uint32_t src[REPO_MAX_PATH_DEPTH], dst[REPO_MAX_PATH_DEPTH]; + struct strbuf src, dst; uint32_t text_delta, prop_delta; } node_ctx; @@@ -62,9 -61,11 +61,11 @@@ static void reset_node_ctx(char *fname node_ctx.action = NODEACT_UNKNOWN; node_ctx.propLength = LENGTH_UNKNOWN; node_ctx.textLength = LENGTH_UNKNOWN; - node_ctx.src[0] = ~0; + strbuf_reset(&node_ctx.src); node_ctx.srcRev = 0; - pool_tok_seq(REPO_MAX_PATH_DEPTH, node_ctx.dst, "/", fname); + strbuf_reset(&node_ctx.dst); + if (fname) + strbuf_addstr(&node_ctx.dst, fname); node_ctx.text_delta = 0; node_ctx.prop_delta = 0; } @@@ -87,7 -88,7 +88,7 @@@ static void reset_dump_ctx(const char * } 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; @@@ -99,23 -100,23 +100,23 @@@ 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"): @@@ -151,7 -152,6 +152,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 @@@ -168,15 -168,15 +169,15 @@@ 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. */ @@@ -184,17 -184,22 +185,17 @@@ 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: @@@ -224,15 -229,14 +225,15 @@@ static void handle_node(void if (have_text || have_props || node_ctx.srcRev) die("invalid dump: deletion node has " "copyfrom info, text, or properties"); - repo_delete(node_ctx.dst); - return repo_delete(node_ctx.dst.buf); ++ repo_delete(node_ctx.dst.buf); + return; } if (node_ctx.action == NODEACT_REPLACE) { - repo_delete(node_ctx.dst); + repo_delete(node_ctx.dst.buf); node_ctx.action = NODEACT_ADD; } if (node_ctx.srcRev) { - repo_copy(node_ctx.srcRev, node_ctx.src, node_ctx.dst); + repo_copy(node_ctx.srcRev, node_ctx.src.buf, node_ctx.dst.buf); if (node_ctx.action == NODEACT_ADD) node_ctx.action = NODEACT_CHANGE; } @@@ -242,13 -246,14 +243,13 @@@ /* * Find old content (old_data) and decide on the new mode. */ - if (node_ctx.action == NODEACT_CHANGE && !~*node_ctx.dst) { + if (node_ctx.action == NODEACT_CHANGE && !*node_ctx.dst.buf) { if (type != REPO_MODE_DIR) die("invalid dump: root of tree is not a regular file"); old_data = NULL; } else if (node_ctx.action == NODEACT_CHANGE) { uint32_t mode; - old_data = repo_read_path(node_ctx.dst, &mode); - old_data = repo_read_path(node_ctx.dst.buf); - mode = repo_read_mode(node_ctx.dst.buf); ++ old_data = repo_read_path(node_ctx.dst.buf, &mode); if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR) die("invalid dump: cannot modify a directory into a file"); if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR) @@@ -285,12 -290,10 +286,10 @@@ /* For the fast_export_* functions, NULL means empty. */ old_data = NULL; if (!have_text) { - fast_export_modify(REPO_MAX_PATH_DEPTH, node_ctx.dst, - node_ctx.type, old_data); + fast_export_modify(node_ctx.dst.buf, node_ctx.type, old_data); return; } - fast_export_modify(REPO_MAX_PATH_DEPTH, node_ctx.dst, - node_ctx.type, "inline"); + fast_export_modify(node_ctx.dst.buf, node_ctx.type, "inline"); fast_export_data(node_ctx.type, node_ctx.textLength, &input); } @@@ -299,7 -302,7 +298,7 @@@ static void begin_revision(void if (!rev_ctx.revision) /* revision 0 gets no git commit. */ return; fast_export_begin_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); } @@@ -318,13 -321,10 +317,13 @@@ void svndump_read(const char *url reset_dump_ctx(url); while ((t = buffer_read_line(&input))) { - val = strstr(t, ": "); + val = strchr(t, ':'); if (!val) continue; - val += 2; + val++; + if (*val != ' ') + continue; + val++; /* strlen(key) + 1 */ switch (val - t - 1) { @@@ -394,7 -394,8 +393,8 @@@ case sizeof("Node-copyfrom-path"): if (constcmp(t, "Node-copyfrom-path")) continue; - pool_tok_seq(REPO_MAX_PATH_DEPTH, node_ctx.src, "/", val); + strbuf_reset(&node_ctx.src); + strbuf_addstr(&node_ctx.src, val); break; case sizeof("Node-copyfrom-rev"): if (constcmp(t, "Node-copyfrom-rev")) @@@ -459,6 -460,8 +459,8 @@@ int svndump_init(const char *filename strbuf_init(&dump_ctx.url, 4096); strbuf_init(&rev_ctx.log, 4096); strbuf_init(&rev_ctx.author, 4096); + strbuf_init(&node_ctx.src, 4096); + strbuf_init(&node_ctx.dst, 4096); reset_dump_ctx(NULL); reset_rev_ctx(0); reset_node_ctx(NULL); @@@ -472,6 -475,8 +474,8 @@@ void svndump_deinit(void reset_rev_ctx(0); reset_node_ctx(NULL); strbuf_release(&rev_ctx.log); + strbuf_release(&node_ctx.src); + strbuf_release(&node_ctx.dst); if (buffer_deinit(&input)) fprintf(stderr, "Input error\n"); if (ferror(stdout))