threads / discuss / 18317

git-svn: creating tags from a subdirectory of trunk

Subject: git-svn: creating tags from a subdirectory of trunk

## tl;dr

5 messages between Mar 15, 2009 and Mar 17, 2009.

replies: 4people: 3as markdown or json

Tom Huybrechts· Mar 15, 2009, 21:18 UTC · lore
Hi,

I'm trying to setup a git mirror of a svn repository. The tags in this repository are not created trunk it self, but from subdirectories of trunk. The tags and branches are in the standard places. e.g: /trunk/main -> tags/main-1 /trunk/plugins/foo -> tags/foo-1 /trunk/plugins/bar -> tags/bar-1

I run 'git svn clone -s svn-url target'. It starts going over the history nicely until it reaches the first branch. It calls this branch something like tags/tag-name@revision, and starts retrieving the entire project history again from r1. This is repeated for every branch.

I've created a very small standalone shell script that demonstrates the problem:

===== #!/bin/bash

REPO=`pwd`/svn-repo WC=`pwd`/svn-wc svnadmin create $REPO REPO=file://$REPO svn co $REPO $WC SUBDIR=$WC/trunk/subdir

mkdir $WC/tags $WC/trunk $WC/branches $SUBDIR svn add $WC/* svn commit -m "structure" $WC svn cp -m "create a tag" $REPO/trunk/subdir $REPO/tags/1

git svn clone -s $REPO git-repo =====

When you run this, the output of git-svn is:
=====
Initialized empty Git repository in /home/tom/experiment/git-repo/.git/
W: +empty_dir: trunk/subdir
r1 = 3b90e67a4d8e9a2d32d4389b0f6ac93e23f38a46 (trunk)
Found possible branch point:
file:///home/tom/experiment/svn-repo/trunk/subdir =>
file:///home/tom/experiment/svn-repo/tags/1, 1
Initializing parent: tags/1@1
r1 = 0ad93ba4a7f6c43de30ab4dd05161662b75a6adb (tags/1@1)
Found branch parent: (tags/1) 0ad93ba4a7f6c43de30ab4dd05161662b75a6adb
Following parent with do_switch
Successfully followed parent
r2 = ce47fc7b4e21000c84da63ad5f643c18118d1918 (tags/1)
Checked out HEAD:
  file:///home/tom/experiment/svn-repo/tags/1 r2
=====
Note the tags/1@1 and then starting over again from r1.

It's not so bad in this little example, but try this on a repository with 200 tags and 16000 revisions... So my question: is this normal or a bug ? Can I do something to import this repository correctly ?

Thanks,
Tom
Eric Wong· Mar 15, 2009, 23:21 UTC · re: Tom Huybrechts · lore

Re: git-svn: creating tags from a subdirectory of trunk

Tom Huybrechts <tom.huybrechts@gmail.com> wrote:
Show 15 quoted lines
> Hi,
> 
> I'm trying to setup a git mirror of a svn repository.  The tags in
> this repository are not created trunk it self, but from subdirectories
> of trunk. The tags and branches are in the standard places.
> e.g:
> /trunk/main -> tags/main-1
> /trunk/plugins/foo -> tags/foo-1
> /trunk/plugins/bar -> tags/bar-1
> 
> I run 'git svn clone -s svn-url target'. It starts going over the
> history nicely until it reaches the first branch. It calls this branch
> something like tags/tag-name@revision, and starts retrieving the
> entire project history again from r1. This is repeated for every
> branch.
Hi Tom,

This is a known problem with some repositories. My suggestion is to use individual "fetch" directives for each of those tags you want to follow.

The -s/--stdlayout is only for projects that follow the SVN-recommended repository layout exactly and we haven't thought of a generic way to handle those non-standard tags in repos...

-- 
Eric Wong
Tom Huybrechts· Mar 16, 2009, 19:02 UTC · re: Eric Wong · lore

Re: git-svn: creating tags from a subdirectory of trunk

On Mon, Mar 16, 2009 at 12:21 AM, Eric Wong <normalperson@yhbt.net> wrote:
Show 30 quoted lines
> Tom Huybrechts <tom.huybrechts@gmail.com> wrote:
>> Hi,
>>
>> I'm trying to setup a git mirror of a svn repository.  The tags in
>> this repository are not created trunk it self, but from subdirectories
>> of trunk. The tags and branches are in the standard places.
>> e.g:
>> /trunk/main -> tags/main-1
>> /trunk/plugins/foo -> tags/foo-1
>> /trunk/plugins/bar -> tags/bar-1
>>
>> I run 'git svn clone -s svn-url target'. It starts going over the
>> history nicely until it reaches the first branch. It calls this branch
>> something like tags/tag-name@revision, and starts retrieving the
>> entire project history again from r1. This is repeated for every
>> branch.
>
> Hi Tom,
>
> This is a known problem with some repositories.  My suggestion is to
> use individual "fetch" directives for each of those tags you want to
> follow.
>
> The -s/--stdlayout is only for projects that follow the SVN-recommended
> repository layout exactly and we haven't thought of a generic way to
> handle those non-standard tags in repos...
>
> --
> Eric Wong
>
Hi Eric,

The repository I'm trying to convert is that of Hudson. I did some digging in the list archives, and found this came up earlier (2009/01/08). Back then you replied:

""" Alternately, you could just clone the root and have all the branches all over the place in one tree (your eventually working copy will be huge).

  git svn clone https://svn.dev.java.net/svn/hudson
Basically this is the equivalent of:
  svn co https://svn.dev.java.net/svn/hudson

Except you'll have the full history. """

Is that still valid ? That is what I did, and which caused the behaviour I described.

Tom
Eric Wong· Mar 16, 2009, 21:08 UTC · re: Tom Huybrechts · lore

Re: git-svn: creating tags from a subdirectory of trunk

Tom Huybrechts <tom.huybrechts@gmail.com> wrote:
Show 55 quoted lines
> On Mon, Mar 16, 2009 at 12:21 AM, Eric Wong <normalperson@yhbt.net> wrote:
> > Tom Huybrechts <tom.huybrechts@gmail.com> wrote:
> >> Hi,
> >>
> >> I'm trying to setup a git mirror of a svn repository.  The tags in
> >> this repository are not created trunk it self, but from subdirectories
> >> of trunk. The tags and branches are in the standard places.
> >> e.g:
> >> /trunk/main -> tags/main-1
> >> /trunk/plugins/foo -> tags/foo-1
> >> /trunk/plugins/bar -> tags/bar-1
> >>
> >> I run 'git svn clone -s svn-url target'. It starts going over the
> >> history nicely until it reaches the first branch. It calls this branch
> >> something like tags/tag-name@revision, and starts retrieving the
> >> entire project history again from r1. This is repeated for every
> >> branch.
> >
> > Hi Tom,
> >
> > This is a known problem with some repositories.  My suggestion is to
> > use individual "fetch" directives for each of those tags you want to
> > follow.
> >
> > The -s/--stdlayout is only for projects that follow the SVN-recommended
> > repository layout exactly and we haven't thought of a generic way to
> > handle those non-standard tags in repos...
> >
> > --
> > Eric Wong
> >
> 
> Hi Eric,
> 
> The repository I'm trying to convert is that of Hudson. I did some
> digging in the list archives, and found this came up earlier
> (2009/01/08).
> Back then you replied:
> 
> """
> Alternately, you could just clone the root and have all the branches all
> over the place in one tree (your eventually working copy will be huge).
> 
>   git svn clone https://svn.dev.java.net/svn/hudson
> 
> 
> Basically this is the equivalent of:
> 
>   svn co https://svn.dev.java.net/svn/hudson
> 
> Except you'll have the full history.
> """
> 
> Is that still valid ? That is what I did, and which caused the
> behaviour I described.

I did not use the -s/--stdlayout option in my example. But yeah, either way that repository is nasty with git-svn :<

-- 
Eric Wong
Michael J Gruber· Mar 17, 2009, 14:43 UTC · re: Tom Huybrechts · lore

Re: git-svn: creating tags from a subdirectory of trunk

Tom Huybrechts venit, vidit, dixit 15.03.2009 22:18:
Show 15 quoted lines
> Hi,
> 
> I'm trying to setup a git mirror of a svn repository.  The tags in
> this repository are not created trunk it self, but from subdirectories
> of trunk. The tags and branches are in the standard places.
> e.g:
> /trunk/main -> tags/main-1
> /trunk/plugins/foo -> tags/foo-1
> /trunk/plugins/bar -> tags/bar-1
> 
> I run 'git svn clone -s svn-url target'. It starts going over the
> history nicely until it reaches the first branch. It calls this branch
> something like tags/tag-name@revision, and starts retrieving the
> entire project history again from r1. This is repeated for every
> branch.

And I thought *I* had produced sick repos by abusing svn... There are also such niceties as /trunk/trunk/ in there.

The problem is that svn tags are branches (to the same extent that svn branches are branches...) and git svn treats them as such, but the hudson tags contain only subtrees. I think you have two options:

- Convert without tags, and try to assign real git tags later on based
on the output of svn log. (This assumes svn tags have not been abused as
branches.)
- Setup git svn configs for each subproject individually, since the tags
contain only subproject tags.

It seems as though hudson's tags have not been abused as branches, except for some messing with deletes and recreations. So the first approach may be worthwhile.

Michael

← back to recent threads