threads / discuss / 18838

git-svn doesn't recognise trunk as parent of branch

Subject: git-svn doesn't recognise trunk as parent of branch

## tl;dr

7 messages between Apr 12, 2009 and Apr 13, 2009.

replies: 6people: 2as markdown or json

Orestis Markou· Apr 12, 2009, 16:40 UTC · lore
Hello there - this is my first post to this ML, so please be kind!

I have previously used git-svn with great success. However, in this project, the svn repo layout is a bit unusual and I'm having getting git-svn to do the correct thing.

The repository I'm trying to clone is a subdirectory under a huge repo:
http://svn.example.com/projects/trunk/MyProject/Production

which has trunk, branches and tags and a couple of other directories (which I'm not interested in).

Complications so far:
* I don't have read access to the lower directories, only to Production
* Being a part of a big repo, the initial revision is something like  
2000
* trunk, branches, tags where not created in the same revision. trunk  
didn't exist until revision say 2050.
Doing 'git svn init -s http://svn.example.com/projects/trunk/MyProject/Production' 
  produces the following configuration:

[svn-remote "svn"] url = http://svn.example.com/trunk/projects/MyProject/Production fetch = trunk:refs/remotes/trunk branches = trunk/projects/MyProject/Production/branches/*:refs/remotes/* tags = trunk/projects/MyProject/Production/tags/*:refs/remotes/tags/*

Fetching this fetches only trunk and no branches.
Amending the config to be:
[svn-remote "svn"]
	url = http://svn.example.com/trunk/projects/MyProject/Production/
	fetch = trunk:refs/remotes/trunk
	branches = branches/*:refs/remotes/*
	tags = tags/*:refs/remotes/tags/*

and fetching (minor issue - have to start from scratch again), does fetch all commits. However, there is no link between branches and trunk. Using gitk (don't know how else to visualise this) shows branches as having no parent. Indeed, in the fetch messages there is no 'found possible parent' message. Also, when creating new branches in svn, nothing shows up in git until a change happens. Then the branch is created (again, with no parent).

The only case where a correct parent was set was when someone branched *from a branch*. Then the usual 'found possible parent' message appeared, and gitk shows a sane tree.

I'm on Mac OS X, git version 1.6.2.2.471.g6da14 (built from source, master branch). This includes a recent commit that fixed an issue with deep directories in git-svn, (without it I couldn't get the branches anyway), but it doesn't seem to have fixed the problem completely.

Any pointers welcome.

Regards, Orestis -- orestis@orestis.gr http://orestis.gr/

Peter Baumann· Apr 12, 2009, 18:54 UTC · re: Orestis Markou · lore

Re: git-svn doesn't recognise trunk as parent of branch

On Sun, Apr 12, 2009 at 07:40:46PM +0300, Orestis Markou wrote:
Show 61 quoted lines
> Hello there - this is my first post to this ML, so please be kind!
>
> I have previously used git-svn with great success. However, in this  
> project, the svn repo layout is a bit unusual and I'm having getting  
> git-svn to do the correct thing.
>
> The repository I'm trying to clone is a subdirectory under a huge repo:
>
> http://svn.example.com/projects/trunk/MyProject/Production
>
> which has trunk, branches and tags and a couple of other directories  
> (which I'm not interested in).
>
> Complications so far:
>
> * I don't have read access to the lower directories, only to Production
> * Being a part of a big repo, the initial revision is something like  
> 2000
> * trunk, branches, tags where not created in the same revision. trunk  
> didn't exist until revision say 2050.
>
>
> Doing 'git svn init -s 
> http://svn.example.com/projects/trunk/MyProject/Production' produces the 
> following configuration:
>
> [svn-remote "svn"]
> url = http://svn.example.com/trunk/projects/MyProject/Production
> fetch = trunk:refs/remotes/trunk
> branches = trunk/projects/MyProject/Production/branches/*:refs/remotes/*
> tags = trunk/projects/MyProject/Production/tags/*:refs/remotes/tags/*
>
> Fetching this fetches only trunk and no branches.
>
> Amending the config to be:
>
> [svn-remote "svn"]
> 	url = http://svn.example.com/trunk/projects/MyProject/Production/
> 	fetch = trunk:refs/remotes/trunk
> 	branches = branches/*:refs/remotes/*
> 	tags = tags/*:refs/remotes/tags/*
>
>
> and fetching (minor issue - have to start from scratch again), does  
> fetch all commits. However, there is no link between branches and trunk. 
> Using gitk (don't know how else to visualise this) shows branches as 
> having no parent. Indeed, in the fetch messages there is no 'found 
> possible parent' message. Also, when creating new branches in svn, 
> nothing shows up in git until a change happens. Then the branch is 
> created (again, with no parent).
>
> The only case where a correct parent was set was when someone branched  
> *from a branch*. Then the usual 'found possible parent' message  
> appeared, and gitk shows a sane tree.
>
> I'm on Mac OS X, git version 1.6.2.2.471.g6da14 (built from source,  
> master branch). This includes a recent commit that fixed an issue with  
> deep directories in git-svn, (without it I couldn't get the branches  
> anyway), but it doesn't seem to have fixed the problem completely.
>
> Any pointers welcome.

It might be that git svn can't work with this strange repo or with trunk created after the branches (no idea if this is a bug or intentional), but I'll show you a easy way how to fix the git repo after the import by using grafts.

If you have a wrongly connected development (which you are trying to fix) line like the following example:

Time goes from left to right
	1 - 2 - 3 - 5 - 6       branchA
       	        a - b - c - d   trunk
you could fix it by connecting the graph using
	echo a 2 >> .git/info/grafts
to get something like this
	1 - 2 - 3 - 5 - 6       branchA
	      \
       	        a - b - c - d   trunk

Replace 'a' and '2' with the sha1 value of the corresponding commit. The same way you could teach git about merges in svn. To make the changes permantent, use something like

	git filter-branch --tag-name-filter cat -- --all
(Pls. check the manpage, I'm not that familiar with git filter-branch)
-Peter
Orestis Markou· Apr 12, 2009, 19:27 UTC · re: Peter Baumann · lore

Re: git-svn doesn't recognise trunk as parent of branch

Many thanks - I'll try that. I would have to do this for every branch, but it's definitely a major help.

Orestis -- orestis@orestis.gr http://orestis.gr/

On 12 Apr 2009, at 21:54, Peter Baumann wrote:
Show 108 quoted lines
> On Sun, Apr 12, 2009 at 07:40:46PM +0300, Orestis Markou wrote:
>> Hello there - this is my first post to this ML, so please be kind!
>>
>> I have previously used git-svn with great success. However, in this
>> project, the svn repo layout is a bit unusual and I'm having getting
>> git-svn to do the correct thing.
>>
>> The repository I'm trying to clone is a subdirectory under a huge  
>> repo:
>>
>> http://svn.example.com/projects/trunk/MyProject/Production
>>
>> which has trunk, branches and tags and a couple of other directories
>> (which I'm not interested in).
>>
>> Complications so far:
>>
>> * I don't have read access to the lower directories, only to  
>> Production
>> * Being a part of a big repo, the initial revision is something like
>> 2000
>> * trunk, branches, tags where not created in the same revision. trunk
>> didn't exist until revision say 2050.
>>
>>
>> Doing 'git svn init -s
>> http://svn.example.com/projects/trunk/MyProject/Production'  
>> produces the
>> following configuration:
>>
>> [svn-remote "svn"]
>> url = http://svn.example.com/trunk/projects/MyProject/Production
>> fetch = trunk:refs/remotes/trunk
>> branches = trunk/projects/MyProject/Production/branches/*:refs/ 
>> remotes/*
>> tags = trunk/projects/MyProject/Production/tags/*:refs/remotes/tags/*
>>
>> Fetching this fetches only trunk and no branches.
>>
>> Amending the config to be:
>>
>> [svn-remote "svn"]
>> 	url = http://svn.example.com/trunk/projects/MyProject/Production/
>> 	fetch = trunk:refs/remotes/trunk
>> 	branches = branches/*:refs/remotes/*
>> 	tags = tags/*:refs/remotes/tags/*
>>
>>
>> and fetching (minor issue - have to start from scratch again), does
>> fetch all commits. However, there is no link between branches and  
>> trunk.
>> Using gitk (don't know how else to visualise this) shows branches as
>> having no parent. Indeed, in the fetch messages there is no 'found
>> possible parent' message. Also, when creating new branches in svn,
>> nothing shows up in git until a change happens. Then the branch is
>> created (again, with no parent).
>>
>> The only case where a correct parent was set was when someone  
>> branched
>> *from a branch*. Then the usual 'found possible parent' message
>> appeared, and gitk shows a sane tree.
>>
>> I'm on Mac OS X, git version 1.6.2.2.471.g6da14 (built from source,
>> master branch). This includes a recent commit that fixed an issue  
>> with
>> deep directories in git-svn, (without it I couldn't get the branches
>> anyway), but it doesn't seem to have fixed the problem completely.
>>
>> Any pointers welcome.
>
> It might be that git svn can't work with this strange repo or with  
> trunk
> created after the branches (no idea if this is a bug or  
> intentional), but I'll
> show you a easy way how to fix the git repo after the import by  
> using grafts.
>
> If you have a wrongly connected development (which you are trying to  
> fix) line like
> the following example:
>
> Time goes from left to right
>
> 	1 - 2 - 3 - 5 - 6       branchA
>
>       	        a - b - c - d   trunk
>
> you could fix it by connecting the graph using
>
> 	echo a 2 >> .git/info/grafts
>
> to get something like this
>
> 	1 - 2 - 3 - 5 - 6       branchA
> 	      \
>       	        a - b - c - d   trunk
>
> Replace 'a' and '2' with the sha1 value of the corresponding commit.  
> The same
> way you could teach git about merges in svn. To make the changes  
> permantent,
> use something like
>
> 	git filter-branch --tag-name-filter cat -- --all
>
> (Pls. check the manpage, I'm not that familiar with git filter-branch)
>
> -Peter
Orestis Markou· Apr 12, 2009, 23:44 UTC · re: Peter Baumann · lore

Re: git-svn doesn't recognise trunk as parent of branch

That seems to be working - the only extra thing that I needed to do after the rewrite of the history is to update the svn remote branch:

echo $rewritten_history_tip > .git/refs/remotes/svn-branch-name

I would still consider this to be a bug though - it's a perfectly valid svn repo and git-svn should handle it... Is this the correct place to report such issues?

Regards, Orestis -- orestis@orestis.gr http://orestis.gr/

On 12 Apr 2009, at 21:54, Peter Baumann wrote:
Show 108 quoted lines
> On Sun, Apr 12, 2009 at 07:40:46PM +0300, Orestis Markou wrote:
>> Hello there - this is my first post to this ML, so please be kind!
>>
>> I have previously used git-svn with great success. However, in this
>> project, the svn repo layout is a bit unusual and I'm having getting
>> git-svn to do the correct thing.
>>
>> The repository I'm trying to clone is a subdirectory under a huge  
>> repo:
>>
>> http://svn.example.com/projects/trunk/MyProject/Production
>>
>> which has trunk, branches and tags and a couple of other directories
>> (which I'm not interested in).
>>
>> Complications so far:
>>
>> * I don't have read access to the lower directories, only to  
>> Production
>> * Being a part of a big repo, the initial revision is something like
>> 2000
>> * trunk, branches, tags where not created in the same revision. trunk
>> didn't exist until revision say 2050.
>>
>>
>> Doing 'git svn init -s
>> http://svn.example.com/projects/trunk/MyProject/Production'  
>> produces the
>> following configuration:
>>
>> [svn-remote "svn"]
>> url = http://svn.example.com/trunk/projects/MyProject/Production
>> fetch = trunk:refs/remotes/trunk
>> branches = trunk/projects/MyProject/Production/branches/*:refs/ 
>> remotes/*
>> tags = trunk/projects/MyProject/Production/tags/*:refs/remotes/tags/*
>>
>> Fetching this fetches only trunk and no branches.
>>
>> Amending the config to be:
>>
>> [svn-remote "svn"]
>> 	url = http://svn.example.com/trunk/projects/MyProject/Production/
>> 	fetch = trunk:refs/remotes/trunk
>> 	branches = branches/*:refs/remotes/*
>> 	tags = tags/*:refs/remotes/tags/*
>>
>>
>> and fetching (minor issue - have to start from scratch again), does
>> fetch all commits. However, there is no link between branches and  
>> trunk.
>> Using gitk (don't know how else to visualise this) shows branches as
>> having no parent. Indeed, in the fetch messages there is no 'found
>> possible parent' message. Also, when creating new branches in svn,
>> nothing shows up in git until a change happens. Then the branch is
>> created (again, with no parent).
>>
>> The only case where a correct parent was set was when someone  
>> branched
>> *from a branch*. Then the usual 'found possible parent' message
>> appeared, and gitk shows a sane tree.
>>
>> I'm on Mac OS X, git version 1.6.2.2.471.g6da14 (built from source,
>> master branch). This includes a recent commit that fixed an issue  
>> with
>> deep directories in git-svn, (without it I couldn't get the branches
>> anyway), but it doesn't seem to have fixed the problem completely.
>>
>> Any pointers welcome.
>
> It might be that git svn can't work with this strange repo or with  
> trunk
> created after the branches (no idea if this is a bug or  
> intentional), but I'll
> show you a easy way how to fix the git repo after the import by  
> using grafts.
>
> If you have a wrongly connected development (which you are trying to  
> fix) line like
> the following example:
>
> Time goes from left to right
>
> 	1 - 2 - 3 - 5 - 6       branchA
>
>       	        a - b - c - d   trunk
>
> you could fix it by connecting the graph using
>
> 	echo a 2 >> .git/info/grafts
>
> to get something like this
>
> 	1 - 2 - 3 - 5 - 6       branchA
> 	      \
>       	        a - b - c - d   trunk
>
> Replace 'a' and '2' with the sha1 value of the corresponding commit.  
> The same
> way you could teach git about merges in svn. To make the changes  
> permantent,
> use something like
>
> 	git filter-branch --tag-name-filter cat -- --all
>
> (Pls. check the manpage, I'm not that familiar with git filter-branch)
>
> -Peter
Orestis Markou· Apr 12, 2009, 23:58 UTC · re: Orestis Markou · lore

Re: git-svn doesn't recognise trunk as parent of branch

And I also realised that I don't need to rewrite the history itself. I was confused because gitk was caching something and I had to restart it to see the updated info. -- orestis@orestis.gr http://orestis.gr/

On 13 Apr 2009, at 02:44, Orestis Markou wrote:
Show 132 quoted lines
> That seems to be working - the only extra thing that I needed to do  
> after the rewrite of the history is to update the svn remote branch:
>
> echo $rewritten_history_tip > .git/refs/remotes/svn-branch-name
>
> I would still consider this to be a bug though - it's a perfectly  
> valid svn repo and git-svn should handle it... Is this the correct  
> place to report such issues?
>
> Regards,
> Orestis
> --
> orestis@orestis.gr
> http://orestis.gr/
>
>
>
>
> On 12 Apr 2009, at 21:54, Peter Baumann wrote:
>
>> On Sun, Apr 12, 2009 at 07:40:46PM +0300, Orestis Markou wrote:
>>> Hello there - this is my first post to this ML, so please be kind!
>>>
>>> I have previously used git-svn with great success. However, in this
>>> project, the svn repo layout is a bit unusual and I'm having getting
>>> git-svn to do the correct thing.
>>>
>>> The repository I'm trying to clone is a subdirectory under a huge  
>>> repo:
>>>
>>> http://svn.example.com/projects/trunk/MyProject/Production
>>>
>>> which has trunk, branches and tags and a couple of other directories
>>> (which I'm not interested in).
>>>
>>> Complications so far:
>>>
>>> * I don't have read access to the lower directories, only to  
>>> Production
>>> * Being a part of a big repo, the initial revision is something like
>>> 2000
>>> * trunk, branches, tags where not created in the same revision.  
>>> trunk
>>> didn't exist until revision say 2050.
>>>
>>>
>>> Doing 'git svn init -s
>>> http://svn.example.com/projects/trunk/MyProject/Production'  
>>> produces the
>>> following configuration:
>>>
>>> [svn-remote "svn"]
>>> url = http://svn.example.com/trunk/projects/MyProject/Production
>>> fetch = trunk:refs/remotes/trunk
>>> branches = trunk/projects/MyProject/Production/branches/*:refs/ 
>>> remotes/*
>>> tags = trunk/projects/MyProject/Production/tags/*:refs/remotes/ 
>>> tags/*
>>>
>>> Fetching this fetches only trunk and no branches.
>>>
>>> Amending the config to be:
>>>
>>> [svn-remote "svn"]
>>> 	url = http://svn.example.com/trunk/projects/MyProject/Production/
>>> 	fetch = trunk:refs/remotes/trunk
>>> 	branches = branches/*:refs/remotes/*
>>> 	tags = tags/*:refs/remotes/tags/*
>>>
>>>
>>> and fetching (minor issue - have to start from scratch again), does
>>> fetch all commits. However, there is no link between branches and  
>>> trunk.
>>> Using gitk (don't know how else to visualise this) shows branches as
>>> having no parent. Indeed, in the fetch messages there is no 'found
>>> possible parent' message. Also, when creating new branches in svn,
>>> nothing shows up in git until a change happens. Then the branch is
>>> created (again, with no parent).
>>>
>>> The only case where a correct parent was set was when someone  
>>> branched
>>> *from a branch*. Then the usual 'found possible parent' message
>>> appeared, and gitk shows a sane tree.
>>>
>>> I'm on Mac OS X, git version 1.6.2.2.471.g6da14 (built from source,
>>> master branch). This includes a recent commit that fixed an issue  
>>> with
>>> deep directories in git-svn, (without it I couldn't get the branches
>>> anyway), but it doesn't seem to have fixed the problem completely.
>>>
>>> Any pointers welcome.
>>
>> It might be that git svn can't work with this strange repo or with  
>> trunk
>> created after the branches (no idea if this is a bug or  
>> intentional), but I'll
>> show you a easy way how to fix the git repo after the import by  
>> using grafts.
>>
>> If you have a wrongly connected development (which you are trying  
>> to fix) line like
>> the following example:
>>
>> Time goes from left to right
>>
>> 	1 - 2 - 3 - 5 - 6       branchA
>>
>>      	        a - b - c - d   trunk
>>
>> you could fix it by connecting the graph using
>>
>> 	echo a 2 >> .git/info/grafts
>>
>> to get something like this
>>
>> 	1 - 2 - 3 - 5 - 6       branchA
>> 	      \
>>      	        a - b - c - d   trunk
>>
>> Replace 'a' and '2' with the sha1 value of the corresponding  
>> commit. The same
>> way you could teach git about merges in svn. To make the changes  
>> permantent,
>> use something like
>>
>> 	git filter-branch --tag-name-filter cat -- --all
>>
>> (Pls. check the manpage, I'm not that familiar with git filter- 
>> branch)
>>
>> -Peter
>
Peter Baumann· Apr 13, 2009, 07:26 UTC · re: Orestis Markou · lore

Re: git-svn doesn't recognise trunk as parent of branch

On Mon, Apr 13, 2009 at 02:58:45AM +0300, Orestis Markou wrote:
> And I also realised that I don't need to rewrite the history itself. I  
> was confused because gitk was caching something and I had to restart it 
> to see the updated info.

The rewrite is done by git filter-branch and this *will* be necessary if you ever want to clone/push/fetch from/to this heavily grafted repo. Grafts are only repository local and using filter-branch, you could make them permanent.

-Peter
Orestis Markou· Apr 13, 2009, 07:35 UTC · re: Peter Baumann · lore

Re: git-svn doesn't recognise trunk as parent of branch

On 13 Apr 2009, at 10:26, Peter Baumann wrote:
Show 15 quoted lines
> On Mon, Apr 13, 2009 at 02:58:45AM +0300, Orestis Markou wrote:
>> And I also realised that I don't need to rewrite the history  
>> itself. I
>> was confused because gitk was caching something and I had to  
>> restart it
>> to see the updated info.
>
> The rewrite is done by git filter-branch and this *will* be  
> necessary if you
> ever want to clone/push/fetch from/to this heavily grafted repo.  
> Grafts are
> only repository local and using filter-branch, you could make them  
> permanent.
>
> -Peter

Thanks - I understand that. However, this is a git-svn repo, and I don't have a need to do so. The suggestion is to not push or pull between git-svn repos but go through svn - AFAICT, that is.

Orestis

← back to recent threads