Subject: Re: git svn: Supporting multiple branch subdirs?

From: Michael J Gruber <[email-masked]>
Date: Sat, 13 Jun 2009 13:46:10 +0200

Marc Branchaud venit, vidit, dixit 12.06.2009 23:46:
> Hi,
> 
> I believe I need git-svn to support multiple branch subdirectories.
> 
> The motivation for this is the (partial) gitification of the FreeBSD subversion repository.  FreeBSD doesn't follow the usual branches/tags/trunk pattern.  Instead:
> 
> - FreeBSD's /trunk is called /head.
> 
> - /head is branched into /stable/X subdirs.
> 
> - Each /stable/X branch is sub-branched into /releng/X.Y subirs.
> 
> - /releng/X.Y.Z branches are tagged under /release/foo.
> 
> I'm only looking to get an updatable mirror of their repo -- I don't (yet) need to push changes back to FreeBSD.
> 
> I'd like to modify git-svn to support multiple (at least two) -b parameters, so I could import the FreeBSD repo with something like
> 	git svn init --trunk=head \
> 		--branches=stable \
> 		--branches=releng \
> 		--tags=release \
> 		file:///local/mirror/of/svn.freebsd.org/base/
> 	git svn fetch
> 
> Is this approach wise or even feasible?  A couple of possible show-stoppers I see are:

After doing the init with "--branches=stable" (without releng), do
git config --add svn-remote.svn.branches 'releng/*:refs/remotes/*'

This gives you two branches refspecs in .git/config (feel free to put
them in different dirs under remotes if there may be name clashes
between stable and releng branches).

> 
> - The releng/X.Y branches are created from the stable/X  tree, where X itself doesn't exist from the start.

Well, I assume X exists at the time of creation of X.Y. That's all that
is needed.

> 
> - FreeBSD likes to make single commits that spans multiple branches.  This is usually done as a security patch: One commit can, for example, touch /head, /stable/X, /stable/W, and several branches under /releng.

I assume that git-svn converts such an svn commit into several git
commits, one for each affected branch. Since you have a local mirror
it's easy to try out.

> 
> If this isn't completely off the wall, I'd appreciate some pointers on the git-svn.perl code.  I've tried searching through the code to see how the -b parameter is handled, but I got lost pretty quickly.  How does the fetch command deal with branches?

I think there's no need to hack git-svn. Let us know how it goes with
the two branches configs.

Michael