threads / discuss / 11324

Question about git-svn import

Subject: Question about git-svn import

## tl;dr

8 messages between Dec 17, 2007 and Dec 21, 2007.

replies: 7people: 3as markdown or json

Pascal Obry· Dec 17, 2007, 17:18 UTC · lore
Hi,

You'll find a script into this message that reproduce what I'll describe below. Basically the Subversion repository add a given structure in the past then rearranged to use the "standard" structure. The former structure was:

   <root>
      |
      | - dir1
      | - dir2
The new one is:
   <root>
      |
      |- trunk
      |    | - dir1
      |    | - dir2
      |- branches
      |- tags

Now I want to import this project into Git (using git-svn) as the project won't leave Subversion for the moment. When doing:

   $ git svn clone -s <repo> <git-repo>

In git-repo we get only the commits done inside <root>/trunk and not the commits done in the former repository.

The question is what is the best way to deal with such a case with git-svn ?
Thanks.

############################ CUT HERE ############################# #!/bin/sh

REP=file://$(pwd)/repo
rm -fr repo co-repo git-repo
svnadmin create repo

svn co $REP co-repo cd co-repo mkdir dir echo file1 > dir/file1 svn add dir dir/file1 svn ci -m "ci1" dir dir/file1

svn mkdir -m "create trunk" $REP/trunk svn mkdir -m "create branches" $REP/branches svn mkdir -m "create tags" $REP/tags

svn move -m "move dir under trunk" $REP/dir $REP/trunk/dir

svn update sleep 2

echo file1 >> trunk/dir/file1 svn ci -m "ci2" trunk/dir/file1

sleep 2 svn update

cd ..

git svn clone -s $REP git-repo ############################ CUT HERE #############################

Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Steven Walter· Dec 18, 2007, 03:48 UTC · re: Pascal Obry · lore

Re: Question about git-svn import

On Mon, Dec 17, 2007 at 06:18:29PM +0100, Pascal Obry wrote:
Show 29 quoted lines
> You'll find a script into this message that reproduce what I'll describe
> below. Basically the Subversion repository add a given structure in the
> past then rearranged to use the "standard" structure. The former
> structure was:
> 
>    <root>
>       |
>       | - dir1
>       | - dir2
> 
> The new one is:
> 
>    <root>
>       |
>       |- trunk
>       |    | - dir1
>       |    | - dir2
>       |- branches
>       |- tags
> 
> Now I want to import this project into Git (using git-svn) as the
> project won't leave Subversion for the moment. When doing:
> 
>    $ git svn clone -s <repo> <git-repo>
> 
> In git-repo we get only the commits done inside <root>/trunk and not the
> commits done in the former repository.
> 
> The question is what is the best way to deal with such a case with git-svn ?

Not sure if this is the best way, but I would recommend cloning into two repositories, then combining them. So you already have the newer changes with the standard layout. You would now:

    $ git svn init <repo>

And only fetch the revisions before the layout change. You could then combine the two repositories using .git/info/grafts and git-rewrite-branch.

-- 
-Steven Walter <stevenrwalter@gmail.com>
Freedom is the freedom to say that 2 + 2 = 4
B2F1 0ECC E605 7321 E818  7A65 FC81 9777 DC28 9E8F 
Pascal Obry· Dec 18, 2007, 07:10 UTC · re: Steven Walter · lore

Re: Question about git-svn import

Steven Walter a écrit :
> Not sure if this is the best way, but I would recommend cloning into two
> repositories, then combining them.  
I feared that :)
Show 8 quoted lines
> So you already have the newer
> changes with the standard layout.  You would now:
> 
>     $ git svn init <repo>
> 
> And only fetch the revisions before the layout change.  You could then
> combine the two repositories using .git/info/grafts and
> git-rewrite-branch.

Hum, looks like something not easy to do (at least for a Git beginner like me) ! Any documentation on this ? Would you mind showing this on the example script I sent ?

Thanks, Pascal.

-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Jörg Sommer· Dec 18, 2007, 15:31 UTC · re: Pascal Obry · lore

Re: Question about git-svn import

