Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git-svn clone fails "fatal: Not a valid object name"

Tags:

git-svn

Whilst doing git svn clone -s https://svn.example.com/repo/ I received the following output:

r3073 = a6132f3a937b632015e66d694250da9f606b8333 (refs/remotes/trunk)
Found possible branch point: https://svn.example.com/repo/trunk => https://svn.example.com/repo/branches/v1.3, 3073
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
fatal: Not a valid object name refs/remotes/tags/Sync Controllers
cat-file commit refs/remotes/tags/Sync Controllers: command returned error: 128

Running git branch -a gives:

remotes/tags/Sync%20Controllers
remotes/tags/v1.1
remotes/trunk
remotes/v1.2

I think the problem is that "remotes/tags/Sync Controllers" != "remotes/tags/Sync%20Controllers".

like image 271
Benjie Avatar asked Jul 06 '12 15:07

Benjie


4 Answers

The tag on SVN has a space in it, but the tag in git had this space converted to %20 (URL encoded). To solve it just manually add a new tag with the verbatim name:

cd .git/refs/remotes/tags/
mv Sync%20Controllers Sync\ Controllers

Then run the git svn clone command again.

(Normally you'd do this with git tag OLDTAG NEWTAG but git was not allowing me to define a tag with a space in. The tag files are simply text files containing the hash of the relevant commit.)

like image 107
Benjie Avatar answered Oct 23 '22 12:10

Benjie


You may use git-svn server-side alternative, SubGit in order to avoid many of git-svn translation problems.

I'm a SubGit developer and could say that we worked a lot to resolve character translation issues like the one above; in this particular case tag would be translated to a refs/tags/Sync+Controllers tag.

Note also, that git-svn has translated Subversion tag as a branch instead of a tag.

like image 21
Alexander Kitaev Avatar answered Oct 23 '22 11:10

Alexander Kitaev


I ran into this issue today, and considered this branch which contains a pace in it is not important, i just run

git branch -r -d partialPayment%202.4

And re-run git svn fetch It skipped current branch and continue grabbing the next one.

like image 5
Jason.chen Avatar answered Oct 23 '22 10:10

Jason.chen


I'm using git 1.29.2 and getting the issue too. Additionlly it is running into a Windows Server 2016 and git is under cygwin.

Was checking into /GitMigration/.git/svn/refs/remotes/origin, and the folder is there with blank spaces not %20 so nothing to change on it.

However into the packed-refs the tag that is producing the problem does not appears, no name and no hash.

The problem should has another related issue with something else that produce the error, not just this.

Looking into the ./.git/config found a series of repetitions of the following lines:

branches = server/branches/*:refs/remotes/origin/*
tags = server/tags/*:refs/remotes/origin/tags/*

That are producing each time i did run the git-svn clone sentence. So i did remove those from the config file, save it and run again, but this time using git svn fetch, to prevent get again the lines duplicated, and voala !! Problem solved.

like image 1
JRod Avatar answered Oct 23 '22 11:10

JRod