git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] import-tars: Allow per-tar author and commit message.

From
Peter Krefting <peter@softwolves.pp.se>
Date
Aug 23, 2009, 20:34 UTC
Message-ID
<20090823203640.B195D189B12@perkele>

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

Instead of having each commit have the same author and committer information, optionally read the committer information from a file called "filename.tar.committer" and author from a file called "filename.tar.author".

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
---
I used this (albeit based on a slightly earlier verison of the script)
to generate a better-looking history when importing
http://git.debian.org/?p=crashmail/jamnntpd.git and
http://git.debian.org/?p=crashmail/crashmail.git into Git, using
excerpts from the embedded change history as commit messages.
 contrib/fast-import/import-tars.perl |   42 +++++++++++++++++++++++++++++++--
 1 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index 78e40d2..7aad16f 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -109,12 +109,48 @@ foreach my $tar_file (@ARGV)
 		$have_top_dir = 0 if $top_dir ne $1;
 	}
 
+	# Optionally read a commit message from <filename.tar>.msg
+	my $commit_msg = "Imported from $tar_file.";
+	if (open MSG, '<', "${tar_file}.msg")
+	{
+		$commit_msg = '';
+		while (<MSG>)
+		{
+			$commit_msg .= $_;
+		}
+		close MSG;
+	}
+
+	# Optionally read a committer from <filename.tar>.committer
+	# (first line is name, second line is e-mail address).
+	my $this_committer_name = $committer_name;
+	my $this_committer_email = $committer_email;
+	if (open COMMITTER, '<', "${tar_file}.committer")
+	{
+		($this_committer_name, $this_committer_email) = <COMMITTER>;
+		chomp $this_committer_name;
+		chomp $this_committer_email;
+		close COMMITTER;
+	}
+
+	# Optionally read an author from <filename.tar>.author
+	# (first line is name, second line is e-mail address).
+	my $this_author_name = $author_name;
+	my $this_author_email = $author_email;
+	if (open AUTHOR, '<', "${tar_file}.author")
+	{
+		($this_author_name, $this_author_email) = <AUTHOR>;
+		chomp $this_author_name;
+		chomp $this_author_email;
+		close AUTHOR;
+	}
+
 	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
Next: Nanako Shiraishi
Message 1 of 8 in “import-tars: Allow per-tar author and commit message.”
  1. import-tars: Allow per-tar author and commit message.Peter Krefting, Aug 23, 2009
  2. Nanako ShiraishiAug 23, 2009
  3. Sam VilainAug 23, 2009
  4. Peter KreftingAug 24, 2009
  5. Junio C HamanoAug 24, 2009
  6. Peter KreftingAug 25, 2009
  7. Junio C HamanoAug 25, 2009
  8. Peter KreftingAug 26, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.