www-infrastructure-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: [scm] Making a public git mirror of an Apache project
Date Sun, 20 Jul 2008 06:57:30 GMT

On Sat, Jul 12, 2008 at 3:24 PM, Jukka Zitting <jukka.zitting@gmail.com> wrote:
> Currently we only enable git-svn use for committers (authenticated
> https on svn.eu), so I looked at how to make a git mirror that could
> be used by external contributors.

After some more experimentation I've come up with a much improved
setup that includes full version histories for not only the project
trunk but also all tags and branches. I also figured a way to make
copies of the remote tracking branches created by git-svn available to
downstream git clones based on the git-svn clone. With this setup it's
possible to create a git mirror of a project that allows git users to
access the entire project history without the long (often hours)
initial git-svn fetch. For example, making a git clone of the entire
Ant history takes just a few minutes.

Here's the sequence of commands I use to prepare a git-svn clone of an
Apache project. Note that I'm making the git-svn clone available to
external clients both through gitweb and git-daemon.

    SVN_URL=... # https://svn.eu... URL of a project (below trunk,tags,branches)
    GIT_DIR=... # Path to the bare git directory for the git-svn clone
    GIT_URL=... # The URL at which the git repository is served by git-daemon
    DESCRIPTION=... # Full name of the project

    export GIT_DIR
    git svn init --stdlayout "$SVN_URL"
    git config gitweb.owner "The Apache Software Foundation"
    git config gitweb.url "$GIT_URL"
    echo "$DESCRIPTION" > "$GIT_DIR/description"
    touch "$GIT_DIR/git-daemon-export-ok"

Once the git-svn clone has been prepared, I use the following commands
to update it:

    GIT_DIR=... # Path to the bare git directory for the git-svn clone
    AUTHORS=... # Path to the authors file
    export GIT_DIR

    git svn fetch --authors-file "$AUTHORS" --log-window-size=10000

    # Make the git master branch always track the svn trunk
    git update-ref refs/heads/master refs/remotes/trunk

    # Copy all other remote branches (svn branches and tags) to normal
git branches
    git for-each-ref refs/remotes | cut -d / -f 3- | grep -v -x trunk
| grep -v @ |
        while read ref
        git update-ref "refs/heads/$ref" "refs/remotes/$ref"

    # Prune branches or tags that have been removed in svn
    git for-each-ref refs/heads | cut -d / -f 3- | grep -v -x master |
        while read ref
        git rev-parse "refs/remotes/$ref" > /dev/null 2>&1 ||
            git update-ref -d "refs/heads/$ref" "refs/heads/$ref"

    git gc --auto

With this setup (and standard configurations for gitweb and
git-daemon) I've configured git-svn clones of a few representative
Apache codebases and made them available at
http://jukka.zitting.name/git/ (gitweb) and
git://jukka.zitting.name/<project>.git (git-daemon). These mirrors are
automatically updated daily. If you're interested, you can browse the
project histories on the gitweb interface or clone a project using
"git clone git://jukka.zitting.name/<project>.git" for local
inspection. Note that these git mirrors are highly experimental and
may be discontinued or recreated at any time.

The script to make the mirrored clones has run for a few days now, and
it'll probably take another day before the remaining big codebases
(Cocoon and httpd) are done. After the initial setup it'll be easy to
keep the mirrors up to date. Ping me if you're interested in seeing
other Apache codebases mirrored.


Jukka Zitting

View raw message