* [PATCH 1/3] git-svn: add documentation for --use-log-author option.
@ 2008-04-16 1:04 apenwarr
2008-04-16 1:04 ` [PATCH 2/3] git-svn: Add --add-author-from option apenwarr
0 siblings, 1 reply; 12+ messages in thread
From: apenwarr @ 2008-04-16 1:04 UTC (permalink / raw)
To: git; +Cc: Avery Pennarun, Avery Pennarun
From: Avery Pennarun <apenwarr@versabanq.com>
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
---
Documentation/git-svn.txt | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index bec9acc..4ad567a 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -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
--
1.5.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 1:04 [PATCH 1/3] git-svn: add documentation for --use-log-author option apenwarr
@ 2008-04-16 1:04 ` apenwarr
2008-04-16 1:04 ` [PATCH 3/3] git-svn: add documentation for " apenwarr
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: apenwarr @ 2008-04-16 1:04 UTC (permalink / raw)
To: git; +Cc: Avery Pennarun, Avery Pennarun
From: Avery Pennarun <apenwarr@versabanq.com>
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 <apenwarr@gmail.com>
---
git-svn.perl | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index b864b54..b7ad898 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -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/;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] git-svn: add documentation for --add-author-from option.
2008-04-16 1:04 ` [PATCH 2/3] git-svn: Add --add-author-from option apenwarr
@ 2008-04-16 1:04 ` apenwarr
2008-04-16 4:33 ` [PATCH 2/3] git-svn: Add " Junio C Hamano
2008-04-17 4:36 ` Eric Wong
2 siblings, 0 replies; 12+ messages in thread
From: apenwarr @ 2008-04-16 1:04 UTC (permalink / raw)
To: git; +Cc: Avery Pennarun, Avery Pennarun
From: Avery Pennarun <apenwarr@versabanq.com>
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
---
Documentation/git-svn.txt | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 4ad567a..acd77eb 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -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
--
1.5.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 1:04 ` [PATCH 2/3] git-svn: Add --add-author-from option apenwarr
2008-04-16 1:04 ` [PATCH 3/3] git-svn: add documentation for " apenwarr
@ 2008-04-16 4:33 ` Junio C Hamano
2008-04-16 16:46 ` Avery Pennarun
2008-04-17 4:36 ` Eric Wong
2 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2008-04-16 4:33 UTC (permalink / raw)
To: apenwarr; +Cc: git, Avery Pennarun
apenwarr@gmail.com writes:
> From: Avery Pennarun <apenwarr@versabanq.com>
>
> 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?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 4:33 ` [PATCH 2/3] git-svn: Add " Junio C Hamano
@ 2008-04-16 16:46 ` Avery Pennarun
2008-04-16 18:36 ` Junio C Hamano
0 siblings, 1 reply; 12+ messages in thread
From: Avery Pennarun @ 2008-04-16 16:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Avery Pennarun
On 4/16/08, Junio C Hamano <gitster@pobox.com> wrote:
> apenwarr@gmail.com 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 16:46 ` Avery Pennarun
@ 2008-04-16 18:36 ` Junio C Hamano
2008-04-16 18:45 ` Avery Pennarun
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Junio C Hamano @ 2008-04-16 18:36 UTC (permalink / raw)
To: Avery Pennarun; +Cc: Eric Wong, Sam Vilain, git, Avery Pennarun
"Avery Pennarun" <apenwarr@gmail.com> writes:
> On 4/16/08, Junio C Hamano <gitster@pobox.com> wrote:
>> apenwarr@gmail.com 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.
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.
> 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?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 18:36 ` Junio C Hamano
@ 2008-04-16 18:45 ` Avery Pennarun
2008-04-16 19:11 ` Richard Quirk
2008-04-16 19:23 ` Dmitry Potapov
2 siblings, 0 replies; 12+ messages in thread
From: Avery Pennarun @ 2008-04-16 18:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Eric Wong, Sam Vilain, git
On 4/16/08, Junio C Hamano <gitster@pobox.com> wrote:
> 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.
> 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.
> 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.
> 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).
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 18:36 ` Junio C Hamano
2008-04-16 18:45 ` Avery Pennarun
@ 2008-04-16 19:11 ` Richard Quirk
2008-04-16 19:23 ` Dmitry Potapov
2 siblings, 0 replies; 12+ messages in thread
From: Richard Quirk @ 2008-04-16 19:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Avery Pennarun, Eric Wong, Sam Vilain, git, Avery Pennarun
On Wed, Apr 16, 2008 at 8:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 18:36 ` Junio C Hamano
2008-04-16 18:45 ` Avery Pennarun
2008-04-16 19:11 ` Richard Quirk
@ 2008-04-16 19:23 ` Dmitry Potapov
2008-04-16 22:24 ` Sam Vilain
2 siblings, 1 reply; 12+ messages in thread
From: Dmitry Potapov @ 2008-04-16 19:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Avery Pennarun, Eric Wong, Sam Vilain, git, Avery Pennarun
On Wed, Apr 16, 2008 at 11:36:26AM -0700, Junio C Hamano wrote:
>
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 19:23 ` Dmitry Potapov
@ 2008-04-16 22:24 ` Sam Vilain
2008-04-16 22:34 ` Avery Pennarun
0 siblings, 1 reply; 12+ messages in thread
From: Sam Vilain @ 2008-04-16 22:24 UTC (permalink / raw)
To: Dmitry Potapov
Cc: Junio C Hamano, Avery Pennarun, Eric Wong, git, Avery Pennarun
Dmitry Potapov wrote:
> On Wed, Apr 16, 2008 at 11:36:26AM -0700, Junio C Hamano wrote:
>
>> 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.
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 22:24 ` Sam Vilain
@ 2008-04-16 22:34 ` Avery Pennarun
0 siblings, 0 replies; 12+ messages in thread
From: Avery Pennarun @ 2008-04-16 22:34 UTC (permalink / raw)
To: Sam Vilain; +Cc: Dmitry Potapov, Junio C Hamano, Eric Wong, git, Avery Pennarun
On 4/16/08, Sam Vilain <sam@vilain.net> wrote:
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] git-svn: Add --add-author-from option.
2008-04-16 1:04 ` [PATCH 2/3] git-svn: Add --add-author-from option apenwarr
2008-04-16 1:04 ` [PATCH 3/3] git-svn: add documentation for " apenwarr
2008-04-16 4:33 ` [PATCH 2/3] git-svn: Add " Junio C Hamano
@ 2008-04-17 4:36 ` Eric Wong
2 siblings, 0 replies; 12+ messages in thread
From: Eric Wong @ 2008-04-17 4:36 UTC (permalink / raw)
To: apenwarr; +Cc: git, Avery Pennarun
apenwarr@gmail.com wrote:
> From: Avery Pennarun <apenwarr@versabanq.com>
>
> 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 <apenwarr@gmail.com>
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.
--
Eric Wong
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-04-17 4:37 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16 1:04 [PATCH 1/3] git-svn: add documentation for --use-log-author option apenwarr
2008-04-16 1:04 ` [PATCH 2/3] git-svn: Add --add-author-from option apenwarr
2008-04-16 1:04 ` [PATCH 3/3] git-svn: add documentation for " apenwarr
2008-04-16 4:33 ` [PATCH 2/3] git-svn: Add " Junio C Hamano
2008-04-16 16:46 ` Avery Pennarun
2008-04-16 18:36 ` Junio C Hamano
2008-04-16 18:45 ` Avery Pennarun
2008-04-16 19:11 ` Richard Quirk
2008-04-16 19:23 ` Dmitry Potapov
2008-04-16 22:24 ` Sam Vilain
2008-04-16 22:34 ` Avery Pennarun
2008-04-17 4:36 ` Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).