Re: Git SVN non-standard branch/tag/trunk layout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message -----
> From: "Albert Krawczyk" <pro-logic@xxxxxxxxxxxxxxx>
> To: git@xxxxxxxxxxxxxxx
> Sent: Sunday, December 12, 2010 4:35:34 PM
> Subject: Git SVN non-standard branch/tag/trunk layout
> 
> The SVN repo I am now faced with has the trunk/branch/tag folders on
> selected folders in the tree.
> 
> Essentially instead of having one project per repo, there are multiple
> projects in the repo. So the repo looks like this
> 
> ---SVN Root --- Folder(Proj1) ---- Files
> \
> ---- Folder(Proj2) --- Trunk - Files
> |	       \
> |		- Branch - Files
> |		|
> |		- Tag - ...
> |
> |- Proj3 - Files
> |- Proj4 - Trunk
> |-Branch
> | - Tag
> 
> The question is, is there a way I can get Git SVN to understand and
> replicate this layout in a git repo? I don't mind if I have to import
> the entire repo again into git.

When I have to deal with non-standard SVN layouts I do the following:
 1) git svn init tgtDir
 2) Edit the config file (see below)
 3) cd tgtDir
 4) git svn fetch

Basically the svn-remote section of the config file allows you to play games with the translation of SVN paths to Git branches.  Basically each line is of the form svnPath:gitRef.

'fetch' lines are fixed SVN paths that map to a fixed Git ref.  You can have zero or more fetch lines as long as the Git refs are unambiguous (add to the static portion of each ref name to make it unambiguous).  

'branches' and 'tags' lines are each allowed to have a single asterisk (*) on either side of the colon (:) that acts like a wildcard -- the SVN directory name at the position of the asterisk will take the place of the asterisk on the right hand side (which must be the end of the line).  Again, you can have zero or more of each of these as long as the left hand side of each is unambiguous.

So taking a SWAG at your project layout (I'm assuming 'Branch' is the actual branch name, not a directory called 'Branch', similar for 'Tag', and I don't know where proj3 and proj4 are -- are they under Proj2 or back in the SVN root?):

[svn-remote "svn"]
        url = http://server.org/svn

        # Project 1 (note use of the name 'trunk' in Git is a personal choice)
        fetch = proj1:refs/remotes/proj1/trunk

        # Project 2
        branches = proj2/*:refs/remotes/proj2/*

        # Project 3 (note use of the name 'trunk' in Git is a personal choice)
        fetch = proj3:refs/remotes/proj3/trunk

        # Project 4 (note use of the name 'trunk' in Git is a personal choice)
        fetch = proj4/trunk:refs/remotes/proj4/trunk

        # etc...

Project 2 is an interesting one because it looks like the trunk is at the same level as branches/tags.  If that's the case, the 'branches' line above will work (it will treat the trunk like any other branch -- a very Git-like approach).  Also note that those projects that didn't have a 'trunk' directory in SVN I added a 'trunk' on the Git side to keep things consistent -- this is completely optional.

Once you get comfortable with the rules governing the config lines, you can pretty much untangle any SVN layout.

HTH,
Stephen
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]