Skip to content

Commit aca3550

Browse files
committed
Merge branch 'jn/svn-fe'
* jn/svn-fe: t/t9010-svn-fe.sh: add an +x bit to this test t9010 (svn-fe): avoid symlinks in test t9010 (svn-fe): use Unix-style path in URI vcs-svn: Avoid %z in format string vcs-svn: Rename dirent pool to build on Windows compat: add strtok_r() treap: style fix vcs-svn: remove build artifacts on "make clean" svn-fe manual: Clarify warning about deltas in dump files Update svn-fe manual SVN dump parser Infrastructure to write revisions in fast-export format Add stream helper library Add string-specific memory pool Add treap implementation Add memory pool library Introduce vcs-svn lib
2 parents d7cc7c9 + cd9a7b5 commit aca3550

31 files changed

+2108
-13
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,17 @@
166166
/test-dump-cache-tree
167167
/test-genrandom
168168
/test-index-version
169+
/test-line-buffer
169170
/test-match-trees
171+
/test-obj-pool
170172
/test-parse-options
171173
/test-path-utils
172174
/test-run-command
173175
/test-sha1
174176
/test-sigchain
177+
/test-string-pool
178+
/test-svn-fe
179+
/test-treap
175180
/common-cmds.h
176181
*.tar.gz
177182
*.dsc

Makefile

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ all::
6868
#
6969
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
7070
#
71+
# Define NO_STRTOK_R if you don't have strtok_r in the C library.
72+
#
7173
# Define NO_LIBGEN_H if you don't have libgen.h.
7274
#
7375
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
@@ -408,12 +410,17 @@ TEST_PROGRAMS_NEED_X += test-date
408410
TEST_PROGRAMS_NEED_X += test-delta
409411
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
410412
TEST_PROGRAMS_NEED_X += test-genrandom
413+
TEST_PROGRAMS_NEED_X += test-line-buffer
411414
TEST_PROGRAMS_NEED_X += test-match-trees
415+
TEST_PROGRAMS_NEED_X += test-obj-pool
412416
TEST_PROGRAMS_NEED_X += test-parse-options
413417
TEST_PROGRAMS_NEED_X += test-path-utils
414418
TEST_PROGRAMS_NEED_X += test-run-command
415419
TEST_PROGRAMS_NEED_X += test-sha1
416420
TEST_PROGRAMS_NEED_X += test-sigchain
421+
TEST_PROGRAMS_NEED_X += test-string-pool
422+
TEST_PROGRAMS_NEED_X += test-svn-fe
423+
TEST_PROGRAMS_NEED_X += test-treap
417424
TEST_PROGRAMS_NEED_X += test-index-version
418425

419426
TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
@@ -468,6 +475,7 @@ export PYTHON_PATH
468475

469476
LIB_FILE=libgit.a
470477
XDIFF_LIB=xdiff/lib.a
478+
VCSSVN_LIB=vcs-svn/lib.a
471479

472480
LIB_H += advice.h
473481
LIB_H += archive.h
@@ -1035,6 +1043,7 @@ ifeq ($(uname_S),Windows)
10351043
NO_UNSETENV = YesPlease
10361044
NO_STRCASESTR = YesPlease
10371045
NO_STRLCPY = YesPlease
1046+
NO_STRTOK_R = YesPlease
10381047
NO_MEMMEM = YesPlease
10391048
# NEEDS_LIBICONV = YesPlease
10401049
NO_ICONV = YesPlease
@@ -1089,6 +1098,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
10891098
NO_UNSETENV = YesPlease
10901099
NO_STRCASESTR = YesPlease
10911100
NO_STRLCPY = YesPlease
1101+
NO_STRTOK_R = YesPlease
10921102
NO_MEMMEM = YesPlease
10931103
NEEDS_LIBICONV = YesPlease
10941104
OLD_ICONV = YesPlease
@@ -1319,6 +1329,10 @@ endif
13191329
ifdef NO_STRTOULL
13201330
COMPAT_CFLAGS += -DNO_STRTOULL
13211331
endif
1332+
ifdef NO_STRTOK_R
1333+
COMPAT_CFLAGS += -DNO_STRTOK_R
1334+
COMPAT_OBJS += compat/strtok_r.o
1335+
endif
13221336
ifdef NO_SETENV
13231337
COMPAT_CFLAGS += -DNO_SETENV
13241338
COMPAT_OBJS += compat/setenv.o
@@ -1739,7 +1753,9 @@ ifndef NO_CURL
17391753
endif
17401754
XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
17411755
xdiff/xmerge.o xdiff/xpatience.o
1742-
OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
1756+
VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \
1757+
vcs-svn/repo_tree.o vcs-svn/fast_export.o vcs-svn/svndump.o
1758+
OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
17431759

