Question about git-svn import
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
| - dir2The new one is:
<root>
|
|- trunk
| | - dir1
| | - dir2
|- branches
|- tagsNow 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.
Signature · 8 lines
--|------------------------------------------------------ --| 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
Quoted 23 lines · Pascal Obry
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 | - dir2The new one is:
<root> | |- trunk | | - dir1 | | - dir2 |- branches |- tagsNow I want to import this project into Git (using git-svn) as the project won't leave Subversion for the moment. When doing:
Quoted 6 lines
$ 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.
Signature · 3 lines
-Steven Walter <[email protected]> Freedom is the freedom to say that 2 + 2 = 4 B2F1 0ECC E605 7321 E818 7A65 FC81 9777 DC28 9E8F
Quoted 2 lines · Steven Walter
Not sure if this is the best way, but I would recommend cloning into two repositories, then combining them.
I feared that :)
Quoted 8 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.
Signature · 8 lines
--|------------------------------------------------------ --| 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
Hello Pascal,
Pascal Obry schrieb am Tue 18. Dec, 08:10 (+0100):
Quoted 5 lines
Quoted 2 lines · Steven Walter
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.
Quoted 5 lines
Quoted 5 lines
So you already have the newer
changes with the standard layout. You would now:$ git svn init <repo>
Quoted 7 lines
Quoted 3 lines
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.
Signature · 1 line
Die am Lautesten reden, haben stets am wenigsten zu sagen.
Jörg,
Quoted 1 line
It's not as complicated as you might think.
Ok, thanks for the pointers. I'll have a look.
Pascal.
Signature · 8 lines
--|------------------------------------------------------ --| 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,
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.
Signature · 8 lines
--|------------------------------------------------------ --| 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 schrieb am Thu 20. Dec, 17:30 (+0100):
Quoted 6 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
Quoted 8 lines
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 historyIs 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.
Signature · 3 lines
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.
Quoted 5 lines · Jörg Sommer
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.
Signature · 8 lines
--|------------------------------------------------------ --| 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