tags:

views:

633

answers:

3
+2  Q: 

git-svn problem

Is it possible to clone a git repository which has more than one revisions? We tried to do it, and after the 1000'th commit it does a GC and exits leaving the clone in a unusable state.

r998 = a5cb4f6a377b0ca80cd95d73b0e32f0552b9cdfd (git-svn)
M trunk/asdf/asdf.java
r999 = a87b06ae8aa497bb28c294b7ff8668ce2e4c8fcc (git-svn)
D tags/sdafasdf/asdfasdf.java
r1000 = 20b383d138499eee4f121079ae059458f3facc94 (git-svn)
Auto packing your repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 18103, done.
Compressing objects:  61% (10590/17116)      7116)   
Compressing objects: 100% (17116/17116), done.
Writing objects: 100% (18103/18103), done.
Total 18103 (delta 9301), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.
root@host:~#

Attempting to continue the checkout by typing the command again results in the following:

root@host:~/repo# git svn clone https://host/svn/repo
Remote ref refs/remote/git-svn is tracked by
  "svn-remote.svn.fetch=:refs/remotes/git-svn"
and
  "svn-remote.svn.fetch=:refs/remotes/git-svn"
Please resolve this ambiguity in your git configuration file before continuing
+1  A: 

Yes. It should work just fine. I cloned the Mono project repository (over 140k revisions) using the following commands:

$ mkdir mono
$ cd mono
$ git init
$ git svn init svn+ssh://[email protected]/source
$ git config svn-remote.svn.fetch trunk/mono:refs/remotes/git-svn/trunk
$ git config svn-remote.svn.branches branches/*/mono:refs/remotes/git-svn/branches/*
$ git config svn-remote.svn.tags tags/*/mono:refs/remotes/git-svn/tags/*
$ git fetch git://repo.or.cz/mono.git refs/heads/master:refs/remotes/git-svn/trunk refs/heads/branches/*:refs/remotes/git-svn/branches/* refs/tags/*:refs/remotes/git-svn/tags/*
$ git reset --hard git-svn/trunk

and everything went ok. Is that similar to what you're doing?

Gonzalo
Lol, thats nothing like what I am doing. That looks way above my git competence level (:
corydoras
All the extra parameters are just to support having all the branches and tags from subversion being different branches in git. You can skip those. No magic involved :)
Gonzalo
+1  A: 

This happened a lot to me. I just re-ran exactly the same git command again and it continued from where it left off. Eventually it gets to the end and everything works.

Edit: If this problem happens when running git svn clone ..., then you want to replace clone with fetch when you rerun the command.

Lachlan
I tried this, and it failed with the following message: error: More than one value for the key svn-remote.svn.fetch: :refs/remotes/git-svn
l0b0
Check the [svn-remote "svn"] section of your .git/config file and make sure the fetch entry (or entries) look ok.
Lachlan
Re-running the command again gives the same error as 'l0b0' has.
corydoras
A: 

Worked out the answer. There must be some sort of bug when using the version of git that comes with ubuntu. The following line appeared twice in the newly created .git/config file:

svn-remote.svn.fetch=:refs/remotes/git-svn
svn-remote.svn.fetch=:refs/remotes/git-svn

Removing the duplicate has allowed me to type a git svn fetch which seems to be continuing the checkout.

corydoras
I think the reason for this is that the command you tried to rerun was "svn clone", which is basically "svn init" followed by "svn fetch". So I should have said "re-run git svn fetch". I had so much trouble with this that I got into the habit of always doing init then fetch by hand.
Lachlan
I think you are right. I have to challenge the idea that it is ok for a git command to put something in the config file that is actually broken. If a new git user accidentally types the wrong command it shouldn't break the repository completely. (Unless break it was what they were trying to do)
corydoras