17441760
dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
17451761
dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
@@ -1861,6 +1877,11 @@ http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h
18611877
xdiff-interface.o $(XDIFF_OBJS): \
18621878
xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
18631879
xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
1880+
1881+
$(VCSSVN_OBJS): \
1882+
vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h \
1883+
vcs-svn/line_buffer.h vcs-svn/repo_tree.h vcs-svn/fast_export.h \
1884+
vcs-svn/svndump.h
18641885
endif
18651886

18661887
exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
@@ -1909,6 +1930,8 @@ $(LIB_FILE): $(LIB_OBJS)
19091930
$(XDIFF_LIB): $(XDIFF_OBJS)
19101931
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(XDIFF_OBJS)
19111932

1933+
$(VCSSVN_LIB): $(VCSSVN_OBJS)
1934+
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(VCSSVN_OBJS)
19121935

19131936
doc:
19141937
$(MAKE) -C Documentation all
@@ -2007,12 +2030,18 @@ test-date$X: date.o ctype.o
20072030

20082031
test-delta$X: diff-delta.o patch-delta.o
20092032

2033+
test-line-buffer$X: vcs-svn/lib.a
2034+
20102035
test-parse-options$X: parse-options.o
20112036

2037+
test-string-pool$X: vcs-svn/lib.a
2038+
2039+
test-svn-fe$X: vcs-svn/lib.a
2040+
20122041
.PRECIOUS: $(TEST_OBJS)
20132042

20142043
test-%$X: test-%.o $(GITLIBS)
2015-
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
2044+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
20162045

20172046
check-sha1:: test-sha1$X
20182047
./test-sha1.sh
@@ -2187,8 +2216,8 @@ distclean: clean
21872216
$(RM) configure
21882217

21892218
clean:
2190-
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
2191-
builtin/*.o $(LIB_FILE) $(XDIFF_LIB)
2219+
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
2220+
builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
21922221
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
21932222
$(RM) $(TEST_PROGRAMS)
21942223
$(RM) -r bin-wrappers

compat/strtok_r.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* Reentrant string tokenizer. Generic version.
2+
Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc.
3+
This file is part of the GNU C Library.
4+
5+
The GNU C Library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
The GNU C Library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with the GNU C Library; if not, write to the Free
17+
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18+
02111-1307 USA. */
19+
20+
#include "../git-compat-util.h"
21+
22+
/* Parse S into tokens separated by characters in DELIM.
23+
If S is NULL, the saved pointer in SAVE_PTR is used as
24+
the next starting point. For example:
25+
char s[] = "-abc-=-def";
26+
char *sp;
27+
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
28+
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
29+
x = strtok_r(NULL, "=", &sp); // x = NULL
30+
// s = "abc\0-def\0"
31+
*/
32+
char *
33+
gitstrtok_r (char *s, const char *delim, char **save_ptr)
34+
{
35+
char *token;
36+
37+
if (s == NULL)
38+
s = *save_ptr;
39+
40+
/* Scan leading delimiters. */
41+
s += strspn (s, delim);
42+
if (*s == '\0')
43+
{
44+
*save_ptr = s;
45+
return NULL;
46+
}
47+
48+
/* Find the end of the token. */
49+
token = s;
50+
s = strpbrk (token, delim);
51+
if (s == NULL)
52+
/* This token finishes the string. */
53+
*save_ptr = token + strlen (token);
54+
else
55+
{
56+
/* Terminate the token and make *SAVE_PTR point past it. */
57+
*s = '\0';
58+
*save_ptr = s + 1;
59+
}
60+
return token;
61+
}

