Re: [AD] git-svn and allegro?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2009-01-16, Thomas Fjellstrom <tfjellstrom@xxxxxxxxxx> wrote:
> I hear you might be using git-svn with allegro.. I was wondering what it takes 
> to set that up and work with it.. How do you work with allegro?

Hi Thomas,

I thought others might be interested in this as well.  We should put it
on the web site, too.  Let me know if there are any errors.

The only hard part about using git-svn is indeed the setting up.
Here is a little guide.  You will need the Subversion Perl bindings in
addition to git itself.


The easy way
============

Converting a copy of the SVN repository to git takes a long time.
Luckily for you, I've already done it.  You can download it from 

http://alleg.sourceforge.net/files/git/allegro-git-20090117.tar.bz2
http://alleg.sourceforge.net/files/git/authors.txt

The authors.txt file it maps SVN usernames to author names.  Everyone
who has committed needs to be listed (so you might need to add to it
occasionally).  Don't worry about the phony email addresses.

    % tar jxf allegro-git-20090117.tar.bz2
    % cd allegro.git
    % git config svn.authorsfile /path/to/authors.txt
    % git checkout -f

Now you can do your first update:

    % git svn rebase

For interest's sake, instructions for converting the repository yourself
are at the end of this message.


Using git-svn
=============

Working
-------

Do your work in this workspace, making local commits with git.  I think
the git-svn documentation suggests you leave the 'master' branch
containing only the public changes from SVN, so do your work in another
branch:

    % git checkout -b myfeature
    # hack hack hack
    % git commit -a

You can see all the branches and tags with:

    % git branch -r 


Updating from SVN
-----------------

First make sure there are no uncommitted changes, then run:

    % git svn rebase

Your local changes on the current branch will be put on top of the
public changes.  You can also download and rebase separately, which is
useful for rebasing multiple local branches.

    % git svn fetch
    % git svn rebase -l

If you do have uncommitted changes lying around, you can either make a
temporary commit, which you undo later, or use the `git stash` feature.
I usually do the former as I forget about things I've stashed.
Undoing the top commit is simple:

    % git reset HEAD~1


Publishing changes
------------------

You can publish your local changes to SVN with:

    % git svn dcommit

I usually run `git svn dcommit -n` first just to check it's the expected
number of changes.  `git log` will tell you what the changes are.

Don't feel like you have to publish every local change immediately.
If you leave it for a while you'll probably think of something that you
forgot.  Then you can amend the change locally, saving yourself some
embarrassment (and keeping our SVN history a bit cleaner).

SourceForge's servers aren't the fastest, so it's nice to batch up
changes then let `dcommit` be patient while you do something else.


Cloning the repository
----------------------

Normally you'd use `git clone` to make a copy of a repository, but
unfortunately that won't keep the metadata required for `git-svn`.
Just make a plain copy, say, using rsync.


Finally, if you're new to `git`, here are some of my favourite commands
which you won't find in `svn` (at least, easily):

* git commit --amend
* git rebase -i
* git diff --color-words
* git grep
* git show
* git log -p
* git add -p

Peter


Converting the repository
=========================

This is not strictly necessary, but I recommend mirroring the SVN
repository to the local disk before attempting a conversion.
If something goes wrong you won't have to download everything from
SourceForge again.  The repository is more than 170 MB.

    % SVN_MIRROR=/path_to_store_at/alleg
    % mkdir -p $SVN_MIRROR
    % rsync -c -av alleg.svn.sourceforge.net::svn/alleg/'*' $SVN_MIRROR

Now the actual conversion:

    % mkdir myworkspace
    % cd myworkspace
    % git svn init file://$SVN_MIRROR/allegro \
        --rewrite-root=https://alleg.svn.sourceforge.net/svnroot/alleg \
        --trunk=trunk --branches=branches --tags=tags
    % git config svn.authorsfile /path/to/authors.txt
    % git svn fetch

The last step takes a long time.  Once it's done, just for kicks, check
the size of the git repository.  Remember what it was before?

    % du -sh .git
    25M .git

Yup.






Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/