Bob Arthur
Bob Arthur

Reputation: 147

Nested branches, variable depth

We have a large, quite old SVN repository that we'd like to migrate to git. Unfortunately, our branch structure is quite tricky; it has nested branches of varying depth, with some branches living alongside nested folders:

branches/
         branch1/
         branch2/
         teams/
               team1/
                     projectBranch1
               team2/
                     projectBranch2

In my git config, I have tried

branches = branches/*/*/*:refs/remotes/origin/*/*/*

which has imported the team branches fine, but when fetching updates to "branch1", it treats the first few project directories as part of the branch name, creating branches like branch1/src/com/. I then tried:

branches = branches/teams/*/*:refs/remotes/origin/teams/*/*
branches = branches/*:refs/remotes/origin/*

hoping that commits to team projects would be matched first, and the first-level wildcard only used for top-level branches. But it then reverts to treating team branches as subdirectories of the "teams" branch. I then hoped reversing the order of the terms in the config file might change the matching order, but that didn't seem to make a difference.

I have managed to get a clean migration from recent revisions by tweaking the top-level wildcard to match only certain names, so that there is no ambiguity between the two branches terms. But ideally I'd like to migrate from older revisions, where the top-level branch names are less easily picked out. Is there any way to persuade git-svn to match branches entries using a "most specific first" rule?

Upvotes: 2

Views: 260

Answers (1)

Lazy Badger
Lazy Badger

Reputation: 97282

I'll recommend to try SubGit for your layout: it can (?) handle more complex cases, than git-svn

branches = branches/*:refs/heads/*
branches = feature_*:refs/heads/features/*
branches = hotfix/*_*:refs/heads/hotfix/*/*

Pay attention to wildcard usage on remote and local parts and translations into different namespaces for different paths of svn-branches

even historical moves and renames

If I understood your branches tree correctly, i.e. you have at the same time

branches/branch*/
…
branches/teams/team*/projectBranch*

your SubGit mapping can be something like (TBT!)

branches = branches/*:refs/remotes/origin/*
branches = teambranches/*-*:refs/remotes/origin/teams/*/*

Upvotes: 1

Related Questions