git-svn: add documentation for --use-log-author option.
PATCH 1/3 git-svn: add documentation for --use-log-author option.
From: Avery Pennarun <[email protected]>
--- Documentation/git-svn.txt | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
Documentation/git-svn.txt +4 -0
@@ -61,6 +61,10 @@ COMMANDS Set the 'useSvnsyncProps' option in the [svn-remote] config. --rewrite-root=<URL>;; Set the 'rewriteRoot' option in the [svn-remote] config. +--use-log-author;; + When retrieving svn commits into git (as part of fetch, rebase, or + dcommit operations), look for the first From: or Signed-off-by: line + in the log message and use that as the author string. --username=<USER>;; For transports that SVN handles authentication for (http, https, and plain svn), specify the username. For other
Signature · 1 line
1.5.4.3
PATCH 2/3 git-svn: Add --add-author-from option.
From: Avery Pennarun <[email protected]>
This adds a From: line (based on the commit's author information) when sending to svn. It doesn't add if a From: or Signed-off-by: header already exists for that commit.
This, combined with --use-log-author, can retain the author field of commits through a round trip from git to svn and back.
--- git-svn.perl | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-)
git-svn.perl +13 -1
@@ -82,6 +82,7 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent, 'repack-flags|repack-args|repack-opts=s' => \$Git::SVN::_repack_flags, 'use-log-author' => \$Git::SVN::_use_log_author, + 'add-author-from' => \$Git::SVN::_add_author_from, %remote_opts ); my ($_trunk, $_tags, $_branches, $_stdlayout);
@@ -1009,17 +1010,28 @@ sub get_commit_entry { my ($msg_fh, $ctx) = command_output_pipe('cat-file', $type, $treeish); my $in_msg = 0; + my $author; + my $saw_from = 0; while (<$msg_fh>) { if (!$in_msg) { $in_msg = 1 if (/^\s*$/); + $author = $1 if (/^author (.*>)/); } elsif (/^git-svn-id: /) { # skip this for now, we regenerate the # correct one on re-fetch anyways # TODO: set *:merge properties or like... } else { + if (/^From:/ || /^Signed-off-by:/) { + $saw_from = 1; + } print $log_fh $_ or croak $!; } } + if ($Git::SVN::_add_author_from && defined($author) + && !$saw_from) { + print $log_fh "\nFrom: $author\n" + or croak $!; + } command_close_pipe($msg_fh, $ctx); } close $log_fh or croak $!;
@@ -1246,7 +1258,7 @@ use constant rev_map_fmt => 'NH40'; use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent $_repack $_repack_flags $_use_svm_props $_head $_use_svnsync_props $no_reuse_existing $_minimize_url - $_use_log_author/; + $_use_log_author $_add_author_from/; use Carp qw/croak/; use File::Path qw/mkpath/; use File::Copy qw/copy/;
Signature · 1 line
1.5.4.3
PATCH 3/3 git-svn: add documentation for --add-author-from option.
From: Avery Pennarun <[email protected]>
--- Documentation/git-svn.txt | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
Documentation/git-svn.txt +6 -0
@@ -65,6 +65,12 @@ COMMANDS When retrieving svn commits into git (as part of fetch, rebase, or dcommit operations), look for the first From: or Signed-off-by: line in the log message and use that as the author string. +--add-author-from;; + When committing to svn from git (as part of commit or dcommit + operations), if the existing log message doesn't already have a + From: or Signed-off-by: line, append a From: line based on the + git commit's author string. If you use this, then --use-log-author + will retrieve a valid author string for all commits. --username=<USER>;; For transports that SVN handles authentication for (http, https, and plain svn), specify the username. For other
Signature · 1 line
1.5.4.3
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
In reply to [email protected]Quoted 9 lines · [email protected] wrote:
From: Avery Pennarun <[email protected]>
This adds a From: line (based on the commit's author information) when sending to svn. It doesn't add if a From: or Signed-off-by: header already exists for that commit.
This, combined with --use-log-author, can retain the author field of commits through a round trip from git to svn and back.
Signed-off-by Avery Pennarun <[email protected]>
This seems like a useful feature for SVN projects and I've sometimes wanted it myself. Thanks.
One thing, can you add some tests to ensure this continues working? I don't have lots of time to work on git-svn these days and if I do, I want it to be easy to ensure I'm not breaking things :)
Thanks.
Signature · 1 line
Eric Wong
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
In reply to [email protected]Quoted 5 lines · [email protected] writes:
From: Avery Pennarun <[email protected]>
This adds a From: line (based on the commit's author information) when sending to svn. It doesn't add if a From: or Signed-off-by: header already exists for that commit.
I admit that I do not use git-svn, but I am confused. Where are you adding that "From:"? You grab a commit log message out of git (which does not have such "From:", add such a line at the beginning of the commit message using the authorship information and send the resulting commit log message to svn? Why?
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
Quoted 10 lines · Junio C Hamano
Quoted 3 lines · [email protected] writes:
This adds a From: line (based on the commit's author information) when sending to svn. It doesn't add if a From: or Signed-off-by: header already exists for that commit.
I admit that I do not use git-svn, but I am confused. Where are you
adding that "From:"? You grab a commit log message out of git (which does not have such "From:", add such a line at the beginning of the commit message using the authorship information and send the resulting commit log message to svn? Why?
When git-svn copies a commit from git to svn, svn eats the authorship information; it always sets the svn author field to the username of the person logged into the svn server.
With the (existing) --use-log-author option, git-svn will pull From:
and Signed-off-by: lines from svn's log entries when pulling back into git, which helps with this problem. However, it only works with commits that have a Signed-off-by: or From: already included.
The new option --add-author-from makes sure that every commit going into svn *does* have a From: or a Signed-off-by: by adding one based on the git Author field if it doesn't already exist. Combined with --use-log-author, this reduces the information loss in a round trip through the svn server. (And there's always a round trip, as "git-svn dcommit" throws away your pre-svn commits and replaces them with the commit it has put into, then pulled out of, svn.)
Does that make sense?
Thanks,
Avery
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
Quoted 12 lines · Avery Pennarun
Quoted 10 lines · Junio C Hamano
Quoted 3 lines · [email protected] writes:
This adds a From: line (based on the commit's author information) when sending to svn. It doesn't add if a From: or Signed-off-by: header already exists for that commit.
I admit that I do not use git-svn, but I am confused. Where are you
adding that "From:"? You grab a commit log message out of git (which does not have such "From:", add such a line at the beginning of the commit message using the authorship information and send the resulting commit log message to svn? Why?
Quoted 3 lines
When git-svn copies a commit from git to svn, svn eats the authorship information; it always sets the svn author field to the username of the person logged into the svn server.
Let me rephrase that to see if I understand what you are saying. If you look at the "svn log" output (not "git svn log"), you see that the result of "git-svn dcommit" does not record the same 'author' as git side does; instead it uses whoever ran git-svn to propagate the commit to the SVN side.
Quoted 4 lines
With the (existing) --use-log-author option, git-svn will pull From:
and Signed-off-by: lines from svn's log entries when pulling back into git, which helps with this problem. However, it only works with commits that have a Signed-off-by: or From: already included.
Ah, that is because the way the commit is propagated is (1) you read git commit; (2) you make a corresponding SVN commit using the log message you read in step (1); (3) you read that SVN commit back, and create a _new_ git commit and replace what you read in step (1). The new git commit is marked with the authorship information you obtain from the SVN side, unless the commit log message you read back from the SVN side has these special markers (and you are using the --use-log-author option).
Is that what is happening?
And your solution is to add these markers in step (2).
If that is the case, I understand how and why this would work around the issue. A possible downside with this approach is that such a commit in SVN (from SVN person's point of view) has extra information that is unusual in the log message part (namely "From: ").
It makes me wonder if there is a better way.
For example, CVS honors LOGNAME to allow you to "lie" who the author of a change was, which is the behaviour inherited from RCS. I have to wonder if SVN has a similar mechanism to tell it "Excuse me, but I am just a secretary recording changes for my boss."
But perhaps there isn't and that was why you did it this way (and that is why --use-log-author was invented 5 months ago). And the issue that the commit on the SVN side has unusual (again, from SVN person's point of view) information not in the original commit on the git side might not be so grave, so it probably is Ok.
Eric? Sam?
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
Quoted 7 lines · Junio C Hamano
It makes me wonder if there is a better way.
For example, CVS honors LOGNAME to allow you to "lie" who the author of a change was, which is the behaviour inherited from RCS. I have to wonder if SVN has a similar mechanism to tell it "Excuse me, but I am just a secretary recording changes for my boss."
Yes, there is such a mechanism:
====
Revision Property (revprop)
Just as files can have properties, so can each revision in the repository. Some special revprops are added automatically when the revision is created, namely: svn:date svn:author svn:log which represent the commit date/time, the committer and the log message respectively. These properties can be edited, but they are not versioned, so any change is permanent and cannot be undone.
====
So, it is possible not only set the real author but also date/time. Unfortunately, there is one problem with this approach -- by default, these properties are disabled from modification for security reasons. To enable modification of these properties, the administrator is required to change some hooks. Personally, I have never observed any SVN repository where anyone was granted the right to change them. So, while it is possible, it is impractical.
Dmitry
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
Quoted 21 lines · Dmitry Potapov
Quoted 7 lines · Junio C Hamano
It makes me wonder if there is a better way.
For example, CVS honors LOGNAME to allow you to "lie" who the author of a change was, which is the behaviour inherited from RCS. I have to wonder if SVN has a similar mechanism to tell it "Excuse me, but I am just a secretary recording changes for my boss."
Yes, there is such a mechanism:
====
Revision Property (revprop)Just as files can have properties, so can each revision in the repository. Some special revprops are added automatically when the revision is created, namely: svn:date svn:author svn:log which represent the commit date/time, the committer and the log message respectively. These properties can be edited, but they are not versioned, so any change is permanent and cannot be undone. ====
Quoted 7 lines
So, it is possible not only set the real author but also date/time. Unfortunately, there is one problem with this approach -- by default, these properties are disabled from modification for security reasons. To enable modification of these properties, the administrator is required to change some hooks. Personally, I have never observed any SVN repository where anyone was granted the right to change them. So, while it is possible, it is impractical.
Yes, and in fact with most shared SVN hosting services the users are left with no option to do this.
While there doesn't seem to be a command-line way to do this, it's possible that a commit "editor" making a new commit can create revision properties without being necessarily subject to those restrictions. Possible, but I guess unlikely as it would then be inconsistent.
The usual thing is to dump the extra information in the commit message. Some projects, like Perl, were quite systematic about this and a lot of useful author information is available. In fact, it was saved in the proposed form.
While not the main thrust of this thread, the usual convention for mapping svn committers to names is a project AUTHORS file. This made me wonder whether allowing git-svn to take its author map from the repository, such as from a revision property or a directory property of the root or project would be a good idea.
Sam
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
Quoted 4 lines · Sam Vilain
The usual thing is to dump the extra information in the commit message. Some projects, like Perl, were quite systematic about this and a lot of useful author information is available. In fact, it was saved in the proposed form.
So can we say that you have no objections to my patch? :)
Thanks,
Avery
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
In reply to Junio C HamanoQuoted 5 lines · Junio C Hamano
Let me rephrase that to see if I understand what you are saying. If you look at the "svn log" output (not "git svn log"), you see that the result of "git-svn dcommit" does not record the same 'author' as git side does; instead it uses whoever ran git-svn to propagate the commit to the SVN side.
Yes.
Quoted 7 lines
Ah, that is because the way the commit is propagated is (1) you read git commit; (2) you make a corresponding SVN commit using the log message you read in step (1); (3) you read that SVN commit back, and create a _new_ git commit and replace what you read in step (1). The new git commit is marked with the authorship information you obtain from the SVN side, unless the commit log message you read back from the SVN side has these special markers (and you are using the --use-log-author option).
Correct.
Quoted 6 lines
And your solution is to add these markers in step (2).
If that is the case, I understand how and why this would work around the issue. A possible downside with this approach is that such a commit in SVN (from SVN person's point of view) has extra information that is unusual in the log message part (namely "From: ").
Yes, that is a downside, although it's relatively harmless to us here.
Quoted 4 lines
For example, CVS honors LOGNAME to allow you to "lie" who the author of a change was, which is the behaviour inherited from RCS. I have to wonder if SVN has a similar mechanism to tell it "Excuse me, but I am just a secretary recording changes for my boss."
I'm not sure if such an official mechanism actually exists; I do know that we're writing to the svn repository via ssh and group folder access, so any attempt to prevent faking of usernames is not actually secure.
I'd be happy to use such a method if it exists, although this patch solves my problem too (as well as acknowledging the difference between the "committer" and the "author" as git does; theoretically it might be *better* with this separation).
Quoted 5 lines
But perhaps there isn't and that was why you did it this way (and that is why --use-log-author was invented 5 months ago). And the issue that the commit on the SVN side has unusual (again, from SVN person's point of view) information not in the original commit on the git side might not be so grave, so it probably is Ok.
Especially since it's optional.
Thanks,
Avery
Re: [PATCH 2/3] git-svn: Add --add-author-from option.
In reply to Junio C HamanoQuoted 4 lines · Junio C Hamano
For example, CVS honors LOGNAME to allow you to "lie" who the author of a change was, which is the behaviour inherited from RCS. I have to wonder if SVN has a similar mechanism to tell it "Excuse me, but I am just a secretary recording changes for my boss."
The author is stored as a property of the commit, so you can set alter it with something like svn propset --revprop -r N svn:author NAME REPO_URL providing you have server-side revision property changes enabled.