wiki:WorkingWithGitSVN

Version 11 (modified by raimue (Rainer Müller), 8 years ago) (diff)

Add hint about svn:log

This page is intended to discuss changes required to make it possible to work on the MacPorts base and ports using git-svn.

Most of this comes from a mail on macports-dev from March, 2014:

Getting the initial git svn clone

The Subversion repository is mirrored in three parts:

Subversion URL Git URL
^/trunk git://git.macports.org/macports/trunk.git
^/contrib git://git.macports.org/macports/contrib.git
^/users git://git.macports.org/macports/users.git

The (release) branches for base are not mirrored at all and you cannot work against them with git-svn unless you create your own mirror. The following will cover examples for trunk, but you can use them in the same way for the other mirrored directories.

Getting your initial clone with git-svn:

git clone git://git.macports.org/macports/trunk.git macports-trunk
cd macports-trunk
git svn init https://svn.macports.org/repository/macports/trunk --username=<username>@macports.org
git config svn-remote.svn.fetch :refs/remotes/origin/master

Since the upstream repository is in Subversion, a git pull should create a linear history locally by defaulting to git pull --rebase:

git config branch.master.rebase true

Ignoring files with both svn:ignore and .gitignore

Git uses .gitignore instead of the svn:ignore property of Subversion.

git svn create-ignore

This creates a .gitignore file in each directory that has an equivalent svn:ignore property.

There is currently no way to synchronize changes to .gitignore to the svn:ignore properties. The preferred way should be to update svn:ignore and then re-generate the .gitignore files as shown above. Changes can be made directly on the Subversion repository with this command:

svn pe svn:ignore $(git svn info --url <PATH>)

Known Problems

Editing svn:log revision property needs to be forbidden

As git(-svn) cannot deal with history changes after the revision was synchronized, revision properties may no longer be edited on the Subversion server.

No support for svn:keywords property

The $Id$ keyword can no longer be used.

No support for svn:eol-style property

TODO: do we really need this?

Mapping author names

Git usually displays real names with email addresses instead of plain usernames. A file with that mapping can be used, but has to be generated from MacPortsDevelopers.

curl https://trac.macports.org/wiki/MacPortsDevelopers?format=txt | gawk -F'\\|\\|' \
'/^\|\|[^=]\s*/ { 
    handle = gensub(/\[wiki:([a-z0-9._-]*)\]/, "\\1", 1, gensub(/\s/, "", "g", $2));
    email = handle "@macports.org";
    name = gensub(/^\s*|\s*$/, "", "g", $3);
    if (!match(handle,"nomaintainer|openmaintainer|portmgr")) {
        printf "%s = %s <%s>\n", handle, name, email;
        printf "%s = %s <%s>\n", email, name, email;
    }
}' | sort > AUTHORS.git-svn.txt

The following names in the svn repository are not mapped by the results of this query. Note that this is list is not exhaustive, and the conversions are best guesses.

akira@macports.org = Akira Kitada <akitada@macports.org>
anddam@macports.org = Andrea D'Amore <and.damore@macports.org>
andrea.damore@macports.org = Andrea D'Amore <and.damore@macports.org>
jkh@apple.com = Jordan K. Hubbard <jkh@macports.org>
kvv@apple.com = Kevin Van Vechten <kvv@macports.org>
macsforever2000@macports.org = Frank Schima <mf2k@macports.org>
n3npq@mac.com = Jeff Johnson <n3npq@macports.org>
nobody = CVS2SVN <cvs2svn@localhost.localdomain>
pguyot@kallisys.net = Paul Guyot <pguyot@macports.org>
portindex@macports.org = PortIndex Generator <portindex@macports.org>
rmsfisher@macports.org = Ryan Stonecipher <rmstonecipher@macports.org>
root = Mac OS Forge Admin <admin@macosforge.org>
royliu@macports.org = Roy Liu <royliu@macports.org>
torrey = Torrey Lyons <torrey@opendarwin.org>
uid50019 = Markus W. Weißmann <mww@macports.org>
uid50030 = Toby Peterson <toby@macports.org>
wsanchez@apple.com = Wilfredo Sánchez Vega <wsanchez@apple.com>
wsiegrist@apple.com = William Siegrist <wms@macports.org>

TODO: This has to be applied when updating the Git mirror, as it will be hardcoded in the Git commit object?

TODO: Split base, doc, www, and ports tree

With the current git mirror everyone interested in base is also required to fetch the trees for dports/, doc/ and doc-new/, and www/. Also, all branches for base are missing.

For disk space and usability reasons, a separate repository might be easier to handle, especially when you can just add that to sources.conf. Note we already have contrib/ and users/ as separate repositories.

Given your Git repository, you can use git filter-branch(1) to remove all history but that in a subdirectory. Note that you should do this on a copy of your repository. For example, to split www from the rest of the repository, use

git filter-branch --subdirectory-filter www --prune-empty -- --all