threads / discuss / 11183

git-svn branch naming question

Subject: git-svn branch naming question

## tl;dr

13 messages between Dec 8, 2007 and Dec 9, 2007.

replies: 12people: 5as markdown or json

Miklos Vajna· Dec 8, 2007, 01:04 UTC · lore
hi,

i'm using git-svn for projects where i don't just want to commit to trunk but to other branches, too.

for example:
git-svn clone -s svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build ooo-build

then i have a local 'master' branch and all the other branches are local branches.

so, when i want to work in the ooo-build-2-3 branch, i do a:
git checkout -b ooo-build-2-3 ooo-build-2-3
but when i do a git svn rebase, i get:
warning: refname 'ooo-build-2-3' is ambiguous.
what am i doing wrong?

in fact i suspect that in case i would use some other branch name, like simply '2-3' then i could get rid of this warning, but that's the problem with using the equivalent name of the remote branch when working in a branch locally?

probably i miss some parameter to git-svn clone so that it would prefix the refs with some 'origin'?

thanks,
- VMiklos
Peter Baumann· Dec 8, 2007, 10:59 UTC · re: Miklos Vajna · lore

Re: git-svn branch naming question

On Sat, Dec 08, 2007 at 02:04:38AM +0100, Miklos Vajna wrote:
Show 21 quoted lines
> hi,
> 
> i'm using git-svn for projects where i don't just want to commit to
> trunk but to other branches, too.
> 
> for example:
> 
> git-svn clone -s svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build ooo-build
> 
> then i have a local 'master' branch and all the other branches are local
> branches.
> 
> so, when i want to work in the ooo-build-2-3 branch, i do a:
> 
> git checkout -b ooo-build-2-3 ooo-build-2-3
> 
> but when i do a git svn rebase, i get:
> 
> warning: refname 'ooo-build-2-3' is ambiguous.
> 
> what am i doing wrong?
Try using 'git svn rebase remotes/ooo-build-2-3'.

