threads / discuss / 17306

How to prefix existing svn remotes?

Subject: How to prefix existing svn remotes?

## tl;dr

6 messages between Jan 22, 2009 and Jan 23, 2009.

replies: 5people: 3as markdown or json

Sébastien Mazy· Jan 22, 2009, 17:32 UTC · lore
Hi all,

I created a few months ago a git-svn repository using: git svn clone -s https://my_svn_repo .

wich also created the following remotes:
git branch -r
  branch0
  tags/tag0
  trunk
I would like to prefix theses remotes, so that it shows:
git branch -r
  prefix/branch0
  prefix/tags/tag0
  prefix/trunk

Of course I should have used the -prefix back when creating the repo but it's too late. 'git help svn' doesn't explain how to achieve that and simply editing .git/config to add the missing prefix will cause the next 'git svn fetch' to download again the whole history (which in my case is huge).

Is it possible? Did I miss something obvious?
Cheers,
-- 
Sébastien Mazy
Michael J Gruber· Jan 23, 2009, 11:13 UTC · re: Sébastien Mazy · lore

Re: How to prefix existing svn remotes?

Sébastien Mazy venit, vidit, dixit 22.01.2009 18:32:
Show 26 quoted lines
> Hi all,
> 
> 
> I created a few months ago a git-svn repository using:
> git svn clone -s https://my_svn_repo .
> 
> wich also created the following remotes:
> git branch -r
>   branch0
>   tags/tag0
>   trunk
> 
> I would like to prefix theses remotes, so that it shows:
> git branch -r
>   prefix/branch0
>   prefix/tags/tag0
>   prefix/trunk
> 
> Of course I should have used the -prefix back when creating the repo but
> it's too late. 'git help svn' doesn't explain how to achieve that and
> simply editing .git/config to add the missing prefix will cause the next
> 'git svn fetch' to download again the whole history (which in my case is
> huge).
> 
> 
> Is it possible? Did I miss something obvious?
Yes! Depends!
The following works for me:
0) fetch to make sure you're current (optional)
1) edit .git/config and add the prefix (right hand side of the
refpsecs), or really rename in any way you want
2) rename the existing remote branches in the same way

The next git svn fetch will rebuild the map file (which is fast) but not refetch any svn revisions you already have.

Regarding the renaming: Either I'm dumb or current git branch can't rename git svn branches. I guess it's because they are remotes but not really. I had to resort to git update-ref. I'll look into that.

Michael
Sébastien Mazy· Jan 23, 2009, 12:42 UTC · re: Michael J Gruber · lore

Re: How to prefix existing svn remotes?

Hi Michael,
Thanks for your reply.
On Fri, Jan 23, 2009 at 12:13:18PM +0100, Michael J Gruber wrote:
Show 5 quoted lines
> The following works for me:
> 
> 0) fetch to make sure you're current (optional)
> 1) edit .git/config and add the prefix (right hand side of the
> refpsecs), or really rename in any way you want
OK.
> 2) rename the existing remote branches in the same way

I'm not sure how I can do it. 'trunk' is the only remote-tracking svn branches under .git/refs/. Here is how it looks:

ls -R .git/refs
 .git/refs:  heads  remotes  tags
 .git/refs/heads:  master
 .git/refs/remotes:  trunk
Still, a 'branch0' remote exist:
git show-ref
 refs/heads/master
 refs/remotes/branch0
 refs/remotes/trunk
-- 
Sébastien Mazy
Michael J Gruber· Jan 23, 2009, 13:02 UTC · re: Sébastien Mazy · lore

Re: How to prefix existing svn remotes?

Sébastien Mazy venit, vidit, dixit 23.01.2009 13:42:
Show 29 quoted lines
> Hi Michael,
> 
> Thanks for your reply.
> 
> On Fri, Jan 23, 2009 at 12:13:18PM +0100, Michael J Gruber wrote:
>> The following works for me:
>>
>> 0) fetch to make sure you're current (optional)
>> 1) edit .git/config and add the prefix (right hand side of the
>> refpsecs), or really rename in any way you want
> 
> OK.
> 
>> 2) rename the existing remote branches in the same way
> 
> I'm not sure how I can do it. 'trunk' is the only remote-tracking svn
> branches under .git/refs/. Here is how it looks:
> 
> ls -R .git/refs
>  .git/refs:  heads  remotes  tags
>  .git/refs/heads:  master
>  .git/refs/remotes:  trunk
> 
> Still, a 'branch0' remote exist:
> 
> git show-ref
>  refs/heads/master
>  refs/remotes/branch0
>  refs/remotes/trunk
You can do (bash)
for b in trunk branch0
do
  git update-ref refs/remotes/yournewprefix/$b refs/remotes/$b
  git update-ref -d refs/remotes/$b
done

OTOH, any incarnation of "git -m" (with or without "-r", specifying refs/remotes/trunk, remotes/trunk or trunk) failed.

Michael
Sébastien Mazy· Jan 23, 2009, 17:13 UTC · re: Michael J Gruber · lore

Re: How to prefix existing svn remotes?

On Fri, Jan 23, 2009 at 02:02:31PM +0100, Michael J Gruber wrote:
Show 7 quoted lines
> You can do (bash)
> 
> for b in trunk branch0
> do
>   git update-ref refs/remotes/yournewprefix/$b refs/remotes/$b
>   git update-ref -d refs/remotes/$b
> done
That did the trick. Thank you so much!

By the way, my renamed remote tracking svn branches now show under .git/refs/ as expected.

-- 
Sébastien Mazy
Jakub Narebski· Jan 23, 2009, 17:51 UTC · re: Sébastien Mazy · lore

Re: How to prefix existing svn remotes?

Sébastien Mazy wrote:
> By the way, my renamed remote tracking svn branches now show under
> .git/refs/ as expected.
They were inside file .git/packed-refs
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

← back to recent threads