|Table of Contents|
SVN Users and Git Authors
Both Subversion and Git keep authors names in commits, but those authors differ.
In SVN, the author is being stored is stored as an unversioned revision property
svn:author. Every time a Subversion user makes a commit, SVN creates a new revision and sets this revision
svn:author property to that exact user's name, for example, johndoe:
------------------------------------------------------------------------ r163 | johndoe | 2017-06-07 20:22:15 +0500 (Wed, 07 Jun 2017) | 1 line Changed paths: A /project A /project/branches A /project/tags A /project/trunk initial layout for the project ------------------------------------------------------------------------ ???? $ svn proplist -v --revprop --revision 163 Unversioned properties on revision 163: svn:author johndoe svn:date 2017-06-07T15:22:15.655243Z svn:log initial layout for the project
Those name and email don't relate to an actual username that is used to login to Git repository, they are being set in Git configuration, for example then , they may be set by the commands below:
$ git config --global user.name "John Doe" $ git config --global user.email firstname.lastname@example.org
This exact line then appears as the author name in every commit that John Doe makes.
It worth to mention that Git holds not only author name, but also a committer name:
Pro Git book describes the difference between those names as follows: the author is the person who originally wrote the work, whereas the committer is the person who last applied the work. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit – you as the author, and the core member as the committer.
SubGit translates Git Up to the version 3.3.4 SubGit only used Git author name, so committer name doesn't mean much for the SVN-to-Git translation processso committer name did not mean much.
Since v.3.3.4 SubGit uses committer name for the author mapping by default. Since v.3.3.6 there's also an option to switch back to using author name for the mapping with the core.mapGitCommitter setting:
[core] mapGitCommitter = true|false
When it’s set to true (default), SubGit uses committer's name. Set it to false to make SubGit use author's name.
Note, that SubGit uses authors names to count licensed users, see Licensing manual for details.
All the configuration options reside in SubGit configuration file, that is situated in subgit subdirectory inside a newly created Git repository:
Anchor core.authorsFile core.authorsFile
this option represents a path to the authors mapping file or authors mapping helper program. The path is either relative to the Git repository or absolute. The default value isauthors file is situated in SubGit directory:
[core] authorsFile = subgit/authors.txt
There may be more that one
authorsFileoption set in the file:
[core] authorsFile = subgit/authors.txt authorsFile = /etc/authors.txt
All the mentioned files content is being merged into a full list. If an SVN username appears more than once – only its first occurrence will be applied. For example, if an SVN username
johndoeappears in both authors files:
subgit/authors.txt johndoe = John Doe <email@example.com> … /etc/authors.txt johndoe = John M. Doe <firstname.lastname@example.org>
In this case, the SVN name
johndoeis being mapped to Git name
John Doe <email@example.com>as it appears first in the list.
Automatic Authors Mapping
Anchor AutoMapping AutoMapping
When SubGit starts translation between SVN and Git, it looks for authors mapping files or authors helper programs. If none of them present, it generates the mapping automatically, following these rules for the translation:
Similarly, Git commits that made by John Doe <firstname.lastname@example.org> Git user appears in SVN with John Doe author name.
Anchor AuthorsFile AuthorsFile
The authors mapping file is actually just a text file filled with SVN username - Git author pairs. Each pair maps SVN username to Git author like:
svn_user_name = Git Name <email@example.com>
e.g. For example, a mapping for a user named John Doe, the mapping can be set as: may look like this:
john_doe = John Doe <firstname.lastname@example.org>
Every SVN or Git user that makes commits either to SVN project or to mirrored Git repository is supposed to have the author mapping pair here in the authors file and each author pair must reside Each mapping pair must appear on a new line.
During SVN to Git translation, SubGit takes a SVN revision authors name and search the authors file for a match. If there is a matching line in the file - SubGit uses appropriate Git username to create commit in Git; otherwise, if there is not - SubGit will construct a Git commit author name using automatic mapping. And vice versa - during Git commit to SVN revision translate, SubGit searches the file and use appropriate SVN username to create the SVN revision; if there's no matching pair in the file - automatic mapping is used.Note, that it is possible to map two different SVN usernames to the same Git author - for cases, say, when one team member uses two identities to make commits or some SVN username was renamed some time. In such case there might be such configuration created:searches all specified authors files for a mapping pair. If the matching pair is found, SubGit uses appropriate author name. If there is no match, then SubGit generates author name according to automatic mapping rules.
It is possible to map more than one SVN username to the same Git author:
john_doe = John Doe <email@example.com>
johndoe = John Doe <firstname.lastname@example.org>
Every revision that was made by Revisions that are created either by
john_doe or or
johndoe will be are being translated to Git commit commits with author name
John Doe <john_doe@email@example.com>com>. But note However, when this Git user makes commit in Git and this commit is Git commits that are made by John Doe
<firstname.lastname@example.org> are being translated to SVN , the author on the SVN side will be set to first revision using first SVN username in authros files that matches particular Git name in the authors file. That is if those two authors mapping lines appear in the authors file in that exact order -
john_doe first, then
johndoe - then SVN revision author will always be set to
john_doe when John Doe's Git commits are being translated to SVN –
john_doe in this case.
Similarly, one SVN user username can be mapped to different Git authors, e.g.:
jdoe = John Doe <email@example.com>
jdoe = Jane Doe <firstname.lastname@example.org>
jdoe = James Doe <email@example.com>
and againAgain, every Git commit made by those authors will be translated to SVN with revision author set to
jdoe; but SVN
. SVN revisions made by that
jdoe SVN user will always be by
jdoe is always set to first matching Git user in the
authors file -
John Doe <firstname.lastname@example.org> in this particular case.
Changes made to authors files are being applied immediately, there is no need to restart mirroring or reinstall SubGit.
Scriptable Authors Mapping
In addition to the authors filefiles, there 's is another way to provide establish SVN to Git authors mapping using authors helper program. The authors helper is an executable - script – script or binary - that – that is able to read data from standard input and provide send its work result to the standard output. The data helper reads from input and the data helper provides to output must fulfill certain formatInput and output data must fulfil the following formats:
for Git to Subversion mapping:
Author Name author email OUTPUT: Subversionuser
author Name author email OUTPUT: subversion_user_name
for Subversion to Git mapping:
Subversionusername OUTPUT: Author Name author
subversion_user_name OUTPUT: author Name author email
Every time SubGit finds needs to map an author name during translation, it invokes the authors mapping helper program, passes the name to it and expects the helper to answer with matching author name.
The authors helper program might be extremely useful especially when you have many authors and the authors list is constantly changing - new – new users are being added, names and emails changes and so on. If you use some catalog to store accounts - LDAP– LDAP, Active Directory, OpenID and so forth - you – you can create a script that will gather needed information from the catalog and provide it to SubGit.
During On configuration or installation phase SubGit places simple creates a simple
authors.sh script into subgit/in
samples directory subdirectory. This script doesn't do much useful, it 's just some 'proof of concept' that demonstrates how input data is being read and output data provided.
Depending on what was sent to its input script returns either Git author name and email or SVN short name. It can be extended to, say, receive the data from catalog or database thereby facilitate the authors mappingFor more details on the authors helper see Script-provided authors mapping article.