ChaniBlog











{May 21, 2009}   using git-svn inside an svn repo

last week I set up my git-svn repos for gsoc, and at first all seemed well. but a few days later, svn decided it wasn’t going to update until it had reclaimed the folders I had converted to git. :P silly svn.

see, I have kdelibs and kdebase checked out from svn, but kdelibs/plasma and kdebase/workspace/plasma are git repositories now. svn didn’t like this. I talked to a guy in #svn who insisted this couldn’t be done and I should give the folder back to svn. I wasn’t going to give up so easily, so I talked things over in #kde-devel… there was this –set-depth and –depth thing in svn update, but the documentation was brief and confusing, so that day I settled on having a separate plasma-git folder and editing cmakelists to compile that instead of plasma.

I wasn’t quite happy with this duplication, though, and something in the back of my mind kept coming back to this depth thing… yesterday I had an idea for how I might be able to use it, and today I googled for more information on the flag, and found it, and tested it, and it *does* behave the way I want. :) in fact it’s slightly easier than I expected.

so here’s how you turn kdelibs/plasma into a git repo without breaking svn for the rest of kdelibs:

cd kdelibs;
mv plasma plasma-svn; #do check for uncommitted data before deleting it
svn up --depth=empty plasma;

now svn will ignore plasma (and plasma-svn unless you explicitly update that). if you don’t have a gitsvn repo yet you can create it in there (git svn clone, if you use a revision # it must be one that touched that part of svn). if you’ve already got a git repo started, you can move it in like so:

mv plasma/.svn plasma-git/;
rmdir plasma;
mv plasma-git plasma

and from then on, you’ll have a hybrid repository. svn up will happily ignore plasma, so remember to git svn rebase it after you svn up. :)



rakuco says:

Awesome! I can finally delete kdeutils/ark-svn and start svn up’ing kdeutils again :)



Harald says:

Maybe this is the time to post my quick gitinsidesvn script. I’ve been using it whenever I have a svn checkout. but want one of the folders to be checked out with git-svn, without having it download enormous amount of svn commit logs. It’s very easy, but it’s surprisingly easy to forget the routine for actually doing this…. Here it is:

#!/bin/bash

if [ -z $1 ]
then
echo gitinsidesvn: missing argument
echo Usage: gitinsidesvn name-of-subfolder
exit 1
fi

SVNFOLDER=`svn info| grep URL | perl -pe ‘s/URL: //’`
LASTCHANGED=`svn info $SVNFOLDER/$1 | grep ‘Last Changed Rev’ | perl -pe ‘s/Last Changed Rev: //’`

echo SVN folder is detected as $SVNFOLDER
echo Last changed revision is detected as $LASTCHANGED
echo Press ENTER to proceed
read

git svn clone -r$LASTCHANGED $SVNFOLDER/$1 $1
cd $1
git svn fetch



SomeGuy says:

@Harald

Not sure it makes a whole lot of difference, but I’d replace both of those perl calls with “cut -d’ ‘ -f2”



[…] to take more than a few hours. I’ve accumulated several of these git-svn repos now (often within svn) and I’ve been getting more comfortable working with git, so I’ve started performing […]



Comments are closed.

et cetera
%d bloggers like this: