Skip to content

Instantly share code, notes, and snippets.

@vitkin
Last active December 11, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitkin/4644830 to your computer and use it in GitHub Desktop.
Save vitkin/4644830 to your computer and use it in GitHub Desktop.
Wiki page on how to convert Apache BCEL Subversion repositories to a Git bare repository managed by Gitolite that can still stay in sync with the Subversion repository by doing a "git svn fetch" directly on the Git bare repository. It is intended for a project that uses modified sources from BCEL in order to ease the merging.

How to synchronize with Subversion

By running:

$ svn log —stop-on-copy http://svn.eu.apache.org/repos/asf/commons/proper/bcel

We know that starting revision 1149512 it was moved from “jakarta” to “commons/proper”.

By running:

$ svn log —stop-on-copy http://svn.eu.apache.org/repos/asf/jakarta/bcel@1149511

We learn that the 1st commit was at revision 152684.
We can also open the URL http://svn.eu.apache.org/repos/asf/!svn/bc/1149511/jakarta/bcel to check that revision

To initialize:

$ mkdir apache-commons-bcel
$ cd apache-commons-bcel
$ git svn init --stdlayout --no-minimize-url http://svn.eu.apache.org/repos/asf/commons/proper/bcel
$ git svn init --stdlayout --no-minimize-url -R old http://svn.eu.apache.org/repos/asf/jakarta/bcel
$ vi .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true

[svn-remote "svn"]
        url = http://svn.eu.apache.org/repos/asf/commons/proper/bcel
        fetch = trunk:refs/remotes/svn/trunk
        branches = branches/*:refs/remotes/svn/*
        tags = tags/*:refs/remotes/svn/tags/*

[svn-remote "old"]
        url = http://svn.eu.apache.org/repos/asf/jakarta/bcel
        fetch = trunk:refs/remotes/svn/old
        branches = branches/*:refs/remotes/svn/*
        tags = tags/*:refs/remotes/svn/tags/*

$ git svn fetch -R old -r 152684:1149511
$ git svn fetch -r 1149512:HEAD

If you want to re-create the master from the ‘trunk’ branch

$ git branch -f master remotes/trunk
$ git checkout master
$ for branch in `git branch -a|grep remotes/svn/|sed 's|remotes/svn/||'`; do git branch $branch remotes/svn/$branch; done

If you want to rebase the master on top of the ‘old’ branch’ after you created it from the ‘trunk’.

$ git rebase old

Do some correction to use the file


$ vi doap_bcel.rdf

Keep the Apache Commons lines.

$ git add .
$ git rebase —continue
$ su gitolite -c “cp -R .git /var/lib/gitolite/repositories/j2ee/apache-commons-bcel.git”
$ su gitolite -c “git config —git-dir=/var/lib/gitolite/repositories/j2ee/apache-commons-bcel.git —bool core.bare true”

Change the committer dates to match the author dates:

$ git filter-branch —env-filter ‘GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE’

If you want to re-create the master from the ‘trunk’ again:

$ cd apache-commons-bcel.git
$ git branch -m master master-old
$ git branch master trunk
$ git config receive.denyDeleteCurrent ignore
$ git symbolic-ref HEAD refs/heads/master
$ git branch -D  master-old
$ git config receive.denyDeleteCurrent ignore

To synchronize:

As the gitolite user:


$ cd ~/repositories/apache-commons-bcel.git
$ git svn fetch
$ for branch in `git branch -a|grep remotes/svn/|sed ‘s|remotes/svn/||’`; do git branch $branch remotes/svn/$branch; done

To merge the updated trunk into the master:

$ git checkout trunk
$ git pull
$ git chekout master
$ git merge trunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment