[LLVMdev] git-svn authorship

Mehdi Amini mehdi.amini at apple.com
Fri Jan 16 18:11:50 PST 2015


> On Jan 16, 2015, at 5:35 PM, Ronan Keryell <ronan at keryell.fr> wrote:
> 
>>>>>> On Fri, 16 Jan 2015 15:19:57 -0800, Greg Fitzgerald <garious at gmail.com> said:
> 
>    Erik> I am surprised noone has mentioned the one of the biggest
>    Erik> advantages of Git which is proper author attribution for
>    Erik> non-core and drive-by patch contributors.
> 
>    Greg> From what I can make of the git-svn docs, that LLVM committers
>    Greg> be adding a "From: <email>" field to commit messages instead
>    Greg> of "Patch by <name>".  If the original author is already in
>    Greg> the git commit, you can generate the "From: <email>" field in
>    Greg> the SVN commit message with:
> 
>    Greg>     git svn --add-author-from --use-log-author dcommit
> 
> 
>    Greg> From the git-svn docs:
> 
>    Greg> --use-log-author
> 
>    Greg> When retrieving svn commits into Git (as part of fetch,
>    Greg> rebase, or dcommit operations), look for the first From: or
>    Greg> Signed-off-by: line in the log message and use that as the
>    Greg> author string.
> 
>    Greg> --add-author-from
> 
>    Greg> When committing to svn from Git (as part of commit-diff,
>    Greg> set-tree or dcommit operations), if the existing log message
>    Greg> doesn’t already have a From: or Signed-off-by: line, append a
>    Greg> From:line based on the Git commit’s author string. If you use
>    Greg> this, then --use-log-author will retrieve a valid author
>    Greg> string for all commits.
> 
>    Greg> https://www.kernel.org/pub/software/scm/git/docs/git-svn.html
> 
> That is interesting. To be tested!
> 
> But as I said in my previous message, I think that would require the
> committer has some specific access right on the svn server to override
> the name that is normally got from the authentication protocol. This is
> to be double-checked.

When you do "git svn dcommit --add-author-from” the git commit is locally changed with the svn commiter as author of the git commit author, and the original author is added in the commit *description*. This is oblivious to svn.
Later when you import this SVN history into git, the --use-log-author tells git to reconstruct the commit author not from the svn author but by looking into the svn commit description, searching for the “From:” line that was added.

So, no need to have any specific access right :)

For example, you can test it yourself now. I just committed r226360 this way, and locally before git svn commit I had:

commit 5a5c3976d8a856ba2294ad87c30ef91814092662
Author: Fiona Glaser <fglaser at apple.com>
Date:   Thu Jan 15 18:05:56 2015

and it was magically turned into:

commit 45a0cf6f6304320a48b783c5ffbca2a404e5532f
Author: mehdi_amini <mehdi_amini at 91177308-0d34-0410-b5e6-96231b3b80d8>
Date:   Fri Jan 16 17:35:56 2015

Locally you can create a git at the previous svn revision:

$ git svn clone  http://llvm.org/svn/llvm-project/llvm/trunk -r 226358
$ cd trunk

And updating to get my commit:

$ git svn rebase --use-log-author
$ git show HEAD
commit b3723c0d5fbb93d42d410bf2bff395ce00dc8eb2
Author: Fiona Glaser <fglaser at apple.com>
Date:   Fri Jan 16 17:35:56 2015




> But perhaps putting this kind of burden in the
> git-svn syntax on the svn committers would motivate them to move to
> git... :-)



git config svn.addAuthorFrom true
git config svn.useLogAuthor true

Enjoy.

Mehdi

PS: now if it was used to sync the github repo it would be perfect, who’s in charge?



More information about the llvm-dev mailing list