threads / discuss / 18965

reviving a git-svn clone

Subject: reviving a git-svn clone

## tl;dr

6 messages between Apr 20, 2009 and Apr 21, 2009.

replies: 5people: 3as markdown or json

martin f krafft· Apr 20, 2009, 10:43 UTC · lore
Hello folks,

The hibernate-script is maintained in SVN, but we've long tracked it with Git at git://git.debian.org/git/collab-maint/hibernate.git .

Unfortunately, I seem to have lost the repository I always used to git-svn-rebase and push new upstream commits to the repository on git.debian.org.

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

alioth:~/hibernate-svnsync|master|% git checkout upstream
alioth:~/hibernate-svnsync|upstream|% git show HEAD | grep git-svn-id
    git-svn-id: svn+ssh://svn.suspend2.net/svn/hibernate-script/trunk@1195 c12ee44c-9ede-0310-94ea-d4716f4f7118
-8<--8<--8<-

So the repository is now cloned and the URL is the same as the one in the HEAD commit message.

But when I try to rebase, I am told:
-8<--8<--8<-
alioth:~/hibernate-svnsync|master|% git svn rebase
Migrating from a git-svn v1 layout...
Data from a previous version of git-svn exists, but
        .git/svn
        (required for this version (1.5.6.5) of git-svn) does not exist.
Done migrating from a git-svn v1 layout
Unable to determine upstream SVN information from working tree history

-8<--8<--8<- (I get the same result with Git 1.6.2.3)

I've spend a bit of time with the code, but I cannot figure out why it has these hiccups. I think it's because git-svn needs a rev-map file in .git/svn/upstream/trunk/.rev_map.c12ee44c-9ede-0310-94ea-d4716f4f7118, which is now gone, but that file is now gone.

Does anyone know how I can revive the git-svn clone? I cannot just reclone, or else all of the commit IDs in the public upstream branch would be rewritten.

Thanks,
-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"alle vorurteile kommen aus den eingeweiden."
                                                 - friedrich nietzsche
 
spamtraps: madduck.bogus@madduck.net
Sam Vilain· Apr 21, 2009, 06:51 UTC · re: martin f krafft · lore

Re: reviving a git-svn clone

On Mon, 2009-04-20 at 12:43 +0200, martin f krafft wrote:
Show 5 quoted lines
> 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:
Show 15 quoted lines
> -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 $_"'
It's a bit hard to test without access to the upstream svn!

Good luck, Sam.

martin f krafft· Apr 21, 2009, 08:14 UTC · re: Sam Vilain · lore

Re: reviving a git-svn clone

also sprach Sam Vilain <sam@vilain.net> [2009.04.21.0851 +0200]:
Show 6 quoted lines
> 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 $_"'

Let me see if I parse this right: you want me to put the same SHA into refs/remotes/upstream/trunk as there is in refs/remotes/origin/upstream (since the upstream branch tracks the trunk)?

> It's a bit hard to test without access to the upstream svn!

Sorry, I should have been more careful. You can access the upstream SVN at http://svn.tuxonice.net/svn/hibernate-script . I am on a train, so I cannot verify that, but the exact URL is listed on the http://svn.tuxonice.net/ website.

One reason why I was a bit hesitant to change the URL from svn+ssh to http was because my study of the code base suggested, that git-svn actually matches the git-svn-id in the last commit message with the URL in the svn-remote config stanza, and recurses the commits parents until it finds a match. The error I am seeing actually seems to occur when git-svn recursed all the way to the first commit without a match.

Then again, I may well have misparsed the Perl code, so feel free to ignore me.

Many thanks,
-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
all of you that believe in telekinetics, raise my hand!
 
spamtraps: madduck.bogus@madduck.net
Deskin Miller· Apr 21, 2009, 09:09 UTC · re: Sam Vilain · lore

Re: reviving a git-svn clone

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
martin f krafft· Apr 21, 2009, 11:58 UTC · re: Deskin Miller · lore

Re: reviving a git-svn clone