config.mak.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ NO_IPV6=@NO_IPV6@
4646
NO_C99_FORMAT=@NO_C99_FORMAT@
4747
NO_HSTRERROR=@NO_HSTRERROR@
4848
NO_STRCASESTR=@NO_STRCASESTR@
49+
NO_STRTOK_R=@NO_STRTOK_R@
4950
NO_MEMMEM=@NO_MEMMEM@
5051
NO_STRLCPY=@NO_STRLCPY@
5152
NO_UINTMAX_T=@NO_UINTMAX_T@

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,12 @@ GIT_CHECK_FUNC(strcasestr,
783783
[NO_STRCASESTR=YesPlease])
784784
AC_SUBST(NO_STRCASESTR)
785785
#
786+
# Define NO_STRTOK_R if you don't have strtok_r
787+
GIT_CHECK_FUNC(strtok_r,
788+
[NO_STRTOK_R=],
789+
[NO_STRTOK_R=YesPlease])
790+
AC_SUBST(NO_STRTOK_R)
791+
#
786792
# Define NO_MEMMEM if you don't have memmem.
787793
GIT_CHECK_FUNC(memmem,
788794
[NO_MEMMEM=],

contrib/svn-fe/svn-fe.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ int main(int argc, char **argv)
1010
{
1111
svndump_init(NULL);
1212
svndump_read((argc > 1) ? argv[1] : NULL);
13+
svndump_deinit();
1314
svndump_reset();
1415
return 0;
1516
}

contrib/svn-fe/svn-fe.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ svnadmin dump --incremental REPO | svn-fe [url] | git fast-import
1212
DESCRIPTION
1313
-----------
1414

15-
Converts a Subversion dumpfile (version: 2) into input suitable for
15+
Converts a Subversion dumpfile into input suitable for
1616
git-fast-import(1) and similar importers. REPO is a path to a
1717
Subversion repository mirrored on the local disk. Remote Subversion
1818
repositories can be mirrored on local disk using the `svnsync`
@@ -25,6 +25,9 @@ Subversion's repository dump format is documented in full in
2525
Files in this format can be generated using the 'svnadmin dump' or
2626
'svk admin dump' command.
2727

28+
Dumps produced with 'svnadmin dump --deltas' (dumpfile format v3)
29+
are not supported.
30+
2831
OUTPUT FORMAT
2932
-------------
3033
The fast-import format is documented by the git-fast-import(1)
@@ -43,11 +46,9 @@ user <user@UUID>
4346
as committer, where 'user' is the value of the `svn:author` property
4447
and 'UUID' the repository's identifier.
4548

46-
To support incremental imports, 'svn-fe' will put a `git-svn-id`
47-
line at the end of each commit log message if passed an url on the
48-
command line. This line has the form `git-svn-id: URL@REVNO UUID`.
49-
50-
Empty directories and unknown properties are silently discarded.
49+
To support incremental imports, 'svn-fe' puts a `git-svn-id` line at
50+
the end of each commit log message if passed an url on the command
51+
line. This line has the form `git-svn-id: URL@REVNO UUID`.
5152

5253
The resulting repository will generally require further processing
5354
to put each project in its own repository and to separate the history
@@ -56,9 +57,9 @@ may be useful for this purpose.
5657

5758
BUGS
5859
----
59-
Litters the current working directory with .bin files for
60-
persistence. Will be fixed when the svn-fe infrastructure is aware of
61-
a Git working directory.
60+
Empty directories and unknown properties are silently discarded.
61+
62+
The exit status does not reflect whether an error was detected.
6263

6364
SEE ALSO
6465
--------

git-compat-util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ extern size_t gitstrlcpy(char *, const char *, size_t);
312312
extern uintmax_t gitstrtoumax(const char *, char **, int);
313313
#endif
314314

315+
#ifdef NO_STRTOK_R
316+
#define strtok_r gitstrtok_r
317+
extern char *gitstrtok_r(char *s, const char *delim, char **save_ptr);
318+
#endif
319+
315320
#ifdef NO_HSTRERROR
316321
#define hstrerror githstrerror
317322
extern const char *githstrerror(int herror);

0 commit comments

Comments
 (0)