git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: reviving a git-svn clone

From
DMDeskin Miller <deskinm@gmail.com>
Date
Apr 21, 2009, 09:09 UTC
Message-ID
<86d4c5e00904210209v3f1b8fd3t6a991fe44455941@mail.gmail.com>
In-Reply-To
<1240296712.3424.8.camel@maia.lan>
On Mon, Apr 20, 2009 at 23:51, Sam Vilain <sam@vilain.net> wrote:
Show 32 quoted lines
> On Mon, 2009-04-20 at 12:43 +0200, martin f krafft wrote:
>> I am now trying to revive the clone, but git-svn remains "unable to
>> determine the upstream SVN information from the working tree
>> history". This baffles me.
>>
>> Here are my steps:
>
>> -8<--8<--8<-
>> alioth:~|master|% git clone /git/collab-maint/hibernate.git hibernate-svnsync
>> Initialized empty Git repository in /srv/alioth.debian.org/chroot/home/users/madduck/hibernate-svnsync/.git/
>>
>> alioth:~|master|% cd hibernate-svnsync
>>
>> alioth:~/hibernate-svnsync|master|% git branch --no-track upstream origin/upstream
>>
>> alioth:~/hibernate-svnsync|master|% cat >> .git/config <<_eof
>> heredoc> [svn-remote "svn"]
>> heredoc>        url = svn+ssh://svn.suspend2.net/svn/hibernate-script
>> heredoc>        fetch = trunk:refs/remotes/upstream/trunk
>> heredoc>        branches = branches/*:refs/remotes/upstream/*
>> heredoc>        tags = tags/*:refs/remotes/upstream/tags/*
>> heredoc> _eof
>
> for git-svn to resume, it needs the refs all in the right place.  If you
> clone a git-svn repository they will be in the wrong place.
>
> eg for this use case something like this to copy the
> refs/remotes/origin/* refs to refs/remotes/upstream/*:
>
>  git for-each-ref --format="%(refname)" refs/remotes/origin/* |
>     perl -le '$x = $_; $x =~ s{origin}{upstream};
>       system "git update-ref $x $_"'

Sam is on the right track. I got the rev-map to rebuild with the following steps (sufficient, perhaps not all necessary); enter these after you hack .git/config with the svn info.

First, we need the backend .git/svn/.metadata file, populated with the right URL and svn uuid; the uuid follows the URL and revision on log messages:

$ mkdir .git/svn
$ cat > .git/svn/.metadata << EOF
[svn-remote "svn"]
        reposRoot = svn+ssh://svn.suspend2.net/svn
        uuid = c12ee44c-9ede-0310-94ea-d4716f4f7118
EOF

Now, make the remote-tracking branch upstream/trunk at the right commit, and check out a local copy; the commit ID is the latest commit from svn, also known as master^2 (at the time of this writing) if you do a normal git clone from your provided url:

$ git update-ref refs/remotes/upstream/trunk 1784ac6d $ git checkout -b upstream upstream/trunk

Now, do git svn info or your other favourite local command to rebuild the rev-map:

$ git svn info

If you have access to the svn remote, you should be able to avoid hacking config and .metadata entirely by entering

$ git svn init --stdlayout --prefix=upstream/ svn+ssh://svn.suspend2.net/svn/hibernate-script

This doesn't fetch any commits, but will contact the svn server to obtain the uuid. Plus, it's much easier to type. At any rate, the commands prior to that rebuilt the rev-map metadata for me; I can't guarantee the alternative last one, since I can't test it myself.

> It's a bit hard to test without access to the upstream svn!
I concur :)  Hope that straightens things out.
Deskin Miller
P.S. Thanks Dscho for the excellent msysgit package
Previous: martin f krafftNext: martin f krafft
Message 4 of 6 in “reviving a git-svn clone”
  1. martin f krafftApr 20, 2009
  2. Sam VilainApr 21, 2009
  3. martin f krafftApr 21, 2009
  4. Deskin MillerApr 21, 2009
  5. martin f krafftApr 21, 2009
  6. switching a git-svn clone to a different URL (was: reviving a git-svn clone)martin f krafft, Apr 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.