{"thread":{"id":"20832","subject":"[PATCH v5] import-tars: Allow per-tar author and commit message.","startedAt":"2009-09-03T12:15:00Z","lastAt":"2009-09-03T12:15:00Z","messageCount":1,"participants":["Peter Krefting"],"isPatch":true,"patchVersion":5,"patchTotal":null},"messages":[{"id":"122354","messageId":"20090903122004.67A502FC20@perkele","threadId":"20832","inReplyTo":null,"subject":"[PATCH v5] import-tars: Allow per-tar author and commit message.","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2009-09-03T12:15:00Z","receivedAt":"2009-09-03T12:15:00Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"If the \"--metainfo=<ext>\" option is given on the command line, a file\ncalled \"<filename.tar>.<ext>\" will be used to create the commit message\nfor \"<filename.tar>\", instead of using \"Imported from filename.tar\".\n\nThe author and committer of the tar ball can also be overridden by\nembedding an \"Author:\" or \"Committer:\" header in the metainfo file.\n\nSigned-off-by: Peter Krefting <peter@softwolves.pp.se>\n---\nFixed script to allow an empty line to stop parsing message for\nheader lines, and fixed indentation style to match the rest of the\nscript.\n\n contrib/fast-import/import-tars.perl |   50 +++++++++++++++++++++++++++++++---\n 1 files changed, 46 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 78e40d2..a909716 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -8,9 +8,20 @@\n ##  perl import-tars.perl *.tar.bz2\n ##  git whatchanged import-tars\n ##\n+## Use --metainfo to specify the extension for a meta data file, where\n+## import-tars can read the commit message and optionally author and\n+## committer information.\n+##\n+##  echo 'This is the commit message' > myfile.tar.bz2.msg\n+##  perl import-tars.perl --metainfo=msg myfile.tar.bz2\n \n use strict;\n-die \"usage: import-tars *.tar.{gz,bz2,Z}\\n\" unless @ARGV;\n+use Getopt::Long;\n+\n+my $metaext = '';\n+\n+die \"usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,Z}\\n\"\n+\tunless GetOptions('metainfo=s' => \\$metaext) && @ARGV;\n \n my $branch_name = 'import-tars';\n my $branch_ref = \"refs/heads/$branch_name\";\n@@ -109,12 +120,43 @@ foreach my $tar_file (@ARGV)\n \t\t$have_top_dir = 0 if $top_dir ne $1;\n \t}\n \n+\tmy $commit_msg = \"Imported from $tar_file.\";\n+\tmy $this_committer_name = $committer_name;\n+\tmy $this_committer_email = $committer_email;\n+\tmy $this_author_name = $author_name;\n+\tmy $this_author_email = $author_email;\n+\tif ($metaext ne '') {\n+\t\t# Optionally read a commit message from <filename.tar>.msg\n+\t\t# Add a line on the form \"Committer: name <e-mail>\" to override\n+\t\t# the committer and \"Author: name <e-mail>\" to override the\n+\t\t# author for this tar ball.\n+\t\tif (open MSG, '<', \"${tar_file}.${metaext}\") {\n+\t\t\tmy $header_done = 0;\n+\t\t\t$commit_msg = '';\n+\t\t\twhile (<MSG>) {\n+\t\t\t\tif (!$header_done && /^Committer:\\s+([^<>]*)\\s+<(.*)>\\s*$/i) {\n+\t\t\t\t\t$this_committer_name = $1;\n+\t\t\t\t\t$this_committer_email = $2;\n+\t\t\t\t} elsif (!$header_done && /^Author:\\s+([^<>]*)\\s+<(.*)>\\s*$/i) {\n+\t\t\t\t\t$this_author_name = $1;\n+\t\t\t\t\t$this_author_email = $2;\n+\t\t\t\t} elsif (!$header_done && /^$/ { # empty line ends header.\n+\t\t\t\t\t$header_done = 1;\n+\t\t\t\t} else {\n+\t\t\t\t\t$commit_msg .= $_;\n+\t\t\t\t\t$header_done = 1;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tclose MSG;\n+\t\t}\n+\t}\n+\n \tprint FI <<EOF;\n commit $branch_ref\n-author $author_name <$author_email> $author_time +0000\n-committer $committer_name <$committer_email> $commit_time +0000\n+author $this_author_name <$this_author_email> $author_time +0000\n+committer $this_committer_name <$this_committer_email> $commit_time +0000\n data <<END_OF_COMMIT_MESSAGE\n-Imported from $tar_file.\n+$commit_msg\n END_OF_COMMIT_MESSAGE\n \n deleteall\n-- \n1.6.3.3\n"}]}