Hello Pascal,
Pascal Obry schrieb am Tue 18. Dec, 08:10 (+0100):
Show 5 quoted lines
> Steven Walter a écrit :
> > Not sure if this is the best way, but I would recommend cloning into two
> > repositories, then combining them.  
> 
> I feared that :)
It's not as complicated as you might think.
Show 12 quoted lines
> > So you already have the newer
> > changes with the standard layout.  You would now:
> > 
> >     $ git svn init <repo>
> > 
> > And only fetch the revisions before the layout change.  You could then
> > combine the two repositories using .git/info/grafts and
> > git-rewrite-branch.
> 
> Hum, looks like something not easy to do (at least for a Git beginner
> like me) ! Any documentation on this ? Would you mind showing this on
> the example script I sent ?

I had the same problem. We changed the structure of our SVN repository from /trunk/pkg to /pkg/trunk and git-svn couldn't deal with this.

I used the script posted in http://lists.alioth.debian.org/pipermail/pkg-jed-devel/2007-December/001719.html to do the switch.

Some suggestions:
1. Import both parts into one git repo into their own branches. (use
   --prefix)
2. Use gitk to insprect the history to find bad commits, e.g. empty
   commits or things git-svn imported wrong.
3. Use git-filter-branch with the --parent-filter to join the branches.
HTH, Jörg.
-- 
Die am Lautesten reden, haben stets am wenigsten zu sagen.
Pascal Obry· Dec 19, 2007, 11:29 UTC · re: Jörg Sommer · lore

Re: Question about git-svn import

Jörg,
> It's not as complicated as you might think.
Ok, thanks for the pointers. I'll have a look.
Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Pascal Obry· Dec 20, 2007, 16:30 UTC · re: Jörg Sommer · lore

Re: Question about git-svn import

Jörg,
I have at least one remaining problem.

# Import old trunk into pre/master $ git svn init svn+ssh://myserver --prefix=pre/ --trunk=importfromcvs/trunk $ git svn fetch --revision=9458:10242

# Import new trunk into post/master $ git config svn-remote.svn.fetch trunk/PROJ:refs/remotes/post/trunk $ git svn fetch --revision=11058:11066

# Rewrite post/trunk on top of pre/trunk into merged-master $ git checkout post/trunk $ git checkout -b merged-master $ git-filter-branch --tag-name-filter cat --parent-filter "sed -e 's/^$/-p $(git rev-parse pre/trunk)/'" merged-master

The problem is that at this point I cannot "git svn rebase". Looks like the filter-branch command did break the link between the Subversion repository and the git svn one:

$ git svn rebase Unable to determine upstream SVN information from working tree history

Is there a way around that ?

Thanks, Pascal.

-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Jörg Sommer· Dec 20, 2007, 16:52 UTC · re: Pascal Obry · lore

Re: Question about git-svn import

Pascal Obry schrieb am Thu 20. Dec, 17:30 (+0100):
Show 14 quoted lines
> # Rewrite post/trunk on top of pre/trunk into merged-master
> $ git checkout post/trunk
> $ git checkout -b merged-master
> $ git-filter-branch --tag-name-filter cat --parent-filter "sed -e
> 's/^$/-p $(git rev-parse pre/trunk)/'" merged-master
> 
> The problem is that at this point I cannot "git svn rebase". Looks like
> the filter-branch command did break the link between the Subversion
> repository and the git svn one:
> 
> $ git svn rebase
> Unable to determine upstream SVN information from working tree history
> 
> Is there a way around that ?

According to http://duncan.mac-vicar.com/blog/archives/282 it should help to do something like:

git update-ref refs/remotes/git-svn master find -name .rev_db* | xargs rm

I didn't had this problem, because I did a one‐time import.
Bye, Jörg.
-- 
Die zehn Gebote Gottes enthalten 172 Wörter, die amerikanische
Unabhängigkeitserklärung 300 Wörter, die Verordnung der europäischen
Gemeinschaft über den Import von Karamelbonbons exakt 25911 Wörter.
Pascal Obry· Dec 21, 2007, 13:11 UTC · re: Jörg Sommer · lore

Re: Question about git-svn import

Jörg Sommer a écrit :
Show 5 quoted lines
> According to http://duncan.mac-vicar.com/blog/archives/282 it should help
> to do something like:
> 
> git update-ref refs/remotes/git-svn master
> find -name .rev_db* | xargs rm
Ok, thanks a lot it is working!

Git is a great tool... and the community around it is really helpful. Thanks to all!

Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

← back to recent threads