{"thread":{"id":"8664","subject":"[PATCH] git-send-email: RFC2822 compliant Message-ID","startedAt":"2007-06-20T13:25:01Z","lastAt":"2007-06-21T04:09:30Z","messageCount":4,"participants":["Michael Hendricks","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"45431","messageId":"11823459011323-git-send-email-michael@ndrix.org","threadId":"8664","inReplyTo":null,"subject":"[PATCH] git-send-email: RFC2822 compliant Message-ID","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2007-06-20T13:25:01Z","receivedAt":"2007-06-20T13:25:01Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"RFC 2822 section 3.6.4 suggests that a \"good method\" for generating a\nMessage-ID is to put the domain name of the host on the right-side of\nthe \"@\" character.  Use Perl's Sys::Hostname to do the heavy lifting.\nThis module has been in the Perl core since version 5.\n---\n git-send-email.perl |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7c0c90b..2259f4b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -21,6 +21,7 @@ use warnings;\n use Term::ReadLine;\n use Getopt::Long;\n use Data::Dumper;\n+use Sys::Hostname;\n use Git;\n \n package FakeTerm;\n@@ -411,9 +412,9 @@ sub extract_valid_address {\n # a random number to the end, in case we are called quicker than\n # 1 second since the last time we were called.\n \n-# We'll setup a template for the message id, using the \"from\" address:\n-my $message_id_from = extract_valid_address($from);\n-my $message_id_template = \"<%s-git-send-email-$message_id_from>\";\n+# We'll setup a template for the message id, using the hostname:\n+my $hostname = hostname();\n+my $message_id_template = \"<%s-git-send-email\\@$hostname>\";\n \n sub make_message_id\n {\n-- \n1.5.2.2.238.g7cbf2f2\n"},{"id":"45438","messageId":"7vlkeetm5c.fsf@assigned-by-dhcp.pobox.com","threadId":"8664","inReplyTo":"11823459011323-git-send-email-michael@ndrix.org","subject":"Re: [PATCH] git-send-email: RFC2822 compliant Message-ID","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-20T20:18:39Z","receivedAt":"2007-06-20T20:18:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Hendricks <michael@ndrix.org> writes:\n\n> RFC 2822 section 3.6.4 suggests that a \"good method\" for generating a\n> Message-ID is to put the domain name of the host on the right-side of\n> the \"@\" character.  Use Perl's Sys::Hostname to do the heavy lifting.\n> This module has been in the Perl core since version 5.\n\nProbably is a good idea for 50% of properly configured hosts.  I\nthink hosts can be configured so that hostname() already returns\nfqdn in which case your patch is fine but they can also be\nconfigured so that hostname() plus its domainname becomes fqdn,\nin which case it is probably not.  In any case it is mere\nsuggestion (not MUST nor even SHOULD), so we should judge its\nmerits a bit carefully.\n\nWhat happens if the machine you run send-email on does not have\na valid hostname configured yet?  People on home machines or\nlaptops whose only contact outside are with their ISP\nmailservers should be able to send their patches without having\nto configure /etc/hostname, shouldn't they?  Does Sys::Hostname\ndie under some condition, such as \"the host is not configured\nwell enough\"?  If so I suspect the change to replace the\nexisting one is not acceptable.\n\nI think we should use something safe that gives reasonably\nunique identifier and the existing $message_id_from based method\nis one way to do so.\n\nThe message from vger mailmaster (DSM) suggests that somehow\n$message_id_from method returned an empty string.  Maybe make\nyour patch used as a fallback in such a case?\n\nFinally could you resend this with your updated git-send-email?\nI suspect that this line in the mail header of your patch:\n\n\tMessage-ID: <11823459011323-git-send-email-michael@ndrix.org>\n\nshould have read like so:\n\n\tMessage-ID: <11823459011323-git-send-email@ndrix.org>\n"},{"id":"45441","messageId":"7v7ipytkt5.fsf@assigned-by-dhcp.pobox.com","threadId":"8664","inReplyTo":"11823459011323-git-send-email-michael@ndrix.org","subject":"Re: [PATCH] git-send-email: RFC2822 compliant Message-ID","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-20T20:47:34Z","receivedAt":"2007-06-20T20:47:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"How about doing this instead?\n\n * Move call to make_message_id() to where it matters, namely,\n   before the $message_id is needed to be placed in the\n   generated e-mail header; this has an important side effect of\n   making it clear that $from is already available.\n\n * Throw in Sys::Hostname::hostname() just for fun, although I\n   suspect that the code would never trigger due to the modified\n   call sequence that makes sure $from is always available.\n\n---\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7c0c90b..9f75551 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -412,13 +412,21 @@ sub extract_valid_address {\n # 1 second since the last time we were called.\n \n # We'll setup a template for the message id, using the \"from\" address:\n-my $message_id_from = extract_valid_address($from);\n-my $message_id_template = \"<%s-git-send-email-$message_id_from>\";\n \n sub make_message_id\n {\n \tmy $date = time;\n \tmy $pseudo_rand = int (rand(4200));\n+\tmy $du_part;\n+\tfor ($from, $committer, $author) {\n+\t\t$du_part = extract_valid_address($_);\n+\t\tlast if ($du_part ne '');\n+\t}\n+\tif ($du_part eq '') {\n+\t\tuse Sys::Hostname qw();\n+\t\t$du_part = 'user@' . Sys::Hostname::hostname();\n+\t}\n+\tmy $message_id_template = \"<%s-git-send-email-$du_part>\";\n \t$message_id = sprintf $message_id_template, \"$date$pseudo_rand\";\n \t#print \"new message id = $message_id\\n\"; # Was useful for debugging\n }\n@@ -467,6 +475,8 @@ sub send_message\n \t\t$ccline = \"\\nCc: $cc\";\n \t}\n \t$from = sanitize_address_rfc822($from);\n+\tmake_message_id();\n+\n \tmy $header = \"From: $from\n To: $to${ccline}\n Subject: $subject\n@@ -533,7 +543,6 @@ X-Mailer: git-send-email $gitversion\n \n $reply_to = $initial_reply_to;\n $references = $initial_reply_to || '';\n-make_message_id();\n $subject = $initial_subject;\n \n foreach my $t (@files) {\n@@ -627,7 +636,6 @@ foreach my $t (@files) {\n \t\t\t$references = \"$message_id\";\n \t\t}\n \t}\n-\tmake_message_id();\n }\n \n if ($compose) {\n"},{"id":"45462","messageId":"20070621040929.GE5915@ginosko.local","threadId":"8664","inReplyTo":"7v7ipytkt5.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [PATCH] git-send-email: RFC2822 compliant Message-ID","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2007-06-21T04:09:30Z","receivedAt":"2007-06-21T04:09:30Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"On Wed, Jun 20, 2007 at 01:47:34PM -0700, Junio C Hamano wrote:\n> How about doing this instead?\n> \n>  * Move call to make_message_id() to where it matters, namely,\n>    before the $message_id is needed to be placed in the\n>    generated e-mail header; this has an important side effect of\n>    making it clear that $from is already available.\n> \n>  * Throw in Sys::Hostname::hostname() just for fun, although I\n>    suspect that the code would never trigger due to the modified\n>    call sequence that makes sure $from is always available.\n> \n> ---\n> \n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 7c0c90b..9f75551 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -412,13 +412,21 @@ sub extract_valid_address {\n>  # 1 second since the last time we were called.\n>  \n>  # We'll setup a template for the message id, using the \"from\" address:\n> -my $message_id_from = extract_valid_address($from);\n> -my $message_id_template = \"<%s-git-send-email-$message_id_from>\";\n>  \n>  sub make_message_id\n>  {\n>  \tmy $date = time;\n>  \tmy $pseudo_rand = int (rand(4200));\n> +\tmy $du_part;\n> +\tfor ($from, $committer, $author) {\n> +\t\t$du_part = extract_valid_address($_);\n> +\t\tlast if ($du_part ne '');\n> +\t}\n> +\tif ($du_part eq '') {\n> +\t\tuse Sys::Hostname qw();\n> +\t\t$du_part = 'user@' . Sys::Hostname::hostname();\n> +\t}\n> +\tmy $message_id_template = \"<%s-git-send-email-$du_part>\";\n>  \t$message_id = sprintf $message_id_template, \"$date$pseudo_rand\";\n>  \t#print \"new message id = $message_id\\n\"; # Was useful for debugging\n>  }\n> @@ -467,6 +475,8 @@ sub send_message\n>  \t\t$ccline = \"\\nCc: $cc\";\n>  \t}\n>  \t$from = sanitize_address_rfc822($from);\n> +\tmake_message_id();\n> +\n>  \tmy $header = \"From: $from\n>  To: $to${ccline}\n>  Subject: $subject\n> @@ -533,7 +543,6 @@ X-Mailer: git-send-email $gitversion\n>  \n>  $reply_to = $initial_reply_to;\n>  $references = $initial_reply_to || '';\n> -make_message_id();\n>  $subject = $initial_subject;\n>  \n>  foreach my $t (@files) {\n> @@ -627,7 +636,6 @@ foreach my $t (@files) {\n>  \t\t\t$references = \"$message_id\";\n>  \t\t}\n>  \t}\n> -\tmake_message_id();\n>  }\n>  \n>  if ($compose) {\n> \n\nI like it.  It eliminates two globals and makes the context of\nmake_message_id clearer.\n\n-- \nMichael\n"}]}