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://
^/contrib git://
^/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:// macports-trunk
cd macports-trunk
git svn init --username=<username>
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 | gawk -F'\\|\\|' \
'/^\|\|[^=]\s*/ { 
    handle = gensub(/\[wiki:([a-z0-9._-]*)\]/, "\\1", 1, gensub(/\s/, "", "g", $2));
    email = handle "";
    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 Kitada <> = Andrea D'Amore <> = Andrea D'Amore <> = Jordan K. Hubbard <> = Kevin Van Vechten <> = Frank Schima <> = Jeff Johnson <>
nobody = CVS2SVN <cvs2svn@localhost.localdomain> = Paul Guyot <> = PortIndex Generator <> = Ryan Stonecipher <>
root = Mac OS Forge Admin <> = Roy Liu <>
torrey = Torrey Lyons <>
uid50019 = Markus W. Weißmann <>
uid50030 = Toby Peterson <> = Wilfredo Sánchez Vega <> = William Siegrist <>

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
Last modified 7 years ago Last modified on Jan 26, 2016, 7:49:47 PM