also sprach Deskin Miller <deskinm@gmail.com> [2009.04.21.1109 +0200]:
Show 5 quoted lines
> 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 worked nicely, so thanks to you, Sam, and Thomas Rast (who helped on IRC). Here is what I ended up doing:

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 total 204 drwx------ 2 4096 20090421.1013 admin drwx------ 3 4096 20090421.1013 debian drwx------ 2 4096 20090421.1013 init.d drwx------ 2 4096 20090421.1013 scriptlets.d -rw------- 1 21417 20090421.1013 CHANGELOG -rw------- 1 17992 20090421.1013 COPYING -rw------- 1 6902 20090421.1013 README -rw------- 1 1470 20090421.1013 README.xfs -rw------- 1 6891 20090421.1013 SCRIPTLET-API -rw------- 1 2020 20090421.1013 blacklisted-modules -rw------- 1 4004 20090421.1013 common.conf -rw------- 1 310 20090421.1013 disk.conf -rw------- 1 7047 20090421.1013 gen-manpages.sh -rw------- 1 518 20090421.1013 hibernate.conf -rw------- 1 26637 20090421.1013 hibernate.sh -rw------- 1 4165 20090421.1013 hibernate.spec -rw------- 1 13822 20090421.1013 hibernate.vim -rwx------ 1 4664 20090421.1013 install.sh -rw------- 1 79 20090421.1013 logrotate.d-hibernate-script -rwx------ 1 608 20090421.1013 mktarball.sh -rw------- 1 837 20090421.1013 ram.conf -rw------- 1 1288 20090421.1013 suspend2.conf -rw------- 1 345 20090421.1013 sysfs-disk.conf -rw------- 1 289 20090421.1013 sysfs-ram.conf -rw------- 1 8 20090421.1013 tuxonice-binary-signature.bin -rw------- 1 509 20090421.1013 ususpend-both.conf -rw------- 1 501 20090421.1013 ususpend-disk.conf -rw------- 1 1324 20090421.1013 ususpend-ram.conf alioth:~/hibernate-svnsync|master|% git svn init --stdlayout --prefix=upstream/ svn+ssh://svn.suspend2.net/svn/hibernate-script alioth:~/hibernate-svnsync|master|% git update-ref refs/remotes/upstream/trunk refs/remotes/origin/upstream alioth:~/hibernate-svnsync|master|% git show-ref refs/remotes/upstream/trunk refs/remotes/origin/upstream 1784ac6d733527ea65c2e9515df30c7a77d8f90b refs/remotes/origin/upstream 1784ac6d733527ea65c2e9515df30c7a77d8f90b refs/remotes/upstream/trunk alioth:~/hibernate-svnsync|master|% git checkout -b upstream upstream/trunk Switched to a new branch "upstream" alioth:..bernate-svnsync|upstream|% git svn info Rebuilding .git/svn/upstream/trunk/.rev_map.c12ee44c-9ede-0310-94ea-d4716f4f7118 ... r840 = 56b969c867a8480521c25e7f943634a865d4ac33 […] r1195 = 1784ac6d733527ea65c2e9515df30c7a77d8f90b Done rebuilding .git/svn/upstream/trunk/.rev_map.c12ee44c-9ede-0310-94ea-d4716f4f7118 Use of uninitialized value within @_ in localtime at /usr/bin/git-svn line 4277. No such file or directory at /usr/bin/git-svn line 897.

Now I can turn to changing the URL, since upstream wants to drop svn.suspend2.net in favour of svn.tuxonice.net. This does not seem to be as straight-forward as it should be. I hate SVN!

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
god is real, unless declared integer.
                                          (dedicated to gabriel gómez)
 
spamtraps: madduck.bogus@madduck.net
martin f krafft· Apr 21, 2009, 17:06 UTC · re: martin f krafft · lore

switching a git-svn clone to a different URL (was: reviving a git-svn clone)

also sprach martin f krafft <madduck@madduck.net> [2009.04.21.1358 +0200]:
> Now I can turn to changing the URL, since upstream wants to drop
> svn.suspend2.net in favour of svn.tuxonice.net. This does not seem
> to be as straight-forward as it should be. I hate SVN!

Turns out using the --rewrite-root option to 'git svn init' and swapping the URLs later, as described on the wiki [0], is exactly what I needed.

0. http://git.or.cz/gitwiki/GitSvnSwitch
-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"alas, i am dying beyond my means."
                                                        -- oscar wilde
 
spamtraps: madduck.bogus@madduck.net

← back to recent threads