wiki:WorkingWithGitSVN

Version 3 (modified by neverpanic (Clemens Lang), 9 years ago) (diff)

Older SVN commits use the handle without the @macports.org suffix; sort output before piping to file.

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

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

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, alls branches for base are missing.

This is not about disk space as a git clone with full history actually takes less space than a Subversion working copy, but 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.