All of lore.kernel.org
 help / color / mirror / Atom feed
From: apenwarr@gmail.com
To: git@vger.kernel.org
Cc: Avery Pennarun <apenwarr@versabanq.com>,
	Avery Pennarun <apenwarr@gmail.com>
Subject: [PATCH 2/3] git-svn: Add --add-author-from option.
Date: Tue, 15 Apr 2008 21:04:17 -0400	[thread overview]
Message-ID: <1208307858-31039-2-git-send-email-apenwarr@gmail.com> (raw)
In-Reply-To: <1208307858-31039-1-git-send-email-apenwarr@gmail.com>

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

  reply	other threads:[~2008-04-16  1:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-16  1:04 [PATCH 1/3] git-svn: add documentation for --use-log-author option apenwarr
2008-04-16  1:04 ` apenwarr [this message]
2008-04-16  1:04   ` [PATCH 3/3] git-svn: add documentation for --add-author-from option 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208307858-31039-2-git-send-email-apenwarr@gmail.com \
    --to=apenwarr@gmail.com \
    --cc=apenwarr@versabanq.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.