{"thread":{"id":"20709","subject":"[PATCH] import-tars: Allow per-tar author and commit message.","startedAt":"2009-08-23T20:34:33Z","lastAt":"2009-08-26T09:17:14Z","messageCount":8,"participants":["Peter Krefting","Nanako Shiraishi","Sam Vilain","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"121581","messageId":"20090823203640.B195D189B12@perkele","threadId":"20709","inReplyTo":null,"subject":"[PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2009-08-23T20:34:33Z","receivedAt":"2009-08-23T20:34:33Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Instead of having each imported tar ball's commit message be \"Imported\nfrom filename.tar\", optionally take a commit message from a file\ncalled \"filename.tar.msg\".\n\nInstead of having each commit have the same author and committer\ninformation, optionally read the committer information from a file\ncalled \"filename.tar.committer\" and author from a file called\n\"filename.tar.author\".\n\nSigned-off-by: Peter Krefting <peter@softwolves.pp.se>\n---\nI used this (albeit based on a slightly earlier verison of the script)\nto generate a better-looking history when importing\nhttp://git.debian.org/?p=crashmail/jamnntpd.git and\nhttp://git.debian.org/?p=crashmail/crashmail.git into Git, using\nexcerpts from the embedded change history as commit messages.\n\n contrib/fast-import/import-tars.perl |   42 +++++++++++++++++++++++++++++++--\n 1 files changed, 39 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 78e40d2..7aad16f 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -109,12 +109,48 @@ foreach my $tar_file (@ARGV)\n \t\t$have_top_dir = 0 if $top_dir ne $1;\n \t}\n \n+\t# Optionally read a commit message from <filename.tar>.msg\n+\tmy $commit_msg = \"Imported from $tar_file.\";\n+\tif (open MSG, '<', \"${tar_file}.msg\")\n+\t{\n+\t\t$commit_msg = '';\n+\t\twhile (<MSG>)\n+\t\t{\n+\t\t\t$commit_msg .= $_;\n+\t\t}\n+\t\tclose MSG;\n+\t}\n+\n+\t# Optionally read a committer from <filename.tar>.committer\n+\t# (first line is name, second line is e-mail address).\n+\tmy $this_committer_name = $committer_name;\n+\tmy $this_committer_email = $committer_email;\n+\tif (open COMMITTER, '<', \"${tar_file}.committer\")\n+\t{\n+\t\t($this_committer_name, $this_committer_email) = <COMMITTER>;\n+\t\tchomp $this_committer_name;\n+\t\tchomp $this_committer_email;\n+\t\tclose COMMITTER;\n+\t}\n+\n+\t# Optionally read an author from <filename.tar>.author\n+\t# (first line is name, second line is e-mail address).\n+\tmy $this_author_name = $author_name;\n+\tmy $this_author_email = $author_email;\n+\tif (open AUTHOR, '<', \"${tar_file}.author\")\n+\t{\n+\t\t($this_author_name, $this_author_email) = <AUTHOR>;\n+\t\tchomp $this_author_name;\n+\t\tchomp $this_author_email;\n+\t\tclose AUTHOR;\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"},{"id":"121589","messageId":"20090824062438.6117@nanako3.lavabit.com","threadId":"20709","inReplyTo":"20090823203640.B195D189B12@perkele","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-08-23T21:24:38Z","receivedAt":"2009-08-23T21:24:38Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Peter Krefting <peter@softwolves.pp.se>\n\n> Instead of having each imported tar ball's commit message be \"Imported\n> from filename.tar\", optionally take a commit message from a file\n> called \"filename.tar.msg\".\n>\n> Instead of having each commit have the same author and committer\n> information, optionally read the committer information from a file\n> called \"filename.tar.committer\" and author from a file called\n> \"filename.tar.author\".\n\nInstead of requiring the user to have millions of separate files, how about reading a single metainfo file that may look like this?\n\n    [file \"git-1.0.0.tar\"]\n\tmessage = \"Commit log message for the first revision\"\n\tauthor = \"A U Thor <au.thor@example.xz>\"\n\n    [file \"git-1.0.1.tar\"]\n\tmessage = \"Commit log message for the first maintenance revision\"\n\tauthor = \"F I Xer <fi.xer@example.xz>\"\n\nand give the name of that metainfo file from the command line? The message may be awkward to put in the metainfo file itself, and it might be easier to refer to the name of a file that is outside the metainfo file itself, but the point is that doing so will both reduce the clutter in your folders, and will give people an option to avoid accidentally reading from random files in the same folder as the tar files that unfortunately have names that ends with the suffixes you randomly chose in this patch.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"121590","messageId":"4A91B8BB.1030906@vilain.net","threadId":"20709","inReplyTo":"20090823203640.B195D189B12@perkele","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2009-08-23T21:46:35Z","receivedAt":"2009-08-23T21:46:35Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Peter Krefting wrote:\n> Instead of having each imported tar ball's commit message be \"Imported\n> from filename.tar\", optionally take a commit message from a file\n> called \"filename.tar.msg\".\n>\n> Instead of having each commit have the same author and committer\n> information, optionally read the committer information from a file\n> called \"filename.tar.committer\" and author from a file called\n> \"filename.tar.author\".\n>\n> Signed-off-by: Peter Krefting <peter@softwolves.pp.se>\n> ---\n> I used this (albeit based on a slightly earlier verison of the script)\n> to generate a better-looking history when importing\n> http://git.debian.org/?p=crashmail/jamnntpd.git and\n> http://git.debian.org/?p=crashmail/crashmail.git into Git, using\n> excerpts from the embedded change history as commit messages.\n>\n>  contrib/fast-import/import-tars.perl |   42 +++++++++++++++++++++++++++++++--\n>  1 files changed, 39 insertions(+), 3 deletions(-)\n>\n> diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\n> index 78e40d2..7aad16f 100755\n> --- a/contrib/fast-import/import-tars.perl\n> +++ b/contrib/fast-import/import-tars.perl\n> @@ -109,12 +109,48 @@ foreach my $tar_file (@ARGV)\n>  \t\t$have_top_dir = 0 if $top_dir ne $1;\n>  \t}\n>  \n> +\t# Optionally read a commit message from <filename.tar>.msg\n> +\tmy $commit_msg = \"Imported from $tar_file.\";\n> +\tif (open MSG, '<', \"${tar_file}.msg\")\n> +\t{\n> +\t\t$commit_msg = '';\n> +\t\twhile (<MSG>)\n> +\t\t{\n> +\t\t\t$commit_msg .= $_;\n> +\t\t}\n> +\t\tclose MSG;\n> +\t}\n> +\n> +\t# Optionally read a committer from <filename.tar>.committer\n> +\t# (first line is name, second line is e-mail address).\n> +\tmy $this_committer_name = $committer_name;\n> +\tmy $this_committer_email = $committer_email;\n> +\tif (open COMMITTER, '<', \"${tar_file}.committer\")\n> +\t{\n> +\t\t($this_committer_name, $this_committer_email) = <COMMITTER>;\n> +\t\tchomp $this_committer_name;\n> +\t\tchomp $this_committer_email;\n> +\t\tclose COMMITTER;\n> +\t}\n> +\n> +\t# Optionally read an author from <filename.tar>.author\n> +\t# (first line is name, second line is e-mail address).\n> +\tmy $this_author_name = $author_name;\n> +\tmy $this_author_email = $author_email;\n> +\tif (open AUTHOR, '<', \"${tar_file}.author\")\n> +\t{\n> +\t\t($this_author_name, $this_author_email) = <AUTHOR>;\n> +\t\tchomp $this_author_name;\n> +\t\tchomp $this_author_email;\n> +\t\tclose AUTHOR;\n> +\t}\n> +\n>   \n\nIt's not necessary to duplicate code like that.\n\nAlso I wonder if there isn't a nicer interface for users.  Why not allow\nthe file to specify From:, Committer: etc as header lines\n\n\t# Optionally read a commit message from <filename.tar>.msg\n\tmy $commit_msg = \"Imported from $tar_file.\";\n\tmy ($committer, $commit_date, $author, $author_date);\n\tif (open MSG, '<', \"${tar_file}.desc\")\n\t{\n\t\tmy $state = \"header\";\n\t\t$commit_msg = '';\n\t\tmy $last_val;\n\t\twhile (<MSG>)\n\t\t{\n\t\t\tif ($state eq \"header\") {\n\t\t\t\tif (m{^([A-Z][\\w\\-]+): (.*)}) {\n\t\t\t\t\tmy ($header, $value) = $1;\n\t\t\t\t\t$last_val = ($header eq \"Date\" ? \\$author_date :\n\t\t\t\t\t\t$header eq \"From\" ? \\$author :\n\t\t\t\t\t\t$header eq \"Subject\" ? \\$commit_msg :\n\t\t\t\t\t\t$header eq \"Commit-Date\" ? \\$commit_date :\n\t\t\t\t\t\t$header eq \"Committer\" ? \\$committer :\n\t\t\t\t\t\tundef );\n\t\t\t\t\tif ($last_val) {\n\t\t\t\t\t\t$$last_val = $value;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\twarn \"ignoring header '$header' in ${tar_file}.desc line $.\\n\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telsif (m{^\\s+(.+)}) {\n\t\t\t\t\tif ($last_val) {\n\t\t\t\t\t\t$$last_val .= \" $1\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telsif (m{^\\s*$}) {\n\t\t\t\t\t$commit_msg .= ($commit_msg ? \"\\n\" : \"\") . \"\\n\";\n\t\t\t\t\t$state = \"body\";\n\t\t\t\t\tnext;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ($state eq \"body\") {\n\t\t\t\t$commit_msg .= $_;\n\t\t\t}\n\t\t}\n\t\tclose MSG;\n\t}\n\n\t($this_committer_name, $this_committer_email) =\n\t\tchoose_email($committer, $committer_name, $committer_email);\n\t($this_author_name, $this_author_email) =\n\t\tchoose_email($author, $author_name, $author_email);\n\n\tsub choose_email {\n\t\tmy ($spec_combined, $def_name, $def_email) = @_;\n\t\treturn ($def_name, $def_email) unless $spec_combined;\n\t\tif ($spec_combined =~ m{^([^<]+) <([^@]+@[^@]+)>$})) {\n\t\t\t($1, $2);\n\t\t}\n\t\telsif ($spec_combined =~ m{^([^@]+@[^@]+) \\((.*)\\)$}) {\n\t\t\t($2, $1);\n\t\t}\n\t\telse {\n\t\t\twarn \"Couldn't parse e-mail address '$spec_combined'\";\n\t\t\t($def_name, $def_email);\n\t\t}\n\t}\n\nSomething like that, anyway...\n\nSam\n\n\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>   \n"},{"id":"121650","messageId":"alpine.DEB.2.00.0908241659380.16576@perkele.intern.softwolves.pp.se","threadId":"20709","inReplyTo":"4A91B8BB.1030906@vilain.net","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2009-08-24T17:07:09Z","receivedAt":"2009-08-24T17:07:09Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Nanako Shiraishi:\n\n> Instead of requiring the user to have millions of separate files, how \n> about reading a single metainfo file that may look like this?\n\nThe advantage of having one (or more) files per tarball is that I can use \nthe shell's tab completion to make sure I spell the name of the archive \ncorrectly. And that it makes it a lot easier to parse.\n\n\nSam Vilain:\n\n> Also I wonder if there isn't a nicer interface for users.  Why not allow\n> the file to specify From:, Committer: etc as header lines\n\nGood idea. My initial patch was simple, just using the .msg file to add a \nmessage. Then I needed to have a different author for one commit, so I added \nthe .author file. Then came the changes that are in the current import-tars \nthat separates author and committer, hence the .committer file. Somewhere \nalong there it became a bit too complex.\n\nParsing the .msg file for (optional) committer and author info is probably \nbetter. I'll update the patch.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"121662","messageId":"7vab1pf3fj.fsf@alter.siamese.dyndns.org","threadId":"20709","inReplyTo":"alpine.DEB.2.00.0908241659380.16576@perkele.intern.softwolves.pp.se","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-24T18:54:24Z","receivedAt":"2009-08-24T18:54:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Krefting <peter@softwolves.pp.se> writes:\n\n> Nanako Shiraishi:\n>\n>> Instead of requiring the user to have millions of separate files,\n>> how about reading a single metainfo file that may look like this?\n>\n> The advantage of having one (or more) files per tarball is that I can\n> use the shell's tab completion to make sure I spell the name of the\n> archive correctly. And that it makes it a lot easier to parse.\n>\n>\n> Sam Vilain:\n>\n>> Also I wonder if there isn't a nicer interface for users.  Why not allow\n>> the file to specify From:, Committer: etc as header lines\n>\n> Good idea.\n\nThat sounds like a sensible thing to do.\n\nI however am a bit uneasy to see that the patch didn't seem to (and the\nrerolled one does not seem to, either) allow any way to forbid reading of\nthe .msg files, other than an obvious workaround of running \"find | xargs\nrm\" beforehand.  Unlike your \"import-directories\" that is a brand new\nprogram without any existing users, you are touching code that other\npeople have already used, and you do not want to change the behaviour for\nthem only because they happen to have unrelated files in the same\ndirectory.\n"},{"id":"121745","messageId":"alpine.DEB.2.00.0908251950010.19406@ds9.cixit.se","threadId":"20709","inReplyTo":"7vab1pf3fj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2009-08-25T18:52:16Z","receivedAt":"2009-08-25T18:52:16Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Junio C Hamano:\n\n> Unlike your \"import-directories\" that is a brand new program without any \n> existing users, you are touching code that other people have already used, \n> and you do not want to change the behaviour for them only because they \n> happen to have unrelated files in the same directory.\n\nIndeed. Not that it is likely that one have stray filetar.gz.msg files just \nlaying around, but I'll add a command line switch to enable the new \nfunctinality. That sounds like the most reasonable way to go, leaving the \nold usage completely unaffected by the change.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"121749","messageId":"7v8wh7pumr.fsf@alter.siamese.dyndns.org","threadId":"20709","inReplyTo":"alpine.DEB.2.00.0908251950010.19406@ds9.cixit.se","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-25T19:21:16Z","receivedAt":"2009-08-25T19:21:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Krefting <peter@softwolves.pp.se> writes:\n\n> Junio C Hamano:\n>\n>> Unlike your \"import-directories\" that is a brand new program without\n>> any existing users, you are touching code that other people have\n>> already used, and you do not want to change the behaviour for them\n>> only because they happen to have unrelated files in the same\n>> directory.\n>\n> Indeed. Not that it is likely that one have stray filetar.gz.msg files\n> just laying around, but I'll add a command line switch to enable the\n> new functinality. That sounds like the most reasonable way to go,\n> leaving the old usage completely unaffected by the change.\n\nAnd the switch could be \"--metainfo=<ext>\", so that people can choose to\nuse other extensions, e.g. with \"--metainfo=info\" file.tar.info would be\nread for descriptions.\n"},{"id":"121785","messageId":"alpine.DEB.2.00.0908261016050.30577@ds9.cixit.se","threadId":"20709","inReplyTo":"7v8wh7pumr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] import-tars: Allow per-tar author and commit message.","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2009-08-26T09:17:14Z","receivedAt":"2009-08-26T09:17:14Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Junio C Hamano:\n\n> And the switch could be \"--metainfo=<ext>\", so that people can choose to \n> use other extensions, e.g. with \"--metainfo=info\" file.tar.info would be \n> read for descriptions.\n\nThat's a good idea. I just made a simple \"-m\" switch to enable the new code. \nI'll change it into a \"--metainfo\" and post an updated patch later.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"}]}