git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] import-tars: Allow per-tar author and commit message.
@ 2009-08-24 17:55 Peter Krefting
  0 siblings, 0 replies; only message in thread
From: Peter Krefting @ 2009-08-24 17:55 UTC (permalink / raw)
  To: git

Instead of having each imported tar ball's commit message be "Imported
from filename.tar", optionally take a commit message from a file
called "filename.tar.msg". The author and committer of the tar ball
can also be overridden by embedding an "Author:" or "Committer:" header
in the .msg file.

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
---
Instead of having a .author and .committer file to override the author
and committer, allow embedding this information in the .msg file, as
suggested by Sam Vilain <sam@vilain.net>.

 contrib/fast-import/import-tars.perl |   38 +++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index 78e40d2..0d59434 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -109,12 +109,44 @@ foreach my $tar_file (@ARGV)
 		$have_top_dir = 0 if $top_dir ne $1;
 	}
 
+	# Optionally read a commit message from <filename.tar>.msg
+	# Add a line on the form "Committer: name <e-mail>" to override
+	# the committer and "Author: name <e-mail>" to override the
+	# author for this tar ball.
+	my $commit_msg = "Imported from $tar_file.";
+	my $this_committer_name = $committer_name;
+	my $this_committer_email = $committer_email;
+	my $this_author_name = $author_name;
+	my $this_author_email = $author_email;
+	if (open MSG, '<', "${tar_file}.msg")
+	{
+		$commit_msg = '';
+		while (<MSG>)
+		{
+			if (/^Committer:\s+([^<>]*)\s+<(.*)>\s*$/i)
+			{
+				$this_committer_name = $1;
+				$this_committer_email = $2;
+			}
+			elsif (/^Author:\s+([^<>]*)\s+<(.*)>\s*$/i)
+			{
+				$this_author_name = $1;
+				$this_author_email = $2;
+			}
+			else
+			{
+				$commit_msg .= $_;
+			}
+		}
+		close MSG;
+	}
+
 	print FI <<EOF;
 commit $branch_ref
-author $author_name <$author_email> $author_time +0000
-committer $committer_name <$committer_email> $commit_time +0000
+author $this_author_name <$this_author_email> $author_time +0000
+committer $this_committer_name <$this_committer_email> $commit_time +0000
 data <<END_OF_COMMIT_MESSAGE
-Imported from $tar_file.
+$commit_msg
 END_OF_COMMIT_MESSAGE
 
 deleteall
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-24 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-24 17:55 [PATCH v2] import-tars: Allow per-tar author and commit message Peter Krefting

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).