{"thread":{"id":"26029","subject":"Git SVN non-standard branch/tag/trunk layout","startedAt":"2010-12-12T21:35:34Z","lastAt":"2010-12-13T21:23:02Z","messageCount":6,"participants":["Albert Krawczyk","Andreas Schwab","Stephen Bash"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"157897","messageId":"006c01cb9a44$8407d2f0$8c1778d0$@optusnet.com.au","threadId":"26029","inReplyTo":null,"subject":"Git SVN non-standard branch/tag/trunk layout","fromName":"Albert Krawczyk","fromEmail":"pro-logic@optusnet.com.au","sentAt":"2010-12-12T21:35:34Z","receivedAt":"2010-12-12T21:35:34Z","isPatch":false,"sender":{"key":"pro-logic@optusnet.com.au","avatar":null},"body":"Hi all,\n\nOne of the SVN repositories that I work with (and have a Git version of) has\nrecently implemented a tag/trunk/branch layout, and I'd like to update my\nrepository to correctly work with this layout. \n\nAs far as I understand the standard layout for a SVN repo that supports\nbranching is \n\nSVR Root ----Trunk - folders/files\n \\\n  --Branch - folders/files\n  \\\n   -Tag - folders/files\n\nWith each of those having the project contents\n\nThe SVN repo I am now faced with has the trunk/branch/tag folders on\nselected folders in the tree.\n\nEssentially instead of having one project per repo, there are multiple\nprojects in the repo. So the repo looks like this\n\n---SVN Root --- Folder(Proj1) ---- Files\n\t\\\n\t ---- Folder(Proj2) --- Trunk - Files\n\t|\t       \\\n\t|\t\t- Branch - Files\n\t|\t\t|\n\t|\t\t- Tag - ...\n\t|\n\t|- Proj3 - Files\n\t|- Proj4 - Trunk\n\t\t |-Branch\n\t\t | - Tag\n\nThe question is, is there a way I can get Git SVN to understand and\nreplicate this layout in a git repo? I don't mind if I have to import the\nentire repo again into git. \n\nThanks,\nAlbert\n"},{"id":"157903","messageId":"m2fwu2ecy8.fsf@igel.home","threadId":"26029","inReplyTo":"006c01cb9a44$8407d2f0$8c1778d0$@optusnet.com.au","subject":"Re: Git SVN non-standard branch/tag/trunk layout","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2010-12-13T00:25:19Z","receivedAt":"2010-12-13T00:25:19Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"\"Albert Krawczyk\" <pro-logic@optusnet.com.au> writes:\n\n> Essentially instead of having one project per repo, there are multiple\n> projects in the repo. So the repo looks like this\n>\n> ---SVN Root --- Folder(Proj1) ---- Files\n> \t\\\n> \t ---- Folder(Proj2) --- Trunk - Files\n> \t|\t       \\\n> \t|\t\t- Branch - Files\n> \t|\t\t|\n> \t|\t\t- Tag - ...\n> \t|\n> \t|- Proj3 - Files\n> \t|- Proj4 - Trunk\n> \t\t |-Branch\n> \t\t | - Tag\n>\n> The question is, is there a way I can get Git SVN to understand and\n> replicate this layout in a git repo? I don't mind if I have to import the\n> entire repo again into git. \n\nIf they are multiple projects then you'll probably be better off\nimporting each project into its own git repository.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"157909","messageId":"000401cb9a60$71bcd610$55368230$@optusnet.com.au","threadId":"26029","inReplyTo":"m2fwu2ecy8.fsf@igel.home","subject":"RE: Git SVN non-standard branch/tag/trunk layout","fromName":"Albert Krawczyk","fromEmail":"pro-logic@optusnet.com.au","sentAt":"2010-12-13T00:55:30Z","receivedAt":"2010-12-13T00:55:30Z","isPatch":false,"sender":{"key":"pro-logic@optusnet.com.au","avatar":null},"body":"Andreas Schwab [mailto:schwab@linux-m68k.org]\n\n> If they are multiple projects then you'll probably be better off \n> importing each project into its own git repository.\n> \n> Andreas.\n\nYes, this is probably the 'better' way of dealing with it, and it works\nfine. I was however wondering if there was a way to track the root of the\nSVN directory with the structure I supplied earlier while maintaining a\n'nice' structure in Git without having /trunk/, /branch/, /tag/\nsubdirectories appearing directly in the repository as standard folders. My\n(extremely limited) understanding is that I would need to edit the config\nfile, specifically the fetch, branches and tags section of svn-remote. But I\nam unsure of how this modified section would look like. \n\nAlbert\n"},{"id":"157961","messageId":"13731475.185564.1292250200171.JavaMail.root@mail.hq.genarts.com","threadId":"26029","inReplyTo":"006c01cb9a44$8407d2f0$8c1778d0$@optusnet.com.au","subject":"Re: Git SVN non-standard branch/tag/trunk layout","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2010-12-13T14:23:20Z","receivedAt":"2010-12-13T14:23:20Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"----- Original Message -----\n> From: \"Albert Krawczyk\" <pro-logic@optusnet.com.au>\n> To: git@vger.kernel.org\n> Sent: Sunday, December 12, 2010 4:35:34 PM\n> Subject: Git SVN non-standard branch/tag/trunk layout\n> \n> The SVN repo I am now faced with has the trunk/branch/tag folders on\n> selected folders in the tree.\n> \n> Essentially instead of having one project per repo, there are multiple\n> projects in the repo. So the repo looks like this\n> \n> ---SVN Root --- Folder(Proj1) ---- Files\n> \\\n> ---- Folder(Proj2) --- Trunk - Files\n> |\t       \\\n> |\t\t- Branch - Files\n> |\t\t|\n> |\t\t- Tag - ...\n> |\n> |- Proj3 - Files\n> |- Proj4 - Trunk\n> |-Branch\n> | - Tag\n> \n> The question is, is there a way I can get Git SVN to understand and\n> replicate this layout in a git repo? I don't mind if I have to import\n> the entire repo again into git.\n\nWhen I have to deal with non-standard SVN layouts I do the following:\n 1) git svn init tgtDir\n 2) Edit the config file (see below)\n 3) cd tgtDir\n 4) git svn fetch\n\nBasically 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.\n\n'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).  \n\n'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.\n\nSo 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?):\n\n[svn-remote \"svn\"]\n        url = http://server.org/svn\n\n        # Project 1 (note use of the name 'trunk' in Git is a personal choice)\n        fetch = proj1:refs/remotes/proj1/trunk\n\n        # Project 2\n        branches = proj2/*:refs/remotes/proj2/*\n\n        # Project 3 (note use of the name 'trunk' in Git is a personal choice)\n        fetch = proj3:refs/remotes/proj3/trunk\n\n        # Project 4 (note use of the name 'trunk' in Git is a personal choice)\n        fetch = proj4/trunk:refs/remotes/proj4/trunk\n\n        # etc...\n\nProject 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.\n\nOnce you get comfortable with the rules governing the config lines, you can pretty much untangle any SVN layout.\n\nHTH,\nStephen\n"},{"id":"157999","messageId":"002301cb9b09$e4eb2de0$aec189a0$@optusnet.com.au","threadId":"26029","inReplyTo":"13731475.185564.1292250200171.JavaMail.root@mail.hq.genarts.com","subject":"RE: Git SVN non-standard branch/tag/trunk layout","fromName":"Albert Krawczyk","fromEmail":"pro-logic@optusnet.com.au","sentAt":"2010-12-13T21:08:28Z","receivedAt":"2010-12-13T21:08:28Z","isPatch":false,"sender":{"key":"pro-logic@optusnet.com.au","avatar":null},"body":">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.\n>\n>Once you get comfortable with the rules governing the config lines, you can pretty much untangle any SVN layout.\n>\n>HTH,\n>Stephen\n\nHi Stephen,\n\nThanks 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. \n\nThanks again for clarifying that,\nAlbert \n"},{"id":"158000","messageId":"19945570.186298.1292275382811.JavaMail.root@mail.hq.genarts.com","threadId":"26029","inReplyTo":"002301cb9b09$e4eb2de0$aec189a0$@optusnet.com.au","subject":"Re: Git SVN non-standard branch/tag/trunk layout","fromName":"Stephen Bash","fromEmail":"bash@genarts.com","sentAt":"2010-12-13T21:23:02Z","receivedAt":"2010-12-13T21:23:02Z","isPatch":false,"sender":{"key":"bash@genarts.com","avatar":null},"body":"----- Original Message -----\n> From: \"Albert Krawczyk\" <pro-logic@optusnet.com.au>\n> To: \"Stephen Bash\" <bash@genarts.com>\n> Cc: git@vger.kernel.org\n> Sent: Monday, December 13, 2010 4:08:28 PM\n> Subject: RE: Git SVN non-standard branch/tag/trunk layout\n>\n> >Project 2 is an interesting one because it looks like the trunk is at\n> >the same level as branches/tags. If that's the case, the 'branches'\n> >line above will work (it will treat >the trunk like any other branch\n> >-- a very Git-like approach). Also note that those projects that\n> >didn't have a 'trunk' directory in SVN I added a 'trunk' on the Git\n> >side to keep things consistent -- this is completely optional.\n> >\n> >Once you get comfortable with the rules governing the config lines,\n> >you can pretty much untangle any SVN layout.\n> \n> Thanks a lot! I thought this is what I had to do, and had through\n> trial and (a lot of) error got to be very close. As far as I can see\n> the only 'downside' of this approach is that you can't have the 'root'\n> of the SVN repo checked out, you can only have the root of each\n> project checked out, as they are all on their own ref.\n\nI 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...\n\nStephen\n"}]}