{"thread":{"id":"10978","subject":"[PATCH] git-svn: add support for pulling author from From: and Signed-off-by:","startedAt":"2007-11-22T13:37:27Z","lastAt":"2007-11-29T07:55:33Z","messageCount":2,"participants":["Andy Whitcroft","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"60686","messageId":"1195739082.0@pinky","threadId":"10978","inReplyTo":null,"subject":"[PATCH] git-svn: add support for pulling author from From: and Signed-off-by:","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":null,"receivedAt":"2007-11-22T13:37:27Z","isPatch":true,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"\nAdd support for pulling the real author of a commit from the From:\nand first Signed-off-by: fields of the SVN commit message.\n\nSigned-off-by: Andy Whitcroft <apw@shadowen.org>\n\n---\n\tThis is a feature that git-svnimport had and I have just\n\tdiscovered that git-svnimport was deleted some time back\n\tbut due to the install strategy I seem to have an old\n\tone in there which I was still using; and so had not noticed\n\tits official removal.  Ouch.\n\n\tPerhaps we should install a \"gone\" stub for things which are\n\tremoved for one release to partly catch this.\n---\n git-svn.perl |   36 +++++++++++++++++++++++++++++-------\n 1 files changed, 29 insertions(+), 7 deletions(-)\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 5b1deea..a99982d 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -80,6 +80,7 @@ my %fc_opts = ( 'follow-parent|follow!' => \\$Git::SVN::_follow_parent,\n \t\t'quiet|q' => \\$_q,\n \t\t'repack-flags|repack-args|repack-opts=s' =>\n \t\t   \\$Git::SVN::_repack_flags,\n+\t\t'use-log-author' => \\$Git::SVN::_use_log_author,\n \t\t%remote_opts );\n \n my ($_trunk, $_tags, $_branches, $_stdlayout);\n@@ -1048,7 +1049,8 @@ use strict;\n use warnings;\n use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent\n             $_repack $_repack_flags $_use_svm_props $_head\n-            $_use_svnsync_props $no_reuse_existing $_minimize_url/;\n+            $_use_svnsync_props $no_reuse_existing $_minimize_url\n+\t    $_use_log_author/;\n use Carp qw/croak/;\n use File::Path qw/mkpath/;\n use File::Copy qw/copy/;\n@@ -1873,11 +1875,17 @@ sub do_git_commit {\n \t\tcroak \"$log_entry->{revision} = $c already exists! \",\n \t\t      \"Why are we refetching it?\\n\";\n \t}\n-\t$ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $log_entry->{name};\n-\t$ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} =\n-\t                                                  $log_entry->{email};\n+\t$ENV{GIT_AUTHOR_NAME} = $log_entry->{name};\n+\t$ENV{GIT_AUTHOR_EMAIL} = $log_entry->{email};\n \t$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_entry->{date};\n \n+\t$ENV{GIT_COMMITTER_NAME} = (defined $log_entry->{commit_name})\n+\t\t\t\t\t\t? $log_entry->{commit_name}\n+\t\t\t\t\t\t: $log_entry->{name};\n+\t$ENV{GIT_COMMITTER_EMAIL} = (defined $log_entry->{commit_email})\n+\t\t\t\t\t\t? $log_entry->{commit_email}\n+\t\t\t\t\t\t: $log_entry->{email};\n+\n \tmy $tree = $log_entry->{tree};\n \tif (!defined $tree) {\n \t\t$tree = $self->tmp_index_do(sub {\n@@ -2165,7 +2173,16 @@ sub make_log_entry {\n \t$log_entry{log} .= \"\\n\";\n \tmy $author = $log_entry{author} = check_author($log_entry{author});\n \tmy ($name, $email) = defined $::users{$author} ? @{$::users{$author}}\n-\t                                               : ($author, undef);\n+\t\t\t\t\t\t       : ($author, undef);\n+\n+\tmy ($commit_name, $commit_email) = ($name, $email);\n+\tif ($_use_log_author) {\n+\t\tif ($log_entry{log} =~ /From:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n+\t\t\t($name, $email) = ($1, $2);\n+        \t} elsif ($log_entry{log} =~ /Signed-off-by:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n+\t\t\t($name, $email) = ($1, $2);\n+\t\t}\n+\t}\n \tif (defined $headrev && $self->use_svm_props) {\n \t\tif ($self->rewrite_root) {\n \t\t\tdie \"Can't have both 'useSvmProps' and 'rewriteRoot' \",\n@@ -2188,23 +2205,28 @@ sub make_log_entry {\n \t\tremove_username($full_url);\n \t\t$log_entry{metadata} = \"$full_url\\@$r $uuid\";\n \t\t$log_entry{svm_revision} = $r;\n-\t\t$email ||= \"$author\\@$uuid\"\n+\t\t$email ||= \"$author\\@$uuid\";\n+\t\t$commit_email ||= \"$author\\@$uuid\";\n \t} elsif ($self->use_svnsync_props) {\n \t\tmy $full_url = $self->svnsync->{url};\n \t\t$full_url .= \"/$self->{path}\" if length $self->{path};\n \t\tremove_username($full_url);\n \t\tmy $uuid = $self->svnsync->{uuid};\n \t\t$log_entry{metadata} = \"$full_url\\@$rev $uuid\";\n-\t\t$email ||= \"$author\\@$uuid\"\n+\t\t$email ||= \"$author\\@$uuid\";\n+\t\t$commit_email ||= \"$author\\@$uuid\";\n \t} else {\n \t\tmy $url = $self->metadata_url;\n \t\tremove_username($url);\n \t\t$log_entry{metadata} = \"$url\\@$rev \" .\n \t\t                       $self->ra->get_uuid;\n \t\t$email ||= \"$author\\@\" . $self->ra->get_uuid;\n+\t\t$commit_email ||= \"$author\\@\" . $self->ra->get_uuid;\n \t}\n \t$log_entry{name} = $name;\n \t$log_entry{email} = $email;\n+\t$log_entry{commit_name} = $commit_name;\n+\t$log_entry{commit_email} = $commit_email;\n \t\\%log_entry;\n }\n \n"},{"id":"61375","messageId":"20071129075533.GC32277@soma","threadId":"10978","inReplyTo":"1195739082.0@pinky","subject":"Re: [PATCH] git-svn: add support for pulling author from From: and Signed-off-by:","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-11-29T07:55:33Z","receivedAt":"2007-11-29T07:55:33Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Andy Whitcroft <apw@shadowen.org> wrote:\n> \n> Add support for pulling the real author of a commit from the From:\n> and first Signed-off-by: fields of the SVN commit message.\n> \n> Signed-off-by: Andy Whitcroft <apw@shadowen.org>\n\nA minor whitespace fix with an Acked patch below.  Thanks.\n\n> ---\n>  git-svn.perl |   36 +++++++++++++++++++++++++++++-------\n>  1 files changed, 29 insertions(+), 7 deletions(-)\n> diff --git a/git-svn.perl b/git-svn.perl\n> index 5b1deea..a99982d 100755\n> @@ -2165,7 +2173,16 @@ sub make_log_entry {\n>  \t$log_entry{log} .= \"\\n\";\n>  \tmy $author = $log_entry{author} = check_author($log_entry{author});\n>  \tmy ($name, $email) = defined $::users{$author} ? @{$::users{$author}}\n> -\t                                               : ($author, undef);\n> +\t\t\t\t\t\t       : ($author, undef);\n> +\n> +\tmy ($commit_name, $commit_email) = ($name, $email);\n> +\tif ($_use_log_author) {\n> +\t\tif ($log_entry{log} =~ /From:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n> +\t\t\t($name, $email) = ($1, $2);\n> +        \t} elsif ($log_entry{log} =~ /Signed-off-by:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n> +\t\t\t($name, $email) = ($1, $2);\n> +\t\t}\n> +\t}\n>  \tif (defined $headrev && $self->use_svm_props) {\n>  \t\tif ($self->rewrite_root) {\n>  \t\t\tdie \"Can't have both 'useSvmProps' and 'rewriteRoot' \",\n\n>From 40fb9135d644f3a1fc47ae9b94ad62ec52b1234b Mon Sep 17 00:00:00 2001\nFrom: Andy Whitcroft <apw@shadowen.org>\nDate: Thu, 22 Nov 2007 13:44:42 +0000\nSubject: [PATCH] git-svn: add support for pulling author from From: and Signed-off-by:\n\nAdd support for pulling the real author of a commit from the From:\nand first Signed-off-by: fields of the SVN commit message.\n\nSigned-off-by: Andy Whitcroft <apw@shadowen.org>\nAcked-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   37 ++++++++++++++++++++++++++++++-------\n 1 files changed, 30 insertions(+), 7 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 640a45a..61f0c1a 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -81,6 +81,7 @@ my %fc_opts = ( 'follow-parent|follow!' => \\$Git::SVN::_follow_parent,\n \t\t'quiet|q' => \\$_q,\n \t\t'repack-flags|repack-args|repack-opts=s' =>\n \t\t   \\$Git::SVN::_repack_flags,\n+\t\t'use-log-author' => \\$Git::SVN::_use_log_author,\n \t\t%remote_opts );\n \n my ($_trunk, $_tags, $_branches, $_stdlayout);\n@@ -1220,7 +1221,8 @@ use strict;\n use warnings;\n use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent\n             $_repack $_repack_flags $_use_svm_props $_head\n-            $_use_svnsync_props $no_reuse_existing $_minimize_url/;\n+            $_use_svnsync_props $no_reuse_existing $_minimize_url\n+\t    $_use_log_author/;\n use Carp qw/croak/;\n use File::Path qw/mkpath/;\n use File::Copy qw/copy/;\n@@ -2060,11 +2062,17 @@ sub do_git_commit {\n \t\tcroak \"$log_entry->{revision} = $c already exists! \",\n \t\t      \"Why are we refetching it?\\n\";\n \t}\n-\t$ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $log_entry->{name};\n-\t$ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} =\n-\t                                                  $log_entry->{email};\n+\t$ENV{GIT_AUTHOR_NAME} = $log_entry->{name};\n+\t$ENV{GIT_AUTHOR_EMAIL} = $log_entry->{email};\n \t$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_entry->{date};\n \n+\t$ENV{GIT_COMMITTER_NAME} = (defined $log_entry->{commit_name})\n+\t\t\t\t\t\t? $log_entry->{commit_name}\n+\t\t\t\t\t\t: $log_entry->{name};\n+\t$ENV{GIT_COMMITTER_EMAIL} = (defined $log_entry->{commit_email})\n+\t\t\t\t\t\t? $log_entry->{commit_email}\n+\t\t\t\t\t\t: $log_entry->{email};\n+\n \tmy $tree = $log_entry->{tree};\n \tif (!defined $tree) {\n \t\t$tree = $self->tmp_index_do(sub {\n@@ -2352,7 +2360,17 @@ sub make_log_entry {\n \t$log_entry{log} .= \"\\n\";\n \tmy $author = $log_entry{author} = check_author($log_entry{author});\n \tmy ($name, $email) = defined $::users{$author} ? @{$::users{$author}}\n-\t                                               : ($author, undef);\n+\t\t\t\t\t\t       : ($author, undef);\n+\n+\tmy ($commit_name, $commit_email) = ($name, $email);\n+\tif ($_use_log_author) {\n+\t\tif ($log_entry{log} =~ /From:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n+\t\t\t($name, $email) = ($1, $2);\n+\t\t} elsif ($log_entry{log} =~\n+\t\t                      /Signed-off-by:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n+\t\t\t($name, $email) = ($1, $2);\n+\t\t}\n+\t}\n \tif (defined $headrev && $self->use_svm_props) {\n \t\tif ($self->rewrite_root) {\n \t\t\tdie \"Can't have both 'useSvmProps' and 'rewriteRoot' \",\n@@ -2375,23 +2393,28 @@ sub make_log_entry {\n \t\tremove_username($full_url);\n \t\t$log_entry{metadata} = \"$full_url\\@$r $uuid\";\n \t\t$log_entry{svm_revision} = $r;\n-\t\t$email ||= \"$author\\@$uuid\"\n+\t\t$email ||= \"$author\\@$uuid\";\n+\t\t$commit_email ||= \"$author\\@$uuid\";\n \t} elsif ($self->use_svnsync_props) {\n \t\tmy $full_url = $self->svnsync->{url};\n \t\t$full_url .= \"/$self->{path}\" if length $self->{path};\n \t\tremove_username($full_url);\n \t\tmy $uuid = $self->svnsync->{uuid};\n \t\t$log_entry{metadata} = \"$full_url\\@$rev $uuid\";\n-\t\t$email ||= \"$author\\@$uuid\"\n+\t\t$email ||= \"$author\\@$uuid\";\n+\t\t$commit_email ||= \"$author\\@$uuid\";\n \t} else {\n \t\tmy $url = $self->metadata_url;\n \t\tremove_username($url);\n \t\t$log_entry{metadata} = \"$url\\@$rev \" .\n \t\t                       $self->ra->get_uuid;\n \t\t$email ||= \"$author\\@\" . $self->ra->get_uuid;\n+\t\t$commit_email ||= \"$author\\@\" . $self->ra->get_uuid;\n \t}\n \t$log_entry{name} = $name;\n \t$log_entry{email} = $email;\n+\t$log_entry{commit_name} = $commit_name;\n+\t$log_entry{commit_email} = $commit_email;\n \t\\%log_entry;\n }\n \n-- \nEric Wong\n"}]}