Skip to contentSkip to conversation

Git SVN non-standard branch/tag/trunk layout

DISCUSSION Albert Krawczyk 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi all,

One of the SVN repositories that I work with (and have a Git version of) has recently implemented a tag/trunk/branch layout, and I'd like to update my repository to correctly work with this layout.

As far as I understand the standard layout for a SVN repo that supports branching is

SVR Root ----Trunk - folders/files
\
--Branch - folders/files
\
-Tag - folders/files

With each of those having the project contents

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.

Thanks,
Albert

#1 lore raw

----- Original Message -----

Quoted 24 lines

From: "Albert Krawczyk" <[email protected]>
To: [email protected]
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
Quoted 3 lines

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

#2 lore raw
Quoted 6 lines

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

Hi Stephen,

Thanks a lot! I thought this is what I had to do, and had through trial and (a lot of) error got to be very close. As far as I can see the only 'downside' of this approach is that you can't have the 'root' of the SVN repo checked out, you can only have the root of each project checked out, as they are all on their own ref.

Thanks again for clarifying that,
Albert

#3 lore raw

----- Original Message -----

Quoted 13 lines

From: "Albert Krawczyk" <[email protected]>
To: "Stephen Bash" <[email protected]>
Cc: [email protected]
Sent: Monday, December 13, 2010 4:08:28 PM
Subject: RE: Git SVN non-standard branch/tag/trunk layout

Quoted 7 lines

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.

Quoted 8 lines
Quoted 2 lines

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

Thanks a lot! I thought this is what I had to do, and had through trial and (a lot of) error got to be very close. As far as I can see the only 'downside' of this approach is that you can't have the 'root' of the SVN repo checked out, you can only have the root of each project checked out, as they are all on their own ref.

I hadn't thought about it until now, but you could probably specify fetch=/:refs/remotes/svnroot to have a ref that is the root of the SVN repository... Might be worth a shot...

Stephen

#4 lore raw
In reply to Albert Krawczyk
Quoted 16 lines · Albert Krawczyk

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
Quoted 3 lines

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.

If they are multiple projects then you'll probably be better off importing each project into its own git repository.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#5 lore raw

Andreas Schwab [mailto:[email protected]]

Quoted 4 lines

If they are multiple projects then you'll probably be better off importing each project into its own git repository.

Andreas.

Yes, this is probably the 'better' way of dealing with it, and it works fine. I was however wondering if there was a way to track the root of the SVN directory with the structure I supplied earlier while maintaining a 'nice' structure in Git without having /trunk/, /branch/, /tag/ subdirectories appearing directly in the repository as standard folders. My (extremely limited) understanding is that I would need to edit the config file, specifically the fetch, branches and tags section of svn-remote. But I am unsure of how this modified section would look like.

Albert