nirvdrum / svn2git

Ruby tool for importing existing svn projects into git.
MIT License
2.11k stars 443 forks source link

Fails in Windows for non-standard repository name containing spaces. #115

Open pfdevmuller opened 11 years ago

pfdevmuller commented 11 years ago

Still struggling with this.

My repo is non standard, locally hosted and has spaces in the name (Oh the regret!)

I'm on Windows 7, 64-bit, git version git version 1.8.1.msysgit.1

If I execute the following command in Powershell:

svn2git.bat 'https://server3/svn/main/Working Files and Tools/Namwater Reval Data Parsing' --username pmuller -v --no-minimize-url --trunk trunk --tags tags --nobranches

I get the following:

PS E:\temp\NamwaterRevalDataParsing> svn2git.bat 'https://server3/svn/main/Working Files and Tools/Namwater Reval Data Parsing' --username pmuller -v --no-minimize-url --trunk trunk --tags tags --nobranches
Running command: git svn init --prefix=svn/ --username=pmuller --no-metadata --no-minimize-url --trunk=trunk --tags=tags https://server3/svn/main/Working\ Files\ and\ Tools/Namwater\ Reval\ Data\ Parsing
Initialized empty Git repository in e:/temp/NamwaterRevalDataParsing/Files/.git/
Running command: git svn fetch
fatal: Not a git repository (or any of the parent directories): .git
Already at toplevel, but .git not found
 at E:\Program Files (x86)\Git/libexec/git-core\git-svn line 342
command failed:
2>&1 git svn fetch

The problem is that git svn init creates a "Files" folder (the first term after a space in my repo URL", and the .git folder ends up inside the "Files" folder.

If I run the generated git-svn command directly, in Powershell, I get the same result:

PS E:\temp\NamwaterRevalDataParsing> git svn init --prefix=svn/ --username=pmuller --no-metadata --no-minimize-url --trunk=trunk --tags=tags https://server3/svn/main/Working\ Files\ and\ Tools/Namwater\ Reval\ Data\ Parsing
Initialized empty Git repository in e:/temp/NamwaterRevalDataParsing/Files/.git/

If I change the generated git-svn command to use quotes rather than the space escapes, and run that directly in Powershell, I get the desired result:

PS E:\temp\NamwaterRevalDataParsing> git svn init --prefix=svn/ --username=pmuller --no-metadata --no-minimize-url --trunk=trunk --tags=tags "https://server3/svn/main/Working Files and Tools/Namwater Reval Data Parsing"
Initialized empty Git repository in E:/temp/NamwaterRevalDataParsing/.git/
PS E:\temp\NamwaterRevalDataParsing>

If I run the generated git-svn command directly in git bash, I get the desired result:

Pieter@PIETER-DESKTOP /E/temp/NamwaterRevalDataParsing
$ git svn init --prefix=svn/ --username=pmuller --no-metadata --no-minimize-url --trunk=trunk --tags=tags https://server3/svn/main/Working\ Files\ and\ Tools/Namwater\ Reval\ Data\ Parsing
Initialized empty Git repository in e:/temp/NamwaterRevalDataParsing/.git/
Pieter@PIETER-DESKTOP /E/temp/NamwaterRevalDataParsing (master)
$

However, unfortunately, if I run the original svn2git command in git bash, I'm back to the original result:

Pieter@PIETER-DESKTOP /E/temp/NamwaterRevalDataParsing
$ svn2git "https://server3/svn/main/Working Files and Tools/Namwater Reval Data Parsing" --username pmuller -v --no-minimize-url --trunk trunk --tags tags --nobranches
Running command: git svn init --prefix=svn/ --username=pmuller --no-metadata --no-minimize-url --trunk=trunk --tags=tags https://server3/svn/main/Working\ Files\ and\ Tools/Namwater\ Reval\ Data\ Parsing
Initialized empty Git repository in e:/temp/NamwaterRevalDataParsing/Files/.git/

Running command: git svn fetch
fatal: Not a git repository (or any of the parent directories): .git
Already at toplevel, but .git not found
 at E:\Program Files (x86)\Git/libexec/git-core\git-svn line 342
command failed:
2>&1 git svn fetch
Pieter@PIETER-DESKTOP /E/temp/NamwaterRevalDataParsing
$

It seems these issues are related to the different ways in which git-svn, svn2git, bash and Powershell (or cmd) handle spaces.

Does anybody have any suggestion, fixes or workarounds, other than installing Linux? :-)

pfdevmuller commented 11 years ago

OK so I hacked this into submission by changing migration.rb to wrap all arguments to the git svn command in quotations, and by removing the code substituting spaces with escaped spaces. I've put the patch in a gist here: https://gist.github.com/pfdevmuller/5300352

I also had to change my command line, so the repository URL was to the root of the repo, and the trunk and tags arguments went all the way down to the project folder, like so:

svn2git.bat "https://server3/svn/main" --username pmuller -v --no-minimize-url --trunk "Working Files and Tools/Namwater Reval Data Parsing/trunk" --tags "Working Files and Tools/Namwater Reval Data Parsing/tags" --nobranches

I don't think my hacks will work on Linux? If somebody wants to check, they can submit the code to be merged.

MikeHook commented 11 years ago

It worked better for me when I used %20 in place of the spaces in the address.

garyritchie commented 7 years ago

do%20not%space%20out

Confirming that using %20 works with release. Note that you have to start over by removing the .git folder from the failed attempt before it will work.