1

I am running svn2git on Windows and would like to exclude a number of branches from the migration process. How is this achieved?

Jacob
  • 619
  • 1
  • 7
  • 18
  • I tried using --exclude _branchname_ but it results in an error. Running command: git svn fetch '--ignore-paths=^(?:trunk[/]|tags[/][^/]+[/]|branches[/][^/]+[/])(?:Alerts|API)' 'tags[' is not recognized as an internal or external command, operable program or batch file. – Jacob May 28 '15 at 22:12
  • Did you try https://github.com/mazong1123/svn2gitnet ? If it still fail please file an issue and I can help. – Jim Ma Sep 23 '17 at 13:12

2 Answers2

1

svn2git generates a regexp from the exclude tags that it feeds to it's --ignore-paths argument.

Unfortunately, this regexp contains DOS reserved characters - like [ ] | etc - which are not escaped.

I first tried to use the generated regexp to make a properly escaped regexp to make my own --ignore-paths argument but the reserved charcters/escape system of DOS is a real nightmare.

Solution -> use a Linux distribution or setup cygwin on your windows system :

  • Install cygwin, with ruby packages

  • gem install svn2git

  • cd /usr/local/bin

  • ln -s /home/<user>/.gem/ruby/gems/svn2git-2.3.2/bin/svn2git

  • cd /cygdrive/c/<your target repo>

Now you can run svn2git with as many --exclude arguments as needed !

cdup
  • 49
  • 4
0

As cdup suggests, if you can get it to run in e.g. the Git bash window that comes with Git for Windows, you'll likely avoid many issues.

However, if you want, can modify svn2git source code directly on your machine to fix this issue. The issue occurs because svn2git uses single ticks ' rather than double quotes " around arguments that are passed to git svn. The fix described below also applies to other areas of svn2git in the context of a Windows command prompt.

Anyway, open migration.rb under <ruby install path>\lib\ruby\gems\<version>\gems\svn2git-<version>\lib\svn2git and look for this line:

cmd += "--ignore-paths='#{regex}' "

Replace it with this (note that ' has been replaced by an escaped double quote \"):

cmd += "--ignore-paths=\"#{regex}\" "

Save changes and rerun svn2git. Your exclude pattern should now work.

bernhof
  • 6,219
  • 2
  • 45
  • 71