git-svn should produce its branches under refs/remotes/* and your local branches are under refs/heads/*.

By using 'git checkout -b ooo-build-2-3 ooo-build-2-3' you created refs/heads/ooo-build-2-3 as a copy of refs/remotes/ooo-build-2-3 and now using only ooo-build-2-3 is ambigious. (at least in some cases where git won't take refs/heads/ooo-build-2-3)

Show 6 quoted lines
> 
> in fact i suspect that in case i would use some other branch name, like
> simply '2-3' then i could get rid of this warning, but that's the
> problem with using the equivalent name of the remote branch when working
> in a branch locally?
> 
See above.
> probably i miss some parameter to git-svn clone so that it would prefix
> the refs with some 'origin'?
Look up  --prefix in the manpage for git-svn.
-Peter
Miklos Vajna· Dec 8, 2007, 14:14 UTC · re: Peter Baumann · lore

Re: git-svn branch naming question

On Sat, Dec 08, 2007 at 11:59:01AM +0100, Peter Baumann <waste.manager@gmx.de> wrote:
> Look up  --prefix in the manpage for git-svn.
great, --prefix is what i missed.
a related question: is it possible to avoid even the "remotes" prefix?

it could be useful when creating an incremental import of an svn repo. (ie when using git-svn as a replacement of git-svnimport.)

so after the clone, one will see all the svn branches as a remote branch, since they will be local (and not remote) ones in the mirror repo.

thanks,
- VMiklos
Peter Baumann· Dec 8, 2007, 16:56 UTC · re: Miklos Vajna · lore

Re: git-svn branch naming question

On Sat, Dec 08, 2007 at 03:14:49PM +0100, Miklos Vajna wrote:
Show 10 quoted lines
> On Sat, Dec 08, 2007 at 11:59:01AM +0100, Peter Baumann <waste.manager@gmx.de> wrote:
> > Look up  --prefix in the manpage for git-svn.
> 
> great, --prefix is what i missed.
> 
> a related question: is it possible to avoid even the "remotes" prefix?
> 
> it could be useful when creating an incremental import of an svn repo.
> (ie when using git-svn as a replacement of git-svnimport.)
> 
git svn init --stdlayout creates this entry in your .git/config per default
  [svn-remote "svn"]
        url = https://url/to/your/svn/repo
        fetch = trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*
You could change this to
  [svn-remote "svn"]
        url = https://url/to/your/svn/repo
        fetch = trunk:refs/remotes/origin/trunk
        branches = branches/*:refs/remotes/origin/*
        tags = tags/*:refs/remotes/origin/tags/*
to get what --prefix origin would do.
 On the other hand you could forget completly the remote part by specifying
  [svn-remote "svn"]
        url = https://url/to/your/svn/repo
        fetch = trunk:refs/heads/trunk
        branches = branches/*:refs/heads/*
        tags = tags/*:refs/heads/tags/*

but I advice you to not do this. refs/remotes has a special meaning in git, e.g. you can't commit directly to it (which makes sense, because it only tracks the state of the remote repo. On the other hand remote branches won't get cloned per default.)

Side note, if you want to track only some branches, or if you have a strange svn layout, you could use something like this:

  [svn-remote "svn"]
        url = https://url/to/your/svn/repo
        fetch = trunk:refs/remotes/origin/trunk
        fetch = branches/branchA:refs/remotes/origin/branchA
        fetch = branches/branchB:refs/remotes/origin/branchB
	...
-Peter
Miklos Vajna· Dec 8, 2007, 23:52 UTC · re: Peter Baumann · lore

Re: git-svn branch naming question

On Sat, Dec 08, 2007 at 05:56:57PM +0100, Peter Baumann <waste.manager@gmx.de> wrote:
Show 12 quoted lines
>  On the other hand you could forget completly the remote part by specifying
> 
>   [svn-remote "svn"]
>         url = https://url/to/your/svn/repo
>         fetch = trunk:refs/heads/trunk
>         branches = branches/*:refs/heads/*
>         tags = tags/*:refs/heads/tags/*
> 
> but I advice you to not do this. refs/remotes has a special meaning in git,
> e.g.  you can't commit directly to it (which makes sense, because it only
> tracks the state of the remote repo. On the other hand remote branches won't
> get cloned per default.)

yes, that's exactly what i want to do - in case the target is to convert an svn repo to a git one (and i need git-svn since git-svnimport is to be removed in 1.5.4)

thanks,
- VMiklos
Miklos Vajna· Dec 9, 2007, 02:05 UTC · re: Miklos Vajna · lore

Re: git-svn branch naming question

On Sun, Dec 09, 2007 at 12:52:48AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:
Show 14 quoted lines
> >   [svn-remote "svn"]
> >         url = https://url/to/your/svn/repo
> >         fetch = trunk:refs/heads/trunk
> >         branches = branches/*:refs/heads/*
> >         tags = tags/*:refs/heads/tags/*
> > 
> > but I advice you to not do this. refs/remotes has a special meaning in git,
> > e.g.  you can't commit directly to it (which makes sense, because it only
> > tracks the state of the remote repo. On the other hand remote branches won't
> > get cloned per default.)
> 
> yes, that's exactly what i want to do - in case the target is to convert
> an svn repo to a git one (and i need git-svn since git-svnimport is to
> be removed in 1.5.4)
hm, this seem to be not-working for me.
after "git svn init -s url" i edited the config:
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build
        fetch = trunk:refs/master
        branches = branches/*:refs/*
        tags = tags/*:refs/tags/*
and wanted to fetch the revisions, but actually
$ git svn fetch

does not fetch any revisions. (yes, it does once i put back the "remotes" prefix). is this a bug? :)

thanks,
- VMiklos
Björn Steinbrink· Dec 9, 2007, 02:13 UTC · re: Miklos Vajna · lore

Re: git-svn branch naming question

On 2007.12.09 03:05:10 +0100, Miklos Vajna wrote:
> On Sun, Dec 09, 2007 at 12:52:48AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:
> > >   [svn-remote "svn"]
> > >         url = https://url/to/your/svn/repo
> > >         fetch = trunk:refs/heads/trunk
                                 ^^^^^
> > >         branches = branches/*:refs/heads/*
                                         ^^^^^
> > >         tags = tags/*:refs/heads/tags/*
                                 ^^^^^
>         url = svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build
>         fetch = trunk:refs/master
>         branches = branches/*:refs/*
>         tags = tags/*:refs/tags/*
Just a guess, but this seems pretty headless ;-)
Björn
Show 9 quoted lines
> and wanted to fetch the revisions, but actually
> 
> $ git svn fetch
> 
> does not fetch any revisions. (yes, it does once i put back the
> "remotes" prefix). is this a bug? :)
> 
> thanks,
> - VMiklos
Miklos Vajna· Dec 9, 2007, 02:25 UTC · re: Björn Steinbrink · lore

Re: git-svn branch naming question

On Sun, Dec 09, 2007 at 03:13:36AM +0100, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
Show 6 quoted lines
> >         url = svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build
> >         fetch = trunk:refs/master
> >         branches = branches/*:refs/*
> >         tags = tags/*:refs/tags/*
> 
> Just a guess, but this seems pretty headless ;-)
oh, right. here is my fixed config:
[svn-remote "svn"]
        url = svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build
        fetch = trunk:refs/heads/master
        branches = branches/*:refs/heads/*
        tags = tags/*:refs/tags/*
git svn fetch still does not seem to do anything :S
thanks,
- VMiklos
Eric Wong· Dec 9, 2007, 02:26 UTC · re: Miklos Vajna · lore

Re: git-svn branch naming question

Miklos Vajna <vmiklos@frugalware.org> wrote:
Show 38 quoted lines
> On Sun, Dec 09, 2007 at 12:52:48AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:
> > >   [svn-remote "svn"]
> > >         url = https://url/to/your/svn/repo
> > >         fetch = trunk:refs/heads/trunk
> > >         branches = branches/*:refs/heads/*
> > >         tags = tags/*:refs/heads/tags/*
> > > 
> > > but I advice you to not do this. refs/remotes has a special meaning in git,
> > > e.g.  you can't commit directly to it (which makes sense, because it only
> > > tracks the state of the remote repo. On the other hand remote branches won't
> > > get cloned per default.)
> > 
> > yes, that's exactly what i want to do - in case the target is to convert
> > an svn repo to a git one (and i need git-svn since git-svnimport is to
> > be removed in 1.5.4)
> 
> hm, this seem to be not-working for me.
> 
> after "git svn init -s url" i edited the config:
> 
> $ cat .git/config
> [core]
>         repositoryformatversion = 0
>         filemode = true
>         bare = false
>         logallrefupdates = true
> [svn-remote "svn"]
>         url = svn+ssh://vmiklos@svn.gnome.org/svn/ooo-build
>         fetch = trunk:refs/master
>         branches = branches/*:refs/*
>         tags = tags/*:refs/tags/*
> 
> and wanted to fetch the revisions, but actually
> 
> $ git svn fetch
> 
> does not fetch any revisions. (yes, it does once i put back the
> "remotes" prefix). is this a bug? :)

I'm not sure if it's considered a "bug", but that's just the way it is at the moment. I can't remember why, but I did make git-svn force the presence of the "remotes/" prefix in all refs it writes to...

-- 
Eric Wong
Miklos Vajna· Dec 9, 2007, 02:36 UTC · re: Eric Wong · lore

Re: git-svn branch naming question

On Sat, Dec 08, 2007 at 06:26:24PM -0800, Eric Wong <normalperson@yhbt.net> wrote:
> I'm not sure if it's considered a "bug", but that's just the
> way it is at the moment.  I can't remember why, but I did
> make git-svn force the presence of the "remotes/" prefix
> in all refs it writes to...

okay, i see. one problem: git-svnimport is to be removed and (afaik) the supposed way is to use git-svn instead. what is the supposed way to use git-svn to convert an svn repo to a git one if the method i tried is not working?

(if the branches are fetched to "remotes/" then they won't be visible when one clones the converted repo)

thanks,
- VMiklos
Eric Wong· Dec 9, 2007, 03:26 UTC · re: Miklos Vajna · lore

Re: git-svn branch naming question

Miklos Vajna <vmiklos@frugalware.org> wrote:
Show 13 quoted lines
> On Sat, Dec 08, 2007 at 06:26:24PM -0800, Eric Wong <normalperson@yhbt.net> wrote:
> > I'm not sure if it's considered a "bug", but that's just the
> > way it is at the moment.  I can't remember why, but I did
> > make git-svn force the presence of the "remotes/" prefix
> > in all refs it writes to...
> 
> okay, i see. one problem: git-svnimport is to be removed and (afaik) the
> supposed way is to use git-svn instead. what is the supposed way to use
> git-svn to convert an svn repo to a git one if the method i tried is not
> working?
> 
> (if the branches are fetched to "remotes/" then they won't be visible
> when one clones the converted repo)

I'm pretty sure the reasoning behind "remotes/" being forced by git-svn was to prevent users from shooting themselves in the foot, since committing to those remote refs will break both git-svn fetch and dcommit...

Heck, the entire "remotes/" idea started because a git-svn user made the mistake of committing to the remote tracking branch directly:

  http://thread.gmane.org/gmane.comp.version-control.git/16869/focus=16875

I'll consider accepting a patch to lift that restriction (but still use the "remotes/" by default, of course).

Also, it's possible to fetch them after editing .git/config a little:
  Harvey Harrison's "[RFC] Mirroring svn" post has a good example
  on how to do it.
  http://mid.gmane.org/1196922153.10408.101.camel@brick

Perhaps git-clone could gain the ability to clone refs/remotes/ as-is without an extra step?

-- 
Eric Wong
Harvey Harrison· Dec 9, 2007, 05:16 UTC · re: Eric Wong · lore

Re: git-svn branch naming question

On Sat, 2007-12-08 at 19:26 -0800, Eric Wong wrote:
> 
> Perhaps git-clone could gain the ability to clone refs/remotes/ as-is
> without an extra step?
> 
Something in the spirit of --mirror perhaps?  
--mirror-remotes sounds about right
Harvey
Miklos Vajna· Dec 9, 2007, 19:36 UTC · re: Eric Wong · lore

Re: git-svn branch naming question

On Sat, Dec 08, 2007 at 07:26:08PM -0800, Eric Wong <normalperson@yhbt.net> wrote:
> Perhaps git-clone could gain the ability to clone refs/remotes/ as-is
> without an extra step?

well, what i did for now is to use 2 repos. i use git-svn to create a regular git-svn repo from svn, then an other one to create a regular git repo from the git-svn one. this has one benefit: git-svn requires a working tree, but i definitely want to publish only a bare repo. so here is what i have in the bare repo's config:

[remote "origin"]
        url = /path/to/git-svn/repo
        fetch = +refs/remotes/origin/tags/*:refs/tags/*
        fetch = +refs/remotes/origin/trunk:refs/heads/master
        fetch = +refs/remotes/origin/*:refs/heads/*

then a simple git fetch will do what i need. i'm not entirely sure this is the right think to do, but works for me :)

thanks,
- VMiklos

← back to recent threads