Skip to content

Commit

Permalink
Merge branch 'jn/svn-fe'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Aug 31, 2010
2 parents d7cc7c9 + cd9a7b5 commit aca3550
Show file tree
Hide file tree
Showing 31 changed files with 2,108 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,17 @@
/test-dump-cache-tree
/test-genrandom
/test-index-version
/test-line-buffer
/test-match-trees
/test-obj-pool
/test-parse-options
/test-path-utils
/test-run-command
/test-sha1
/test-sigchain
/test-string-pool
/test-svn-fe
/test-treap
/common-cmds.h
*.tar.gz
*.dsc
Expand Down
37 changes: 33 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ all::
#
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
#
# Define NO_STRTOK_R if you don't have strtok_r in the C library.
#
# Define NO_LIBGEN_H if you don't have libgen.h.
#
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
Expand Down Expand Up @@ -408,12 +410,17 @@ TEST_PROGRAMS_NEED_X += test-date
TEST_PROGRAMS_NEED_X += test-delta
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
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-svn-fe
TEST_PROGRAMS_NEED_X += test-treap
TEST_PROGRAMS_NEED_X += test-index-version

TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
Expand Down Expand Up @@ -468,6 +475,7 @@ export PYTHON_PATH

LIB_FILE=libgit.a
XDIFF_LIB=xdiff/lib.a
VCSSVN_LIB=vcs-svn/lib.a

LIB_H += advice.h
LIB_H += archive.h
Expand Down Expand Up @@ -1035,6 +1043,7 @@ ifeq ($(uname_S),Windows)
NO_UNSETENV = YesPlease
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_STRTOK_R = YesPlease
NO_MEMMEM = YesPlease
# NEEDS_LIBICONV = YesPlease
NO_ICONV = YesPlease
Expand Down Expand Up @@ -1089,6 +1098,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_UNSETENV = YesPlease
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
NO_STRTOK_R = YesPlease
NO_MEMMEM = YesPlease
NEEDS_LIBICONV = YesPlease
OLD_ICONV = YesPlease
Expand Down Expand Up @@ -1319,6 +1329,10 @@ endif
ifdef NO_STRTOULL
COMPAT_CFLAGS += -DNO_STRTOULL
endif
ifdef NO_STRTOK_R
COMPAT_CFLAGS += -DNO_STRTOK_R
COMPAT_OBJS += compat/strtok_r.o
endif
ifdef NO_SETENV
COMPAT_CFLAGS += -DNO_SETENV
COMPAT_OBJS += compat/setenv.o
Expand Down Expand Up @@ -1739,7 +1753,9 @@ ifndef NO_CURL
endif
XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
xdiff/xmerge.o xdiff/xpatience.o
OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS)
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
OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)

dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
Expand Down Expand Up @@ -1861,6 +1877,11 @@ http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h
xdiff-interface.o $(XDIFF_OBJS): \
xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h

$(VCSSVN_OBJS): \
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
endif

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

$(VCSSVN_LIB): $(VCSSVN_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(VCSSVN_OBJS)

doc:
$(MAKE) -C Documentation all
Expand Down Expand Up @@ -2007,12 +2030,18 @@ test-date$X: date.o ctype.o

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

test-line-buffer$X: vcs-svn/lib.a

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)

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

check-sha1:: test-sha1$X
./test-sha1.sh
Expand Down Expand Up @@ -2187,8 +2216,8 @@ distclean: clean
$(RM) configure

clean:
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o \
builtin/*.o $(LIB_FILE) $(XDIFF_LIB)
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
$(RM) $(TEST_PROGRAMS)
$(RM) -r bin-wrappers
Expand Down
61 changes: 61 additions & 0 deletions compat/strtok_r.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* Reentrant string tokenizer. Generic version.
Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include "../git-compat-util.h"

/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
char s[] = "-abc-=-def";
char *sp;
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0"
*/
char *
gitstrtok_r (char *s, const char *delim, char **save_ptr)
{
char *token;

if (s == NULL)
s = *save_ptr;

/* Scan leading delimiters. */
s += strspn (s, delim);
if (*s == '\0')
{
*save_ptr = s;
return NULL;
}

/* Find the end of the token. */
token = s;
s = strpbrk (token, delim);
if (s == NULL)
/* This token finishes the string. */
*save_ptr = token + strlen (token);
else
{
/* Terminate the token and make *SAVE_PTR point past it. */
*s = '\0';
*save_ptr = s + 1;
}
return token;
}
1 change: 1 addition & 0 deletions config.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ NO_IPV6=@NO_IPV6@
NO_C99_FORMAT=@NO_C99_FORMAT@
NO_HSTRERROR=@NO_HSTRERROR@
NO_STRCASESTR=@NO_STRCASESTR@
NO_STRTOK_R=@NO_STRTOK_R@
NO_MEMMEM=@NO_MEMMEM@
NO_STRLCPY=@NO_STRLCPY@
NO_UINTMAX_T=@NO_UINTMAX_T@
Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,12 @@ GIT_CHECK_FUNC(strcasestr,
[NO_STRCASESTR=YesPlease])
AC_SUBST(NO_STRCASESTR)
#
# Define NO_STRTOK_R if you don't have strtok_r
GIT_CHECK_FUNC(strtok_r,
[NO_STRTOK_R=],
[NO_STRTOK_R=YesPlease])
AC_SUBST(NO_STRTOK_R)
#
# Define NO_MEMMEM if you don't have memmem.
GIT_CHECK_FUNC(memmem,
[NO_MEMMEM=],
Expand Down
1 change: 1 addition & 0 deletions contrib/svn-fe/svn-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ int main(int argc, char **argv)
{
svndump_init(NULL);
svndump_read((argc > 1) ? argv[1] : NULL);
svndump_deinit();
svndump_reset();
return 0;
}
19 changes: 10 additions & 9 deletions contrib/svn-fe/svn-fe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ svnadmin dump --incremental REPO | svn-fe [url] | git fast-import
DESCRIPTION
-----------

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

Dumps produced with 'svnadmin dump --deltas' (dumpfile format v3)
are not supported.

OUTPUT FORMAT
-------------
The fast-import format is documented by the git-fast-import(1)
Expand All @@ -43,11 +46,9 @@ user <user@UUID>
as committer, where 'user' is the value of the `svn:author` property
and 'UUID' the repository's identifier.

To support incremental imports, 'svn-fe' will put a `git-svn-id`
line at the end of each commit log message if passed an url on the
command line. This line has the form `git-svn-id: URL@REVNO UUID`.

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

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

BUGS
----
Litters the current working directory with .bin files for
persistence. Will be fixed when the svn-fe infrastructure is aware of
a Git working directory.
Empty directories and unknown properties are silently discarded.

The exit status does not reflect whether an error was detected.

SEE ALSO
--------
Expand Down
5 changes: 5 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ extern size_t gitstrlcpy(char *, const char *, size_t);
extern uintmax_t gitstrtoumax(const char *, char **, int);
#endif

#ifdef NO_STRTOK_R
#define strtok_r gitstrtok_r
extern char *gitstrtok_r(char *s, const char *delim, char **save_ptr);
#endif

#ifdef NO_HSTRERROR
#define hstrerror githstrerror
extern const char *githstrerror(int herror);
Expand Down
Loading

0 comments on commit aca3550

Please sign in to comment.