2

I am trying to convert a svn repo to Git. I've done the standard Git svn clone <url> however it stops around a certain point.

These are the commands I ran:

java -jar ../svn-migration-scripts.jar authors <svn-repo-url> > authors.txt
mkdir repo && cd repo
git svn init --prefix="" --stdlayout <svn-repo-url> 
git config svn.authorsfile <authors.txt path>
git svn fetch

The error that comes out is:

fatal: Unable to create 'C:/Users/user1/migrate/proj1/.git\svn\refs\remotes\https;C:\Program Files\Git\index.lock': 
Invalid argument write-tree: command returned error:128

I'm on Windows 10. I'm not understanding what the error is and how to fix it.

GitHelp
  • 21
  • 4
  • Welcome to Stackoverflow, have you read this ? https://stackoverflow.com/questions/1356233/fatal-git-write-tree-error-building-trees – mike Jul 22 '20 at 22:08
  • Thank you! Yes I have, the accepted solution there does not work for me. @mike – GitHelp Jul 22 '20 at 22:21
  • 2
    Something has gone wrong in the git-svn code - it generated a file name with two `C:` parts. The second colon is a forbidden character and is causing the immediate problem, but the whole string is wrong: it should be `...\svn\refs\remotes\\.lock` for instance. I don't have Windows and have not actually used git-svn like this so I don't know what triggered the problem. – torek Jul 22 '20 at 23:33
  • Like torek, Ihaven't used git-svn, but was looking at this question for inspiration https://stackoverflow.com/questions/55814947/incomplete-svn-commit-histories-with-git-svn. This question shows commands being run as well as the error that comes out, can you add the commands that were run to the question. – mike Jul 23 '20 at 10:28
  • @mike I have updated the original post. – GitHelp Jul 23 '20 at 20:43

1 Answers1

0

I had the same issue. The problem was that some SVN revisions were trying to create directories with colon characters in them. That is an invalid character in Windows filenames, and that is messing up the path handling code somewhere inside git-svn.

The solution is to clone the repo, but skipping the offending revision. For example if revisions 21 and 22 have invalid paths, first clone up to revision 20 and then fetch from revision 23 to the end :

git svn clone -s -r1:20 https://path.to/some/repo/ target_directory
cd target_directory
git svn fetch -r 23:HEAD

Or you can also first run git svn init and then run 2 separate fetch commands.

git-svn manages to bridge the gap and rebuilds the history over the missing revisions.

vivi
  • 123
  • 2
  • 6