git svn show-ignore gives error "command returned error: 1"
Asked Answered
S

1

29

I'm trying to migrate a project from SVN to git. This is the command I use:

$ git svn clone http://oursvnserver/ --no-metadata -A ../authors-transform.txt --trunk=path/to/trunk --branches=path/to/branches --tags=path/to/tags . --username=mysvnusername --prefix=origin/

The current directory is the directory that I want to become a repository. authors-transform.txt is most definitely in the right location. The project uses the standard layout, but it does not exist at the root of the repository. (Unfortunately, someone long ago started the practice of just stuffing all projects into the same repository. That's why I specify --trunk, --branches, and --tags.) It seems to check out fine. Then I try to generate an ignore file and get this incredibly cryptic error:

$ git svn show-ignore
config --get svn-remote.svn.fetch :refs/remotes/git-svn$: command returned error: 1

It appears to be running some other command in the process, so I made some guesses:

$ git config --get svn-remote.svn.fetch :refs/remotes/git-svn || echo $?
1
$ git config --get svn-remote.svn.fetch :refs/remotes/git-svn$ || echo $?
1

So maybe I'm guessing right about what command it's calling? But that doesn't really help.

What does this error actually mean? What can I try to resolve it?

Using msysgit 1.9.4.

Shantel answered 12/8, 2014 at 1:4 Comment(0)
S
42

So this is caused by git not being able to find a matching fetch entry in the svn-remote section of the $GIT_DIR/config file. Without an argument to git svn show-ignore, it doesn't know what to look for in that section. (Maybe my tracking isn't set up right?)

To deal with this, you need to first specify which remote you want it to look at:

git svn show-ignore --id=origin/trunk

(Note that I specified the "origin" prefix when performing the clone. Vary your command accordingly.)

Secondly, this still failed with a very similar error for my branches. It worked fine for trunk, but not branches. This is because there was no fetch entry for the branches. To add them, use this command (with adjustments for prefix):

git config --add svn-remote.svn.fetch path/to/branches/branchname:refs/remotes/origin/branchname

To see all the fetch entries and make sure it worked:

git config --get-all svn-remote.svn.fetch

I'm not sure why only an entry for trunk is set in the beginning; maybe I did something wrong with the clone.

Shantel answered 12/8, 2014 at 19:21 Comment(4)
If you still remember this (I know it's three years ago), @jpmc26, what exactly do you mean when you say you specified "origin" when performing the clone? I got it working adding the --id=origin/trunk bit, but I didn't specify anything like this in my clone...Boston
@SvendHansen See the --prefix argument in the question. ;) If you didn't specify it, origin/ might be the default; I'm not sure. But if you specified something else, then obviously you'd need to adjust the commands to account for that.Shantel
Right. Doh! I should probably have looked there. I guess not specifying it just defaults to "origin", which is why it then worked for me :)Boston
For anybody still wondering: I just cloned an SVN repo (standard layout) without --prefix=origin, but for show-ignore, I did have to specify origin/trunk. Without "origin/", I got the same error as before.Darby

© 2022 - 2024 — McMap. All rights reserved.