git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stephen Bash <bash@genarts.com>
To: Albert Krawczyk <pro-logic@optusnet.com.au>
Cc: git@vger.kernel.org
Subject: Re: Git SVN non-standard branch/tag/trunk layout
Date: Mon, 13 Dec 2010 09:23:20 -0500 (EST)	[thread overview]
Message-ID: <13731475.185564.1292250200171.JavaMail.root@mail.hq.genarts.com> (raw)
In-Reply-To: <006c01cb9a44$8407d2f0$8c1778d0$@optusnet.com.au>

----- Original Message -----
> From: "Albert Krawczyk" <pro-logic@optusnet.com.au>
> To: git@vger.kernel.org
> 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

  parent reply	other threads:[~2010-12-13 14:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12 21:35 Git SVN non-standard branch/tag/trunk layout Albert Krawczyk
2010-12-13  0:25 ` Andreas Schwab
2010-12-13  0:55   ` Albert Krawczyk
2010-12-13 14:23 ` Stephen Bash [this message]
2010-12-13 21:08   ` Albert Krawczyk
2010-12-13 21:23     ` Stephen Bash

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13731475.185564.1292250200171.JavaMail.root@mail.hq.genarts.com \
    --to=bash@genarts.com \
    --cc=git@vger.kernel.org \
    --cc=pro-logic@optusnet.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).