{"thread":{"id":"18939","subject":"[PATCH RFC3.5 00/12] Introduction to Decreasing send-email Entropy","startedAt":"2009-04-18T17:01:56Z","lastAt":"2009-04-21T03:29:20Z","messageCount":50,"participants":["Michael Witten","Wesley J. Landaker","Jay Soffian","Thomas Adam","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":12},"messages":[{"id":"111591","messageId":"1240074128-16132-1-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":null,"subject":"[PATCH RFC3.5 00/12] Introduction to Decreasing send-email Entropy","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:01:56Z","receivedAt":"2009-04-18T17:01:56Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"This patch series introduces some very basic refactorizations and\nimprovements to send-email. My goal was to keep each patch relatively\nsmall, but it may be better to look at the results of the following\npatches:\n\n\t[PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message\n\t[PATCH RFC3.5 07/12] send-email: Cleanup send_message 'log' code\n\t[PATCH RFC3.5 09/12] Docs: send-email: Reorganize the CONFIGURATION section\n\nThe overall diffstat:\n\n\tDocumentation/git-send-email.txt |  201 ++++++++++++++++++++----\n\tgit-send-email.perl              |  317 +++++++++++++++++++++++++-------------\n\t2 files changed, 376 insertions(+), 142 deletions(-)\n\nThe over all patch series:\n\n\t[PATCH RFC3.5 01/12] send-email: Cleanup the usage text and docs a bit\n\t[PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a command\n\t[PATCH RFC3.5 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".\n\t[PATCH RFC3.5 04/12] send-email: Verification for --smtp-server and --smpt-server-port\n\t[PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code\n\t[PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message\n\t[PATCH RFC3.5 07/12] send-email: Cleanup send_message 'log' code\n\t[PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message\n\t[PATCH RFC3.5 09/12] Docs: send-email: Reorganize the CONFIGURATION section\n\t[PATCH RFC3.5 10/12] Docs: Embolden the CONFIGURATION references\n\t[PATCH RFC3.5 11/12] Docs: send-email: Clarification of sendemail.<identity>\n\t[PATCH RFC3.5 12/12] Docs: send-email: git send-email -> 'send-email'\n\nSincerely,\nMichael Witten\n"},{"id":"111594","messageId":"1240074128-16132-2-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-1-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 01/12] send-email: Cleanup the usage text and docs a bit","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:01:57Z","receivedAt":"2009-04-18T17:01:57Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"--chain-reply-to doesn't take an argument.\n\nThe here-document quotation that defines the usage\ntext is now a single-quote form, so that no interpolation\ntakes place.\n\nAll usage text lines should be < 80 characters.\n\nThe usage text's option arguments match those of the docs.\n\nThe 'host:port' form of argument for --smtp-server was only\nworking for SSL connections, because the SSL connection code\nwas relying on undocumented behavior of Net::SMTP::SSL (really,\nundocumented behavior of Net::SMTP's new method). Because the\nmain documentation for send-email doesn't even list it as valid,\n<str:int> has been replaced with just <server> and <host | command>\nin the usage text; this is only temporary and for purity.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |   21 ++++++++-------\n git-send-email.perl              |   49 +++++++++++++++++++++-----------------\n 2 files changed, 38 insertions(+), 32 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex f7e428e..071e9bf 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -74,8 +74,9 @@ See the CONFIGURATION section for 'sendemail.multiedit'.\n \tthe value GIT_COMMITTER_IDENT, as returned by \"git var -l\".\n \tThe user will still be prompted to confirm this entry.\n \n---in-reply-to=<identifier>::\n-\tSpecify the contents of the first In-Reply-To header.\n+--in-reply-to=<message-id>::\n+\tSpecify the contents of the first In-Reply-To header;\n+\tinclude the angle brackets `<` and `>`.\n \tSubsequent emails will refer to the previous email\n \tinstead of this if --chain-reply-to is set (the default)\n \tOnly necessary if --compose is also set.  If --compose\n@@ -106,7 +107,7 @@ Sending\n \tthe 'sendemail.envelopesender' configuration variable; if that is\n \tunspecified, choosing the envelope sender is left to your MTA.\n \n---smtp-encryption=<encryption>::\n+--smtp-encryption=<type>::\n \tSpecify the encryption to use, either 'ssl' or 'tls'.  Any other\n \tvalue reverts to plain SMTP.  Default is the value of\n \t'sendemail.smtpencryption'.\n@@ -123,20 +124,20 @@ or on the command line. If a username has been specified (with\n specified (with '--smtp-pass' or 'sendemail.smtppass'), then the\n user is prompted for a password while the input is masked for privacy.\n \n---smtp-server=<host>::\n+--smtp-server=<server>::\n \tIf set, specifies the outgoing SMTP server to use (e.g.\n \t`smtp.example.com` or a raw IP address).  Alternatively it can\n \tspecify a full pathname of a sendmail-like program instead;\n \tthe program must support the `-i` option.  Default value can\n \tbe specified by the 'sendemail.smtpserver' configuration\n-\toption; the built-in default is `/usr/sbin/sendmail` or\n-\t`/usr/lib/sendmail` if such program is available, or\n+\tvariable; the built-in default is `/usr/sbin/sendmail` or\n+\t`/usr/lib/sendmail` if such a program is available, or\n \t`localhost` otherwise.\n \n --smtp-server-port=<port>::\n \tSpecifies a port different from the default port (SMTP\n \tservers typically listen to smtp port 25 and ssmtp port\n-\t465); symbolic port names (e.g. \"submission\" instead of 465)\n+\t465); symbolic service names (e.g. \"submission\" instead of 587)\n \tare also accepted. The port can also be set with the\n \t'sendemail.smtpserverport' configuration variable.\n \n@@ -158,7 +159,7 @@ Automating\n \tOutput of this command must be single email address per line.\n \tDefault is the value of 'sendemail.cccmd' configuration value.\n \n---[no-]chain-reply-to=<identifier>::\n+--[no-]chain-reply-to::\n \tIf this is set, each email will be sent as a reply to the previous\n \temail sent.  If disabled with \"--no-chain-reply-to\", all emails after\n \tthe first will be sent as replies to the first email sent.  When using\n@@ -170,7 +171,7 @@ Automating\n \tA configuration identity. When given, causes values in the\n \t'sendemail.<identity>' subsection to take precedence over\n \tvalues in the 'sendemail' section. The default identity is\n-\tthe value of 'sendemail.identity'.\n+\tthe value of the 'sendemail.identity' configuration variable.\n \n --[no-]signed-off-by-cc::\n \tIf this is set, add emails found in Signed-off-by: or Cc: lines to the\n@@ -214,7 +215,7 @@ specified, as well as 'body' if --no-signed-off-cc is specified.\n Administering\n ~~~~~~~~~~~~~\n \n---confirm=<mode>::\n+--confirm=<when>::\n \tConfirm just before sending:\n +\n --\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 04267c5..e43342e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -42,46 +42,51 @@ package main;\n \n \n sub usage {\n-\tprint <<EOT;\n+\n+\t# All printed lines should be less than 80 characters.\n+\n+\tprint <<'EOT';\n git send-email [options] <file | directory | rev-list options >\n \n   Composing:\n-    --from                  <str>  * Email From:\n-    --to                    <str>  * Email To:\n-    --cc                    <str>  * Email Cc:\n-    --bcc                   <str>  * Email Bcc:\n-    --subject               <str>  * Email \"Subject:\"\n-    --in-reply-to           <str>  * Email \"In-Reply-To:\"\n-    --annotate                     * Review each patch that will be sent in an editor.\n+    --from              <address>  * Email From:\n+    --to                <address>  * Email To:\n+    --cc                <address>  * Email Cc:\n+    --bcc               <address>  * Email Bcc:\n+    --subject            <string>  * Email \"Subject:\"\n+    --in-reply-to    <message-id>  * Email \"In-Reply-To:\"; include '<' and '>'.\n+    --annotate                     * Review each patch that will be sent in\n+                                     an editor.\n     --compose                      * Open an editor for introduction.\n \n   Sending:\n-    --envelope-sender       <str>  * Email envelope sender.\n-    --smtp-server       <str:int>  * Outgoing SMTP server to use. The port\n-                                     is optional. Default 'localhost'.\n-    --smtp-server-port      <int>  * Outgoing SMTP server port.\n-    --smtp-user             <str>  * Username for SMTP-AUTH.\n-    --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.\n-    --smtp-encryption       <str>  * tls or ssl; anything else disables.\n+    --envelope-sender   <address>  * Email envelope sender.\n+    --smtp-server        <server>  * Outgoing SMTP server. <host | command>\n+    --smtp-server-port     <port>  * Outgoing SMTP server port; symbolic too.\n+    --smtp-user        <username>  * Username for SMTP-AUTH.\n+    --smtp-pass       [<password>] * Password for SMTP-AUTH; not necessary.\n+    --smtp-encryption      <type>  * tls or ssl; anything else disables.\n     --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.\n \n   Automating:\n-    --identity              <str>  * Use the sendemail.<id> options.\n-    --cc-cmd                <str>  * Email Cc: via `<str> \\$patch_path`\n-    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, all.\n-    --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.\n+    --identity         <identity>  * Use the sendemail.<identity> options.\n+    --cc-cmd            <command>  * Email Cc: via `<command> $patch_path`\n+    --suppress-cc      <category>  * author, self, sob, cc, cccmd, body,\n+                                     bodycc, all.\n+    --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses.\n+                                     Default on.\n     --[no-]suppress-from           * Send to self. Default off.\n     --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default on.\n     --[no-]thread                  * Use In-Reply-To: field. Default on.\n \n   Administering:\n-    --confirm               <str>  * Confirm recipients before sending;\n+    --confirm              <when>  * Confirm recipients before sending;\n                                      auto, cc, compose, always, or never.\n     --quiet                        * Output one line of info per email.\n     --dry-run                      * Don't actually send the emails.\n     --[no-]validate                * Perform patch sanity checks. Default on.\n-    --[no-]format-patch            * understand any non optional arguments as\n-                                     `git format-patch` ones.\n+    --[no-]format-patch            * Understand any non-optional arguments as\n+                                     `git format-patch' arguments.\n \n EOT\n \texit(1);\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111592","messageId":"1240074128-16132-3-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-2-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a command","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:01:58Z","receivedAt":"2009-04-18T17:01:58Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"This is a minor change, but it's cleaner, and it sets up the\n$smtp_server initialization code for future improvements.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |   19 ++++++++++++++-----\n 1 files changed, 14 insertions(+), 5 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e43342e..1a20b2c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -186,7 +186,8 @@ sub do_edit {\n \n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n-my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);\n+my ($smtp_server, $smtp_server_is_a_command);\n+my ($smtp_server_port, $smtp_authuser, $smtp_encryption);\n my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);\n my ($validate, $confirm);\n my (@suppress_cc);\n@@ -674,14 +675,22 @@ if (defined $initial_reply_to) {\n \t$initial_reply_to = \"<$initial_reply_to>\" if $initial_reply_to ne '';\n }\n \n-if (!defined $smtp_server) {\n+if (defined $smtp_server) {\n+\n+\t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n+\n+} else { # use a default:\n+\n \tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n \t\tif (-x $_) {\n \t\t\t$smtp_server = $_;\n+\t\t\t$smtp_server_is_a_command = 1;\n \t\t\tlast;\n \t\t}\n \t}\n-\t$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n+\n+\t$smtp_server = 'localhost'; # 127.0.0.1 is not compatible with IPv6\n+\t\tunless $smtp_server_is_a_command;\n }\n \n if ($compose && $compose > 0) {\n@@ -882,7 +891,7 @@ X-Mailer: git-send-email $gitversion\n \n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n-\t} elsif ($smtp_server =~ m#^/#) {\n+\t} elsif ($smtp_server_is_a_command) {\n \t\tmy $pid = open my $sm, '|-';\n \t\tdefined $pid or die $!;\n \t\tif (!$pid) {\n@@ -958,7 +967,7 @@ X-Mailer: git-send-email $gitversion\n \t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n \t} else {\n \t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\n\");\n-\t\tif ($smtp_server !~ m#^/#) {\n+\t\tunless ($smtp_server_is_a_command) {\n \t\t\tprint \"Server: $smtp_server\\n\";\n \t\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n \t\t\tprint \"RCPT TO:\".join(',',(map { \"<$_>\" } @recipients)).\"\\n\";\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111593","messageId":"1240074128-16132-4-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-3-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:01:59Z","receivedAt":"2009-04-18T17:01:59Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Why not? It's at least useful for testing.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |    4 +++-\n git-send-email.perl              |    2 +-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 071e9bf..ae01632 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -132,7 +132,9 @@ user is prompted for a password while the input is masked for privacy.\n \tbe specified by the 'sendemail.smtpserver' configuration\n \tvariable; the built-in default is `/usr/sbin/sendmail` or\n \t`/usr/lib/sendmail` if such a program is available, or\n-\t`localhost` otherwise.\n+\t`localhost` otherwise. Also, a built-in default is used if\n+\t`<host>` or 'sendemail.smtpserver' is the empty string (for\n+\texample, if '--smtp-server \"\"' is specified on the command line).\n \n --smtp-server-port=<port>::\n \tSpecifies a port different from the default port (SMTP\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 1a20b2c..5e669c7 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -675,7 +675,7 @@ if (defined $initial_reply_to) {\n \t$initial_reply_to = \"<$initial_reply_to>\" if $initial_reply_to ne '';\n }\n \n-if (defined $smtp_server) {\n+if (defined $smtp_server && $smtp_server ne '') {\n \n \t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n \n-- \n1.6.2.2.479.g2aec\n"},{"id":"111595","messageId":"1240074128-16132-5-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-4-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 04/12] send-email: Verification for --smtp-server and --smpt-server-port","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:00Z","receivedAt":"2009-04-18T17:02:00Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"The server URI is verified according to RFCs (including IPv6 support).\n\nThe $smtp_server and $smtp_server_port setup code has been moved\nhigher in the file, so that send-email fails fast if they are bad.\n\nNow, the 'host:port' server URI form is handled regardless of the\ndocumentation deficiencies of Net::SMTP{,::SSL}.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |   50 ++++++++++++-----\n git-send-email.perl              |  115 +++++++++++++++++++++++++++++++------\n 2 files changed, 131 insertions(+), 34 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex ae01632..92985ee 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -125,23 +125,43 @@ specified (with '--smtp-pass' or 'sendemail.smtppass'), then the\n user is prompted for a password while the input is masked for privacy.\n \n --smtp-server=<server>::\n-\tIf set, specifies the outgoing SMTP server to use (e.g.\n-\t`smtp.example.com` or a raw IP address).  Alternatively it can\n-\tspecify a full pathname of a sendmail-like program instead;\n-\tthe program must support the `-i` option.  Default value can\n-\tbe specified by the 'sendemail.smtpserver' configuration\n-\tvariable; the built-in default is `/usr/sbin/sendmail` or\n-\t`/usr/lib/sendmail` if such a program is available, or\n-\t`localhost` otherwise. Also, a built-in default is used if\n-\t`<host>` or 'sendemail.smtpserver' is the empty string (for\n-\texample, if '--smtp-server \"\"' is specified on the command line).\n+\tSpecifies the outgoing SMTP server to use. The server may be\n+\tgiven as a domain name (e.g. `smtp.example.com:587`), raw IP\n+\taddress (e.g. `192.168.0.1`), or absolute path to a command\n+\t(e.g. `/usr/sbin/sendmail`).\n++\n+Usually a server is specified with its URI form:\n++\n+\thost[:port]\n++\n+The optional port, which identifies a particular service at the\n+given host, is normally provided as a non-negative integer that\n+is representable in 16-bits; however, it is possible to use any\n+string composed of some combination of alphanumeric characters, the\n+underscore, the hyphen, and punctuation (special) characters, so\n+that symbolic service names can be employed (as defined by, say,\n+`/etc/services` on Unix systems).\n++\n+Alternatively the server can be specified as an absolute path to\n+a sendmail-like program; in particular, the program must support\n+`sendmail's` `-i` option.\n++\n+Default value can be specified by the 'sendemail.smtpserver'\n+configuration variable; the built-in default is `/usr/sbin/sendmail`\n+or `/usr/lib/sendmail` if such a program is available, or `localhost`\n+otherwise. Also, a built-in default is used if `<server>` or\n+'sendemail.smtpserver' is the empty string (for example, if\n+'--smtp-server \"\"' is specified on the command line).\n \n --smtp-server-port=<port>::\n-\tSpecifies a port different from the default port (SMTP\n-\tservers typically listen to smtp port 25 and ssmtp port\n-\t465); symbolic service names (e.g. \"submission\" instead of 587)\n-\tare also accepted. The port can also be set with the\n-\t'sendemail.smtpserverport' configuration variable.\n+\tSpecifies a port different from the default port (SMTP servers\n+\ttypically listen to port 25, 587, or even non-standard 465); symbolic\n+\tservice names (e.g. \"submission\" instead of 587) are also accepted,\n+\tprovided the underlying system handles mappings in something like\n+\t`/etc/services`; such service names may only be composed of some\n+\tcombination of alphanumeric characters, the underscore, the hyphen,\n+\tand punctuation (special) characters. The port can also be set with\n+\tthe 'sendemail.smtpserverport' configuration variable.\n \n --smtp-ssl::\n \tLegacy alias for '--smtp-encryption ssl'.\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5e669c7..e2c7954 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -61,7 +61,7 @@ git send-email [options] <file | directory | rev-list options >\n \n   Sending:\n     --envelope-sender   <address>  * Email envelope sender.\n-    --smtp-server        <server>  * Outgoing SMTP server. <host | command>\n+    --smtp-server        <server>  * Outgoing SMTP server: <host[:port] | cmd>.\n     --smtp-server-port     <port>  * Outgoing SMTP server port; symbolic too.\n     --smtp-user        <username>  * Username for SMTP-AUTH.\n     --smtp-pass       [<password>] * Password for SMTP-AUTH; not necessary.\n@@ -328,6 +328,101 @@ foreach my $setting (values %config_bool_settings) {\n # 'default' encryption is none -- this only prevents a warning\n $smtp_encryption = '' unless (defined $smtp_encryption);\n \n+# Define a function that verifies a server URI and returns\n+# its host and port parts:\n+\n+sub parse_server_URI($) {\n+\n+\t# These regular experssions were derived from:\n+\t#   * RFC 2373 (Appendix B) : IP Version 6 Addressing Architecture\n+\t#   * RFC 2732 (Section  3) : Format for Literal IPv6 Addresses in URL's\n+\t#   * RFC 2396 (Sec. 3.2.2) : Uniform Resource Identifiers (URI): Generic Syntax\n+\t# Also, ports are allowed to be symbolic, so that /etc/services mappings\n+\t# can be used.\n+\n+\t# Define a port (RFC 2396 and extension):\n+\n+\tmy $port = qr/[\\w[:punct:]]+/;\n+\n+\t# Define an IPv4 address (RFC 2373):\n+\n+\tmy $dig3        = qr/\\d{1,3}/;\n+\tmy $IPv4address = qr/$dig3(?:\\.$dig3){3}/;\n+\n+\t# Define an IPv6 address (RFC 2373):\n+\n+\tmy $hex4        = qr/[[:xdigit:]]{1,4}/;\n+\tmy $hexseq      = qr/$hex4(?::$hex4)*/;  \t\t# RFC 2373 is really that loose.\n+\tmy $hexpart     = qr/$hexseq|$hexseq?::$hexseq?/;\n+\tmy $IPv6address = qr/$hexpart(?::$IPv4address)?/;\n+\n+\t# Define an IPv6 literal (RFC 2732):\n+\n+\tmy $IPv6reference = qr/\\[$IPv6address\\]/;\n+\n+\t# Define a server URI (RFC 2396 and RFC 2732):\n+\n+\tmy $toplabel    = qr/[[:alpha:]](?:(?:[[:alnum:]]|-)*[[:alpha:]])?/;\n+\tmy $domainlabel = qr/[[:alnum:]](?:(?:[[:alnum:]]|-)*[[:alnum:]])?/;\n+\tmy $hostname    = qr/(?:$domainlabel\\.)*$toplabel\\.?/;\n+\tmy $host        = qr/$hostname|$IPv4address|$IPv6reference/;\n+\tmy $hostport    = qr/^($host)(?::($port))?$/;\n+\n+\t# Phew! Now parse\n+\n+\treturn shift =~ $hostport;\n+}\n+\n+# Figure out how to contact the SMTP server.\n+# After this code, $smtp_server_port is either\n+# valid or undef:\n+\n+if (defined $smtp_server && $smtp_server ne '') {\n+\n+\tif ($smtp_server_is_a_command = ($smtp_server =~ m{^/})) {\n+\n+\t\tdie \"--smtp-server: The SMTP server command does not exist: $smtp_server\\n\"\n+\t\t\tunless -x $smtp_server;\n+\n+\t\tprint STDERR \"--smtp-server: Using command '$smtp_server'; ignoring --smtp-server-port='$smtp_server_port'\\n\"\n+\t\t\tif defined $smtp_server_port;\n+\n+\t} else {\n+\n+\t\t($smtp_server, my $port) = parse_server_URI $smtp_server\n+\t\t\tor die \"--smtp-server: Not a valid server URI: '$smtp_server'\\n\";\n+\n+\t\tif (defined $smtp_server_port) {\n+\n+\t\t\t$smtp_server_port =~ /[\\w[:punct:]]+/ or die \"--smtp-server-port: Invalid port: '$smtp_server_port'\\n\";\n+\n+\t\t\tprint STDERR \"--smtp-server-port: Using port '$smtp_server_port'; ignoring --smtp-server's port '$port'\\n\"\n+\t\t\t\tif defined $port;\n+\n+\t\t} else {\n+\n+\t\t\t$smtp_server_port = $port;\n+\t\t}\n+\t}\n+\n+} else { # use a default:\n+\n+\tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n+\t\tif (-x $_) {\n+\t\t\t$smtp_server = $_;\n+\t\t\t$smtp_server_is_a_command = 1;\n+\n+\t\t\tprint STDERR \"--smtp-server: Using command '$smtp_server'; ignoring --smtp-server-port='$smtp_server_port'\\n\"\n+\t\t\t\tif defined $smtp_server_port;\n+\n+\t\t\tlast;\n+\t\t}\n+\t}\n+\n+\t$smtp_server = 'localhost'; # 127.0.0.1 is not compatible with IPv6\n+\t\tunless $smtp_server_is_a_command;\n+}\n+\n # Set CC suppressions\n my(%suppress_cc);\n if (@suppress_cc) {\n@@ -675,24 +770,6 @@ if (defined $initial_reply_to) {\n \t$initial_reply_to = \"<$initial_reply_to>\" if $initial_reply_to ne '';\n }\n \n-if (defined $smtp_server && $smtp_server ne '') {\n-\n-\t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n-\n-} else { # use a default:\n-\n-\tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n-\t\tif (-x $_) {\n-\t\t\t$smtp_server = $_;\n-\t\t\t$smtp_server_is_a_command = 1;\n-\t\t\tlast;\n-\t\t}\n-\t}\n-\n-\t$smtp_server = 'localhost'; # 127.0.0.1 is not compatible with IPv6\n-\t\tunless $smtp_server_is_a_command;\n-}\n-\n if ($compose && $compose > 0) {\n \t@files = ($compose_filename . \".final\", @files);\n }\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111596","messageId":"1240074128-16132-6-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-5-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:01Z","receivedAt":"2009-04-18T17:02:01Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Signed-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |   21 ++++++++++++++-------\n 1 files changed, 14 insertions(+), 7 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e2c7954..2727c77 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -967,15 +967,22 @@ X-Mailer: git-send-email $gitversion\n \t}\n \n \tif ($dry_run) {\n+\n \t\t# We don't want to send the email.\n+\n \t} elsif ($smtp_server_is_a_command) {\n-\t\tmy $pid = open my $sm, '|-';\n-\t\tdefined $pid or die $!;\n-\t\tif (!$pid) {\n-\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n-\t\t}\n-\t\tprint $sm \"$header\\n$message\";\n-\t\tclose $sm or die $?;\n+\n+\t\t(my $pid = open my $pipe, '|-')\n+\t\t\t// die \"Could not fork to run '$smtp_server': $!\\n\";\n+\n+\t\t$pid or exec($smtp_server, @sendmail_parameters)\n+\t\t\tor die \"Could not run '$smtp_server': $!\\n\";\n+\n+\t\tlocal $SIG{PIPE} = 'IGNORE';\n+\n+\t\tprint $pipe \"$header\\n$message\";\n+\t\tclose $pipe or die \"'$smtp_server' exited with status $?: $!\\n\";\n+\n \t} else {\n \n \t\tif (!defined $smtp_server) {\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111597","messageId":"1240074128-16132-7-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-6-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:02Z","receivedAt":"2009-04-18T17:02:02Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Some of the code was never used or not necessary; it should\nbe easier to read now.\n\nThe code could even be simplified further, because Net::SMTP{,::SSL}\nboth take the PORT variable in their new methods (which, as of this\ncommit, are actually the same method). Moreover, both take a server\nURI of the form 'host:port' that trumps any value passed to PORT.\n\nUnfortunately, none of this is documented publicly, so it isn't\nexploited out of purity.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |   93 +++++++++++++++++++++++++++-----------------------\n 1 files changed, 50 insertions(+), 43 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 2727c77..6e2ea2c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -985,67 +985,74 @@ X-Mailer: git-send-email $gitversion\n \n \t} else {\n \n-\t\tif (!defined $smtp_server) {\n-\t\t\tdie \"The required SMTP server is not properly defined.\"\n-\t\t}\n+\t\tgoto SEND_MAIL if $smtp;\n+\n+\t\tif ($smtp_encryption =~ /ssl/i) {\n+\n+\t\t\tuse Net::SMTP::SSL;\n+\t\t\t$smtp = Net::SMTP::SSL->new($smtp_server, Port => $smtp_server_port // 465)\n+\t\t\t\tor die \"Could not connect to SSL SMTP server '$smtp_server:$smtp_server_port'\\n\";\n+\n+\t\t} else {\n+\n+\t\t\tuse Net::SMTP;\n+\n+\t\t\tmy $server_URI = (defined $smtp_server_port)\n+\t\t\t\t\t\t? \"$smtp_server:$smtp_server_port\"\n+\t\t\t\t\t\t:  $smtp_server;\n+\n+\t\t\t$smtp = Net::SMTP->new($server_URI)\n+\t\t\t\tor die \"Could not connect to SMTP server: '$server_URI'\\n\";\n+\n+\t\t\tif ($smtp_encryption =~ /tls/i) {\n \n-\t\tif ($smtp_encryption eq 'ssl') {\n-\t\t\t$smtp_server_port ||= 465; # ssmtp\n-\t\t\trequire Net::SMTP::SSL;\n-\t\t\t$smtp ||= Net::SMTP::SSL->new($smtp_server, Port => $smtp_server_port);\n-\t\t}\n-\t\telse {\n-\t\t\trequire Net::SMTP;\n-\t\t\t$smtp ||= Net::SMTP->new((defined $smtp_server_port)\n-\t\t\t\t\t\t ? \"$smtp_server:$smtp_server_port\"\n-\t\t\t\t\t\t : $smtp_server);\n-\t\t\tif ($smtp_encryption eq 'tls') {\n-\t\t\t\trequire Net::SMTP::SSL;\n \t\t\t\t$smtp->command('STARTTLS');\n-\t\t\t\t$smtp->response();\n-\t\t\t\tif ($smtp->code == 220) {\n-\t\t\t\t\t$smtp = Net::SMTP::SSL->start_SSL($smtp)\n-\t\t\t\t\t\tor die \"STARTTLS failed! \".$smtp->message;\n-\t\t\t\t\t$smtp_encryption = '';\n-\t\t\t\t\t# Send EHLO again to receive fresh\n-\t\t\t\t\t# supported commands\n-\t\t\t\t\t$smtp->hello();\n-\t\t\t\t} else {\n-\t\t\t\t\tdie \"Server does not support STARTTLS! \".$smtp->message;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t}\n+\t\t\t\t$smtp->response(); # so $smtp->code works.\n+\n+\t\t\t\tdie \"Server does not support STARTTLS: \" . $smtp->message . \"\\n\"\n+\t\t\t\t\tunless $smtp->code == 220;\n+\n+\t\t\t\tuse Net::SMTP::SSL;\n+\t\t\t\tNet::SMTP::SSL->start_SSL($smtp)\n+\t\t\t\t\tor die \"STARTTLS failed! \" . $smtp->message . \"\\n\";\n+\n+\t\t\t\t# Send EHLO again to receive fresh\n+\t\t\t\t# supported commands:\n \n-\t\tif (!$smtp) {\n-\t\t\tdie \"Unable to initialize SMTP properly.  Is there something wrong with your config?\";\n+\t\t\t\t$smtp->hello();\n+\t\t\t}\n \t\t}\n \n \t\tif (defined $smtp_authuser) {\n \n-\t\t\tif (!defined $smtp_authpass) {\n+\t\t\tunless (defined $smtp_authpass) {\n \n \t\t\t\tsystem \"stty -echo\";\n \n-\t\t\t\tdo {\n+\t\t\t\t{\n \t\t\t\t\tprint \"Password: \";\n-\t\t\t\t\t$_ = <STDIN>;\n+\t\t\t\t\t$smtp_authpass = <STDIN>;\n \t\t\t\t\tprint \"\\n\";\n-\t\t\t\t} while (!defined $_);\n-\n-\t\t\t\tchomp($smtp_authpass = $_);\n+\t\t\t\t\tredo unless defined $smtp_authpass;\n+\t\t\t\t\tchomp($smtp_authpass);\n+\t\t\t\t}\n \n \t\t\t\tsystem \"stty echo\";\n \t\t\t}\n \n-\t\t\t$auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;\n+\t\t\t$smtp->auth($smtp_authuser, $smtp_authpass)\n+\t\t\t\tor die \"Could not authenticate '$smtp_authuser': \" . $smtp->message . \"\\n\";\n \t\t}\n \n-\t\t$smtp->mail( $raw_from ) or die $smtp->message;\n-\t\t$smtp->to( @recipients ) or die $smtp->message;\n-\t\t$smtp->data or die $smtp->message;\n-\t\t$smtp->datasend(\"$header\\n$message\") or die $smtp->message;\n-\t\t$smtp->dataend() or die $smtp->message;\n-\t\t$smtp->code =~ /250|200/ or die \"Failed to send $subject\\n\".$smtp->message;\n+\t\tSEND_MAIL:\n+\n+\t\t$smtp->mail($raw_from)               and\n+\t\t$smtp->to(@recipients)               and\n+\t\t$smtp->data                          and\n+\t\t$smtp->datasend(\"$header\\n$message\") and\n+\t\t$smtp->dataend                       or\n+\n+\t\tdie \"Failed to send '$subject': \" . $smtp->message . \"\\n\";\n \t}\n \tif ($quiet) {\n \t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111598","messageId":"1240074128-16132-8-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-7-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 07/12] send-email: Cleanup send_message 'log' code","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:03Z","receivedAt":"2009-04-18T17:02:03Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Signed-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |   33 ++++++++++++++++-----------------\n 1 files changed, 16 insertions(+), 17 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6e2ea2c..f3e2ccd 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1054,24 +1054,23 @@ X-Mailer: git-send-email $gitversion\n \n \t\tdie \"Failed to send '$subject': \" . $smtp->message . \"\\n\";\n \t}\n-\tif ($quiet) {\n-\t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n+\n+\tprint \"\\n\" unless $quiet;\n+\tprint 'Dry-' if $dry_run;\n+\tprint(\"Sent $subject\\n\"), return 1 if $quiet;\n+\tprint \"OK. Log says:\\n\";\n+\n+\tif ($smtp_server_is_a_command) {\n+\t\tprint \"Sendmail: $smtp_server \".join(' ',@sendmail_parameters).\"\\n\";\n+\t\tprint \"$header\\n\";\n+\t\tprint \"Result: OK\\n\";\n \t} else {\n-\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\n\");\n-\t\tunless ($smtp_server_is_a_command) {\n-\t\t\tprint \"Server: $smtp_server\\n\";\n-\t\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n-\t\t\tprint \"RCPT TO:\".join(',',(map { \"<$_>\" } @recipients)).\"\\n\";\n-\t\t} else {\n-\t\t\tprint \"Sendmail: $smtp_server \".join(' ',@sendmail_parameters).\"\\n\";\n-\t\t}\n-\t\tprint $header, \"\\n\";\n-\t\tif ($smtp) {\n-\t\t\tprint \"Result: \", $smtp->code, ' ',\n-\t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n-\t\t} else {\n-\t\t\tprint \"Result: OK\\n\";\n-\t\t}\n+\t\tprint \"Server: $smtp_server\\n\";\n+\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n+\t\tprint \"RCPT TO:\".join(',',(map { \"<$_>\" } @recipients)).\"\\n\";\n+\t\tprint \"$header\\n\";\n+\t\tprint(\"Result: OK\\n\"), return 1 if $dry_run;\n+\t\tprint \"Result: \", $smtp->code, ' ', ($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n \t}\n \n \treturn 1;\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111600","messageId":"1240074128-16132-9-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-8-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:04Z","receivedAt":"2009-04-18T17:02:04Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Signed-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |   11 ++++-------\n 1 files changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex f3e2ccd..b9a6d42 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -676,12 +676,7 @@ EOT\n \t\t\t$need_8bit_cte = 0;\n \t\t} elsif (/^Subject:\\s*(.+)\\s*$/i) {\n \t\t\t$initial_subject = $1;\n-\t\t\tmy $subject = $initial_subject;\n-\t\t\t$_ = \"Subject: \" .\n-\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n-\t\t\t\t quote_rfc2047($subject) :\n-\t\t\t\t $subject) .\n-\t\t\t\t\"\\n\";\n+\t\t\tnext;\n \t\t} elsif (/^In-Reply-To:\\s*(.+)\\s*$/i) {\n \t\t\t$initial_reply_to = $1;\n \t\t\tnext;\n@@ -914,9 +909,11 @@ sub send_message\n \tmy $sanitized_sender = sanitize_address($sender);\n \tmake_message_id() unless defined($message_id);\n \n+\tmy $sanitized_subject = ($subject =~ /[^[:ascii:]]/) ? quote_rfc2047($subject) : $subject;\n+\n \tmy $header = \"From: $sanitized_sender\n To: $to${ccline}\n-Subject: $subject\n+Subject: $sanitized_subject\n Date: $date\n Message-Id: $message_id\n X-Mailer: git-send-email $gitversion\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111601","messageId":"1240074128-16132-10-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-9-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 09/12] Docs: send-email: Reorganize the CONFIGURATION section","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:05Z","receivedAt":"2009-04-18T17:02:05Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"For each configuration variable, the reader is either prompted\nto seek out the description of the corresponding command line option,\nor a description is given if there is no corresponding command line\noption.\n\nThe CONFIGURATION section has also been recast into the Composing,\nSending, Automating, and Administering sections, and configuration\nvariables are listed in alphabetical order within each section.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |   83 ++++++++++++++++++++++++++++++++++----\n 1 files changed, 75 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 92985ee..6f770d0 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -282,6 +282,28 @@ default to '--validate'.\n CONFIGURATION\n -------------\n \n+Composing\n+~~~~~~~~~\n+\n+sendemail.bcc::\n+\tSee '--bcc'\n+\n+sendemail.cc::\n+\tSee '--cc'\n+\n+sendemail.multiedit::\n+\tIf true (default), a single editor instance will be spawned to edit\n+\tfiles you have to edit (patches when '--annotate' is used, and the\n+\tsummary when '--compose' is used). If false, files will be edited one\n+\tafter the other, spawning a new editor each time.\n+\n+sendemail.to::\n+\tSee '--from'\n+\n+\n+Sending\n+~~~~~~~\n+\n sendemail.aliasesfile::\n \tTo avoid typing long email addresses, point this to one or more\n \temail aliases files.  You must also supply 'sendemail.aliasfiletype'.\n@@ -290,16 +312,61 @@ sendemail.aliasfiletype::\n \tFormat of the file(s) specified in sendemail.aliasesfile. Must be\n \tone of 'mutt', 'mailrc', 'pine', or 'gnus'.\n \n-sendemail.multiedit::\n-\tIf true (default), a single editor instance will be spawned to edit\n-\tfiles you have to edit (patches when '--annotate' is used, and the\n-\tsummary when '--compose' is used). If false, files will be edited one\n-\tafter the other, spawning a new editor each time.\n+sendemail.envelopesender::\n+\tSee '--envelope-sender'\n+\n+sendemail.smtpencryption::\n+\tSee '--smtp-encryption'\n+\n+sendemail.smtppass::\n+\tSee '--smtp-pass'\n+\n+sendemail.smtpserver::\n+\tSee '--smtp-server'\n+\n+sendemail.smtpserverport::\n+\tSee '--smtp-server-port'\n+\n+sendemail.smtpuser::\n+\tSee '--smtp-ssl'\n+\n+\n+Automating\n+~~~~~~~~~~\n+\n+sendemail.cccmd::\n+\tSee '--cc-cmd'\n+\n+sendemail.chainreplyto::\n+\tSee '--[no-]chain-reply-to'\n+\n+sendemail.identity::\n+\tSee '--identity'\n+\n+sendemail.signedoffbycc::\n+\tSee '--[no-]signed-off-by-cc'\n+\n+sendemail.sleep::\n+\tSee '--sleep'\n+\n+sendemail.suppresscc::\n+\tSee '--suppress-cc'\n+\n+sendemail.suppressfrom::\n+\tSee '--[no-]suppress-from'\n+\n+sendemail.thread::\n+\tSee '--[no-]thread'\n+\n+\n+Administering\n+~~~~~~~~~~~~~\n \n sendemail.confirm::\n-\tSets the default for whether to confirm before sending. Must be\n-\tone of 'always', 'never', 'cc', 'compose', or 'auto'. See '--confirm'\n-\tin the previous section for the meaning of these values.\n+\tSee '--confirm'\n+\n+sendemail.validate::\n+\tSee '--dry-run'\n \n \n Author\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111602","messageId":"1240074128-16132-11-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-10-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 10/12] Docs: Embolden the CONFIGURATION references","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:06Z","receivedAt":"2009-04-18T17:02:06Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Signed-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 6f770d0..93c39e1 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -41,7 +41,7 @@ Composing\n \n --annotate::\n \tReview and edit each patch you're about to send. See the\n-\tCONFIGURATION section for 'sendemail.multiedit'.\n+\t*CONFIGURATION* section for 'sendemail.multiedit'.\n \n --bcc=<address>::\n \tSpecify a \"Bcc:\" value for each email. Default is the value of\n@@ -67,7 +67,7 @@ and In-Reply-To headers will be used unless they are removed.\n +\n Missing From or In-Reply-To headers will be prompted for.\n +\n-See the CONFIGURATION section for 'sendemail.multiedit'.\n+See the *CONFIGURATION* section for 'sendemail.multiedit'.\n \n --from=<address>::\n \tSpecify the sender of the emails.  This will default to\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111603","messageId":"1240074128-16132-12-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-11-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 11/12] Docs: send-email: Clarification of sendemail.<identity>","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:07Z","receivedAt":"2009-04-18T17:02:07Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Signed-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |   43 ++++++++++++++++++++++++++++++++++++++\n 1 files changed, 43 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 93c39e1..3b36ac7 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -194,6 +194,7 @@ Automating\n \t'sendemail.<identity>' subsection to take precedence over\n \tvalues in the 'sendemail' section. The default identity is\n \tthe value of the 'sendemail.identity' configuration variable.\n+\tSee the *CONFIGURATION* section for more details.\n \n --[no-]signed-off-by-cc::\n \tIf this is set, add emails found in Signed-off-by: or Cc: lines to the\n@@ -282,6 +283,48 @@ default to '--validate'.\n CONFIGURATION\n -------------\n \n+Configuration subsections are very useful in combination with '--identity'.\n+For instance, consider a configuration file that contains the following:\n+\n+\t...\n+\n+\t[sendemail]\n+\t\tsmtpencryption = tls\n+\t\tsmtpserver     = smtp.example.com\n+\t\tsmtpuser       = user@example.com\n+\t\tsuppresscc     = self\n+\t\tconfirm        = always\n+\t\tidentity       = test\n+\n+\t[sendemail \"test\"]\n+\t\tto = user@example.com\n+\n+\t[sendemail \"git-rfc\"]\n+\t\tto = git@vger.kernel.org\n+\n+\t[sendemail \"git-submit\"]\n+\t\tto      = gitster@pobox.com\n+\t\tcc      = git@vger.kernel.org\n+\t\tconfirm = never\n+\n+\t...\n+\n+With this configuration, 'send-email' processes the variables in `[sendemail]`.\n+Then, 'sendemail.identity' tells 'send-email' to process the variables in the\n+`[sendemail \"test\"]` subsection. Thus:\n+\n+\tgit send-email <patch>\n+\n+would send `<patch>` to `user@example.com` as a \"test\". When the user\n+decides that `<patch>` is ready to be sent for real, the user could\n+email the 'git' mailing list to make a request for comments (RFC):\n+\n+\tgit send-email <patch> --identity git-rfc\n+\n+Then, for final submission:\n+\n+\tgit send-email <patch> --identity git-submit\n+\n Composing\n ~~~~~~~~~\n \n-- \n1.6.2.2.479.g2aec\n"},{"id":"111604","messageId":"1240074128-16132-13-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-12-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5 12/12] Docs: send-email: git send-email -> 'send-email'","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-18T17:02:08Z","receivedAt":"2009-04-18T17:02:08Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"For the sake of consistency.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n Documentation/git-send-email.txt |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 3b36ac7..11965eb 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -59,7 +59,7 @@ The --cc option must be repeated for each user you want on the cc list.\n \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n \tintroductory message for the patch series.\n +\n-When '--compose' is used, git send-email will use the From, Subject, and\n+When '--compose' is used, 'send-email' will use the From, Subject, and\n In-Reply-To headers specified in the message. If the body of the message\n (what you type after the headers and a blank line) only contains blank\n (or GIT: prefixed) lines the summary won't be sent, but From, Subject,\n@@ -244,7 +244,7 @@ Administering\n --\n - 'always' will always confirm before sending\n - 'never' will never confirm before sending\n-- 'cc' will confirm before sending when send-email has automatically\n+- 'cc' will confirm before sending when 'send-email' has automatically\n   added addresses from the patch to the Cc list\n - 'compose' will confirm before sending the first message when using --compose.\n - 'auto' is equivalent to 'cc' + 'compose'\n@@ -261,10 +261,10 @@ have been specified, in which case default to 'compose'.\n \tWhen an argument may be understood either as a reference or as a file name,\n \tchoose to understand it as a format-patch argument ('--format-patch')\n \tor as a file name ('--no-format-patch'). By default, when such a conflict\n-\toccurs, git send-email will fail.\n+\toccurs, 'send-email' will fail.\n \n --quiet::\n-\tMake git-send-email less verbose.  One line per email should be\n+\tMake 'send-email' less verbose.  One line per email should be\n \tall that is output.\n \n --[no-]validate::\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111619","messageId":"200904181735.51696.wjl@icecavern.net","threadId":"18939","inReplyTo":"1240074128-16132-4-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".","fromName":"Wesley J. Landaker","fromEmail":"wjl@icecavern.net","sentAt":"2009-04-18T23:35:50Z","receivedAt":"2009-04-18T23:35:50Z","isPatch":true,"sender":{"key":"wjl@icecavern.net","avatar":"https://avatars.githubusercontent.com/u/67229?v=4"},"body":"On Saturday 18 April 2009 11:01:59 Michael Witten wrote:\n>  \t`/usr/lib/sendmail` if such a program is available, or\n> -\t`localhost` otherwise.\n> +\t`localhost` otherwise. Also, a built-in default is used if\n\nI think you may have meant:\n+\t`localhost` otherwise. Also, the built-in default is used if\n\n> +\t`<host>` or 'sendemail.smtpserver' is the empty string (for\n> +\texample, if '--smtp-server \"\"' is specified on the command line).\n"},{"id":"111620","messageId":"b4087cc50904181713m49849f89q87a9f5a392085939@mail.gmail.com","threadId":"18939","inReplyTo":"200904181735.51696.wjl@icecavern.net","subject":"Re: [PATCH RFC3.5 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T00:13:11Z","receivedAt":"2009-04-19T00:13:11Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sat, Apr 18, 2009 at 18:35, Wesley J. Landaker <wjl@icecavern.net> wrote:\n> On Saturday 18 April 2009 11:01:59 Michael Witten wrote:\n>>       `/usr/lib/sendmail` if such a program is available, or\n>> -     `localhost` otherwise.\n>> +     `localhost` otherwise. Also, a built-in default is used if\n>\n> I think you may have meant:\n> +       `localhost` otherwise. Also, the built-in default is used if\n\nGood eye! However, I deliberately chose 'a built-in', because there\nare multiple built-in values. However, 'the built-in' is used in the\nprevious sentence, now that I take a closer look myself.\n"},{"id":"111622","messageId":"76718490904181851g2701ce59x614ea60452b914ce@mail.gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-6-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-19T01:51:43Z","receivedAt":"2009-04-19T01:51:43Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 18, 2009 at 1:02 PM, Michael Witten <mfwitten@gmail.com> wrote:\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index e2c7954..2727c77 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -967,15 +967,22 @@ X-Mailer: git-send-email $gitversion\n>        }\n>\n>        if ($dry_run) {\n> +\n>                # We don't want to send the email.\n> +\n>        } elsif ($smtp_server_is_a_command) {\n> -               my $pid = open my $sm, '|-';\n> -               defined $pid or die $!;\n> -               if (!$pid) {\n> -                       exec($smtp_server, @sendmail_parameters) or die $!;\n> -               }\n> -               print $sm \"$header\\n$message\";\n> -               close $sm or die $?;\n> +\n> +               (my $pid = open my $pipe, '|-')\n> +                       // die \"Could not fork to run '$smtp_server': $!\\n\";\n\nWhat is '//' about?\n\nj.\n"},{"id":"111623","messageId":"76718490904181854o380fe118y9f3a52c926bd1f6d@mail.gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-9-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-19T01:54:07Z","receivedAt":"2009-04-19T01:54:07Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 18, 2009 at 1:02 PM, Michael Witten <mfwitten@gmail.com> wrote:\n> +       my $sanitized_subject = ($subject =~ /[^[:ascii:]]/) ? quote_rfc2047($subject) : $subject;\n\nI wonder if it would be clearer to always call quote_rfc2047, then\nhave that function just return its input unaltered if quoting is not\nneeded.\n\nj.\n"},{"id":"111624","messageId":"b4087cc50904181913g117937le333c3b255f7d184@mail.gmail.com","threadId":"18939","inReplyTo":"76718490904181851g2701ce59x614ea60452b914ce@mail.gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T02:13:20Z","receivedAt":"2009-04-19T02:13:20Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sat, Apr 18, 2009 at 20:51, Jay Soffian <jaysoffian@gmail.com> wrote:\n> What is '//' about?\n\nIt's called the Logical Defined-OR:\n\n    http://perldoc.perl.org/perlop.html#C-style-Logical-Defined-Or\n\n> Although it has no direct equivalent in C, Perl's // operator is related to its C-style or. In fact, it's exactly the same as ||, except that it tests the left hand side's definedness instead of its truth. Thus, $a // $b is similar to defined($a) || $b  (except that it returns the value of $a rather than the value of defined($a)) and is exactly equivalent to defined($a) ? $a : $b . This is very useful for providing default values for variables. If you actually want to test if at least one of $a  and $b  is defined, use defined($a // $b) ...\n\nHowever, I wonder if your comment is a veiled quip at my \"Improve\nredability\" claim (which is also ironically unreadable). :-)\n"},{"id":"111625","messageId":"18071eea0904181917u7c7187bubc8fab6ede2d19ef@mail.gmail.com","threadId":"18939","inReplyTo":"b4087cc50904181913g117937le333c3b255f7d184@mail.gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Thomas Adam","fromEmail":"thomas.adam22@gmail.com","sentAt":"2009-04-19T02:17:20Z","receivedAt":"2009-04-19T02:17:20Z","isPatch":true,"sender":{"key":"thomas.adam22@gmail.com","avatar":"https://gravatar.com/avatar/137f9858bc6bfd5b2f743aefd988c81ce0cbd306248889df80e269519cfc8741?d=mp&s=160"},"body":"2009/4/19 Michael Witten <mfwitten@gmail.com>:\n> However, I wonder if your comment is a veiled quip at my \"Improve\n> redability\" claim (which is also ironically unreadable). :-)\n\nMore concerning is that it's a perl 5.10ism -- you cannot assume that\nperl 5.10 is installed on all platforms.  I really wouldn't use this\nconstruct.\n\n-- Thomas Adam\n"},{"id":"111626","messageId":"b4087cc50904181937q38ef45fm7409e020ecf40792@mail.gmail.com","threadId":"18939","inReplyTo":"76718490904181854o380fe118y9f3a52c926bd1f6d@mail.gmail.com","subject":"Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T02:37:57Z","receivedAt":"2009-04-19T02:37:57Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sat, Apr 18, 2009 at 20:54, Jay Soffian <jaysoffian@gmail.com> wrote:\n> On Sat, Apr 18, 2009 at 1:02 PM, Michael Witten <mfwitten@gmail.com> wrote:\n>> +       my $sanitized_subject = ($subject =~ /[^[:ascii:]]/) ? quote_rfc2047($subject) : $subject;\n>\n> I wonder if it would be clearer to always call quote_rfc2047, then\n> have that function just return its input unaltered if quoting is not\n> needed.\n\nIt actually ALWAYS changes the input. This code:\n\n\tsub quote_rfc2047 {\n\t\tlocal $_ = shift;\n\t\tmy $encoding = shift || 'utf-8';\n\t\ts/([^-a-zA-Z0-9!*+\\/])/sprintf(\"=%02X\", ord($1))/eg;\n\t\ts/(.*)/=\\?$encoding\\?q\\?$1\\?=/;\n\t\treturn $_;\n\t}\n\n\tprint quote_rfc2047(\"Yiarg #&@$! This output is messy!\") . \"\\n\"\n\ngives this output:\n\n\t=?utf-8?q?Yiarg=20=23=26!=20This=20output=20is=20messy!?=\n\nTherfore the /[^[:ascii:]]/ check actually saves us from corrupting\nalready encoded subjects or from encoding ones that shouldn't be. In\nfact, I'm not entirely sure the original code is correct to make that\ncheck, because some of the characters that are replaced are ascii\ncharacters. This is all rather strange.\n\nThanks! I should have tested it more; I'm constantly amazed by my\ninability to see the problems I introduce ;-)\n"},{"id":"111627","messageId":"b4087cc50904181943t71d501a6r51bb4cc846f32f78@mail.gmail.com","threadId":"18939","inReplyTo":"18071eea0904181917u7c7187bubc8fab6ede2d19ef@mail.gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T02:43:58Z","receivedAt":"2009-04-19T02:43:58Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sat, Apr 18, 2009 at 21:17, Thomas Adam <thomas.adam22@gmail.com> wrote:\n> More concerning is that it's a perl 5.10ism -- you cannot assume that\n> perl 5.10 is installed on all platforms.  I really wouldn't use this\n> construct.\n\nSee that's the thing: How am I supposed to know it's a perl 5.10ism?\nThe Perl docs give absolutely no clue; Perl[5] is based way too much\non practice rather than theory, because only people that have been\nusing it since day 1 know what's going on. A couple of weeks ago, I\nwent to the perldoc website and just read each website one after the\nother---that is my total knowledge of Perl, and already I've caught\nflack a number of times for having used 'new-fangled technologies'; I\nreally wish the docs would specify when a feature became available.\n\n... add that to the list of perldoc shortcomings.\n"},{"id":"111630","messageId":"7vskk5s15t.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"b4087cc50904181943t71d501a6r51bb4cc846f32f78@mail.gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-19T04:44:14Z","receivedAt":"2009-04-19T04:44:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> On Sat, Apr 18, 2009 at 21:17, Thomas Adam <thomas.adam22@gmail.com> wrote:\n>> More concerning is that it's a perl 5.10ism -- you cannot assume that\n>> perl 5.10 is installed on all platforms.  I really wouldn't use this\n>> construct.\n>\n> See that's the thing: How am I supposed to know it's a perl 5.10ism?\n\nRead perldelta.pod  They come with your Perl distribution.\n\nDebian based distro installs them in\n\n    /usr/share/perl/5.10.0/pod/perl*delta.pod\n\nand Fedora seems to have them in\n\n    /usr/lib/perl5/5.10.0/pod/perl*delta.pod\n\nI think we stick to something like early 5.8 to support platforms with\ninfrequent updates to Perl.\n"},{"id":"111642","messageId":"1240148975-3082-1-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"7vskk5s15t.fsf@gitster.siamese.dyndns.org","subject":"[PATCH RFC3.5.1 05/12] send-email: Improve readability and error-handling in send_message's sendmail code","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T13:49:35Z","receivedAt":"2009-04-19T13:49:35Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Signed-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |   21 ++++++++++++++-------\n 1 files changed, 14 insertions(+), 7 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 559e17b..3a140cd 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -967,15 +967,22 @@ X-Mailer: git-send-email $gitversion\n \t}\n \n \tif ($dry_run) {\n+\n \t\t# We don't want to send the email.\n+\n \t} elsif ($smtp_server_is_a_command) {\n-\t\tmy $pid = open my $sm, '|-';\n-\t\tdefined $pid or die $!;\n-\t\tif (!$pid) {\n-\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n-\t\t}\n-\t\tprint $sm \"$header\\n$message\";\n-\t\tclose $sm or die $?;\n+\n+\t\tdefined (my $pid = open my $pipe, '|-')\n+\t\t\tor die \"Could not fork to run '$smtp_server': $!\\n\";\n+\n+\t\t$pid or exec($smtp_server, @sendmail_parameters)\n+\t\t\tor die \"Could not run '$smtp_server': $!\\n\";\n+\n+\t\tlocal $SIG{PIPE} = 'IGNORE';\n+\n+\t\tprint $pipe \"$header\\n$message\";\n+\t\tclose $pipe or die \"'$smtp_server' exited with status $?: $!\\n\";\n+\n \t} else {\n \n \t\tif (!defined $smtp_server) {\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111644","messageId":"76718490904190713l3d6b5abcmf54544512de87413@mail.gmail.com","threadId":"18939","inReplyTo":"b4087cc50904181937q38ef45fm7409e020ecf40792@mail.gmail.com","subject":"Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-19T14:13:30Z","receivedAt":"2009-04-19T14:13:30Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 18, 2009 at 10:37 PM, Michael Witten <mfwitten@gmail.com> wrote:\n> On Sat, Apr 18, 2009 at 20:54, Jay Soffian <jaysoffian@gmail.com> wrote:\n>> On Sat, Apr 18, 2009 at 1:02 PM, Michael Witten <mfwitten@gmail.com> wrote:\n>>> +       my $sanitized_subject = ($subject =~ /[^[:ascii:]]/) ? quote_rfc2047($subject) : $subject;\n>>\n>> I wonder if it would be clearer to always call quote_rfc2047, then\n>> have that function just return its input unaltered if quoting is not\n>> needed.\n>\n> It actually ALWAYS changes the input. This code:\n\nI think I was not clear. My suggestion was to move the /[^[:ascii:]]/\ncheck to the inside of quote_rfc2047 exactly so that it doesn't always\nchange its input. i.e.\n\n>        sub quote_rfc2047 {\n>                local $_ = shift;\n\nAdd this:\n                 return $_ unless /[^[:ascii:]]/;\n\n>                my $encoding = shift || 'utf-8';\n>                s/([^-a-zA-Z0-9!*+\\/])/sprintf(\"=%02X\", ord($1))/eg;\n>                s/(.*)/=\\?$encoding\\?q\\?$1\\?=/;\n>                return $_;\n>        }\n\nThis simplifies things for the function caller I think.\n\nj.\n"},{"id":"111645","messageId":"76718490904190716u155f7f78ve78bfa61d3d1d468@mail.gmail.com","threadId":"18939","inReplyTo":"18071eea0904181917u7c7187bubc8fab6ede2d19ef@mail.gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-19T14:16:27Z","receivedAt":"2009-04-19T14:16:27Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 18, 2009 at 10:17 PM, Thomas Adam <thomas.adam22@gmail.com> wrote:\n> 2009/4/19 Michael Witten <mfwitten@gmail.com>:\n>> However, I wonder if your comment is a veiled quip at my \"Improve\n>> redability\" claim (which is also ironically unreadable). :-)\n>\n> More concerning is that it's a perl 5.10ism -- you cannot assume that\n> perl 5.10 is installed on all platforms.  I really wouldn't use this\n> construct.\n\nExactly. I started with perl4 (no really...), then moved away from\nhard-core perl coding around 2000 and have been just a perl dabbler\nsince then. So I didn't recognize //, though I suspected it was a\nnewer construct. :-)\n\nj.\n"},{"id":"111646","messageId":"1240150615-3939-1-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"b4087cc50904181713m49849f89q87a9f5a392085939@mail.gmail.com","subject":"[PATCH RFC3.5.1 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T14:16:55Z","receivedAt":"2009-04-19T14:16:55Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Why not? It's at least useful for testing.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n\n\t\tNOTE: This also resulted in a similar change to:\n\t\t[PATCH RFC3.5 04/12] send-email: Verification...\n\n Documentation/git-send-email.txt |    4 +++-\n git-send-email.perl              |    2 +-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 071e9bf..0937dd0 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -132,7 +132,9 @@ user is prompted for a password while the input is masked for privacy.\n \tbe specified by the 'sendemail.smtpserver' configuration\n \tvariable; the built-in default is `/usr/sbin/sendmail` or\n \t`/usr/lib/sendmail` if such a program is available, or\n-\t`localhost` otherwise.\n+\t`localhost` otherwise. Also, the built-in default is used if\n+\t`<host>` or 'sendemail.smtpserver' is the empty string (for\n+\texample, if '--smtp-server \"\"' is specified on the command line).\n \n --smtp-server-port=<port>::\n \tSpecifies a port different from the default port (SMTP\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex fed3554..be6d171 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -675,7 +675,7 @@ if (defined $initial_reply_to) {\n \t$initial_reply_to = \"<$initial_reply_to>\" if $initial_reply_to ne '';\n }\n \n-if (defined $smtp_server) {\n+if (defined $smtp_server && $smtp_server ne '') {\n \n \t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n \n-- \n1.6.2.2.479.g2aec\n"},{"id":"111648","messageId":"1240150785-3999-1-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"1240074128-16132-5-git-send-email-mfwitten@gmail.com","subject":"[PATCH RFC3.5.1 04/12] send-email: Verification for --smtp-server and --smpt-server-port","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T14:19:45Z","receivedAt":"2009-04-19T14:19:45Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"The server URI is verified according to RFCs (including IPv6 support).\n\nThe $smtp_server and $smtp_server_port setup code has been moved\nhigher in the file, so that send-email fails fast if they are bad.\n\nNow, the 'host:port' server URI form is handled regardless of the\ndocumentation deficiencies of Net::SMTP{,::SSL}.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n\n\t\tNOTE: This changed due to the change in:\n\t\t[PATCH RFC3.5.1 03/12] send-email: Interpret...\n\t\tBasically, only \"a built-in\" was changed to\n\t\t\"the built-in\".\n\n\t\tIs it ever useful to submit patches for patches\n\t\trather than sending the whole patch gain? Or would\n\t\tthat be even more trouble?\n\n Documentation/git-send-email.txt |   50 ++++++++++++-----\n git-send-email.perl              |  115 +++++++++++++++++++++++++++++++------\n 2 files changed, 131 insertions(+), 34 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 0937dd0..f306e88 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -125,23 +125,43 @@ specified (with '--smtp-pass' or 'sendemail.smtppass'), then the\n user is prompted for a password while the input is masked for privacy.\n \n --smtp-server=<server>::\n-\tIf set, specifies the outgoing SMTP server to use (e.g.\n-\t`smtp.example.com` or a raw IP address).  Alternatively it can\n-\tspecify a full pathname of a sendmail-like program instead;\n-\tthe program must support the `-i` option.  Default value can\n-\tbe specified by the 'sendemail.smtpserver' configuration\n-\tvariable; the built-in default is `/usr/sbin/sendmail` or\n-\t`/usr/lib/sendmail` if such a program is available, or\n-\t`localhost` otherwise. Also, the built-in default is used if\n-\t`<host>` or 'sendemail.smtpserver' is the empty string (for\n-\texample, if '--smtp-server \"\"' is specified on the command line).\n+\tSpecifies the outgoing SMTP server to use. The server may be\n+\tgiven as a domain name (e.g. `smtp.example.com:587`), raw IP\n+\taddress (e.g. `192.168.0.1`), or absolute path to a command\n+\t(e.g. `/usr/sbin/sendmail`).\n++\n+Usually a server is specified with its URI form:\n++\n+\thost[:port]\n++\n+The optional port, which identifies a particular service at the\n+given host, is normally provided as a non-negative integer that\n+is representable in 16-bits; however, it is possible to use any\n+string composed of some combination of alphanumeric characters, the\n+underscore, the hyphen, and punctuation (special) characters, so\n+that symbolic service names can be employed (as defined by, say,\n+`/etc/services` on Unix systems).\n++\n+Alternatively the server can be specified as an absolute path to\n+a sendmail-like program; in particular, the program must support\n+`sendmail's` `-i` option.\n++\n+Default value can be specified by the 'sendemail.smtpserver'\n+configuration variable; the built-in default is `/usr/sbin/sendmail`\n+or `/usr/lib/sendmail` if such a program is available, or `localhost`\n+otherwise. Also, the built-in default is used if `<server>` or\n+'sendemail.smtpserver' is the empty string (for example, if\n+'--smtp-server \"\"' is specified on the command line).\n \n --smtp-server-port=<port>::\n-\tSpecifies a port different from the default port (SMTP\n-\tservers typically listen to smtp port 25 and ssmtp port\n-\t465); symbolic service names (e.g. \"submission\" instead of 587)\n-\tare also accepted. The port can also be set with the\n-\t'sendemail.smtpserverport' configuration variable.\n+\tSpecifies a port different from the default port (SMTP servers\n+\ttypically listen to port 25, 587, or even non-standard 465); symbolic\n+\tservice names (e.g. \"submission\" instead of 587) are also accepted,\n+\tprovided the underlying system handles mappings in something like\n+\t`/etc/services`; such service names may only be composed of some\n+\tcombination of alphanumeric characters, the underscore, the hyphen,\n+\tand punctuation (special) characters. The port can also be set with\n+\tthe 'sendemail.smtpserverport' configuration variable.\n \n --smtp-ssl::\n \tLegacy alias for '--smtp-encryption ssl'.\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex be6d171..559e17b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -61,7 +61,7 @@ git send-email [options] <file | directory | rev-list options >\n \n   Sending:\n     --envelope-sender   <address>  * Email envelope sender.\n-    --smtp-server        <server>  * Outgoing SMTP server. <host | command>\n+    --smtp-server        <server>  * Outgoing SMTP server: <host[:port] | cmd>.\n     --smtp-server-port     <port>  * Outgoing SMTP server port; symbolic too.\n     --smtp-user        <username>  * Username for SMTP-AUTH.\n     --smtp-pass       [<password>] * Password for SMTP-AUTH; not necessary.\n@@ -328,6 +328,101 @@ foreach my $setting (values %config_bool_settings) {\n # 'default' encryption is none -- this only prevents a warning\n $smtp_encryption = '' unless (defined $smtp_encryption);\n \n+# Define a function that verifies a server URI and returns\n+# its host and port parts:\n+\n+sub parse_server_URI($) {\n+\n+\t# These regular experssions were derived from:\n+\t#   * RFC 2373 (Appendix B) : IP Version 6 Addressing Architecture\n+\t#   * RFC 2732 (Section  3) : Format for Literal IPv6 Addresses in URL's\n+\t#   * RFC 2396 (Sec. 3.2.2) : Uniform Resource Identifiers (URI): Generic Syntax\n+\t# Also, ports are allowed to be symbolic, so that /etc/services mappings\n+\t# can be used.\n+\n+\t# Define a port (RFC 2396 and extension):\n+\n+\tmy $port = qr/[\\w[:punct:]]+/;\n+\n+\t# Define an IPv4 address (RFC 2373):\n+\n+\tmy $dig3        = qr/\\d{1,3}/;\n+\tmy $IPv4address = qr/$dig3(?:\\.$dig3){3}/;\n+\n+\t# Define an IPv6 address (RFC 2373):\n+\n+\tmy $hex4        = qr/[[:xdigit:]]{1,4}/;\n+\tmy $hexseq      = qr/$hex4(?::$hex4)*/;  \t\t# RFC 2373 is really that loose.\n+\tmy $hexpart     = qr/$hexseq|$hexseq?::$hexseq?/;\n+\tmy $IPv6address = qr/$hexpart(?::$IPv4address)?/;\n+\n+\t# Define an IPv6 literal (RFC 2732):\n+\n+\tmy $IPv6reference = qr/\\[$IPv6address\\]/;\n+\n+\t# Define a server URI (RFC 2396 and RFC 2732):\n+\n+\tmy $toplabel    = qr/[[:alpha:]](?:(?:[[:alnum:]]|-)*[[:alpha:]])?/;\n+\tmy $domainlabel = qr/[[:alnum:]](?:(?:[[:alnum:]]|-)*[[:alnum:]])?/;\n+\tmy $hostname    = qr/(?:$domainlabel\\.)*$toplabel\\.?/;\n+\tmy $host        = qr/$hostname|$IPv4address|$IPv6reference/;\n+\tmy $hostport    = qr/^($host)(?::($port))?$/;\n+\n+\t# Phew! Now parse\n+\n+\treturn shift =~ $hostport;\n+}\n+\n+# Figure out how to contact the SMTP server.\n+# After this code, $smtp_server_port is either\n+# valid or undef:\n+\n+if (defined $smtp_server && $smtp_server ne '') {\n+\n+\tif ($smtp_server_is_a_command = ($smtp_server =~ m{^/})) {\n+\n+\t\tdie \"--smtp-server: The SMTP server command does not exist: $smtp_server\\n\"\n+\t\t\tunless -x $smtp_server;\n+\n+\t\tprint STDERR \"--smtp-server: Using command '$smtp_server'; ignoring --smtp-server-port='$smtp_server_port'\\n\"\n+\t\t\tif defined $smtp_server_port;\n+\n+\t} else {\n+\n+\t\t($smtp_server, my $port) = parse_server_URI $smtp_server\n+\t\t\tor die \"--smtp-server: Not a valid server URI: '$smtp_server'\\n\";\n+\n+\t\tif (defined $smtp_server_port) {\n+\n+\t\t\t$smtp_server_port =~ /[\\w[:punct:]]+/ or die \"--smtp-server-port: Invalid port: '$smtp_server_port'\\n\";\n+\n+\t\t\tprint STDERR \"--smtp-server-port: Using port '$smtp_server_port'; ignoring --smtp-server's port '$port'\\n\"\n+\t\t\t\tif defined $port;\n+\n+\t\t} else {\n+\n+\t\t\t$smtp_server_port = $port;\n+\t\t}\n+\t}\n+\n+} else { # use a default:\n+\n+\tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n+\t\tif (-x $_) {\n+\t\t\t$smtp_server = $_;\n+\t\t\t$smtp_server_is_a_command = 1;\n+\n+\t\t\tprint STDERR \"--smtp-server: Using command '$smtp_server'; ignoring --smtp-server-port='$smtp_server_port'\\n\"\n+\t\t\t\tif defined $smtp_server_port;\n+\n+\t\t\tlast;\n+\t\t}\n+\t}\n+\n+\t$smtp_server = 'localhost' # 127.0.0.1 is not compatible with IPv6\n+\t\tunless $smtp_server_is_a_command;\n+}\n+\n # Set CC suppressions\n my(%suppress_cc);\n if (@suppress_cc) {\n@@ -675,24 +770,6 @@ if (defined $initial_reply_to) {\n \t$initial_reply_to = \"<$initial_reply_to>\" if $initial_reply_to ne '';\n }\n \n-if (defined $smtp_server && $smtp_server ne '') {\n-\n-\t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n-\n-} else { # use a default:\n-\n-\tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n-\t\tif (-x $_) {\n-\t\t\t$smtp_server = $_;\n-\t\t\t$smtp_server_is_a_command = 1;\n-\t\t\tlast;\n-\t\t}\n-\t}\n-\n-\t$smtp_server = 'localhost' # 127.0.0.1 is not compatible with IPv6\n-\t\tunless $smtp_server_is_a_command;\n-}\n-\n if ($compose && $compose > 0) {\n \t@files = ($compose_filename . \".final\", @files);\n }\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111649","messageId":"b4087cc50904190739u54a9a9d7p6f011ab2b47c1d05@mail.gmail.com","threadId":"18939","inReplyTo":"76718490904190713l3d6b5abcmf54544512de87413@mail.gmail.com","subject":"Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T14:39:58Z","receivedAt":"2009-04-19T14:39:58Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 09:13, Jay Soffian <jaysoffian@gmail.com> wrote:\n> I think I was not clear. My suggestion was to move the /[^[:ascii:]]/\n> check to the inside of quote_rfc2047 exactly so that it doesn't always\n> change its input. i.e.\n\nAh. However, there is still the question of whether the actual email\nheaders are present to declare the right encoding. I don't know enough\nto comment on this, though; before this patch, this quoting was\nperformed by code that new to right the correct \"Content-Type\" and\n\"Content-Transfer-Encoding\" headers. I suppose I'll have to read the\nRFC.\n\n>\n>>        sub quote_rfc2047 {\n>>                local $_ = shift;\n>\n> Add this:\n>                 return $_ unless /[^[:ascii:]]/;\n>\n>>                my $encoding = shift || 'utf-8';\n>>                s/([^-a-zA-Z0-9!*+\\/])/sprintf(\"=%02X\", ord($1))/eg;\n>>                s/(.*)/=\\?$encoding\\?q\\?$1\\?=/;\n>>                return $_;\n>>        }\n>\n> This simplifies things for the function caller I think.\n\nI'm morally opposed to this kind of thing. The caller should be\nrequired to test whether quote_rfc2047() is required, as it's not the\njob of quote_rfc2047 to validate. Suppose that quote_rfc2047 were\nactually part of a library of useful functions that my program\nimports. Perhaps my program knows that it must always quote some piece\nof text. Why, then, should my program be forced to waste the cycles to\nperform a useless test?\n\nIMnsHO, verification should always be done by the caller with one\nexception: Interactive (human) input should always be verified,\nbecause humans represent an unreliable component in the system (in\nterms of digital systems, their asynchronous input must be\nsynchronized with the clocked system). WIth this model, there's are\nfewer wasted cycles, because you can reuse verification across similar\nfunctions, and the code (particularly library code) is easier to\nunderstand.\n"},{"id":"111650","messageId":"b4087cc50904190753v6f5862c0sebe2dcc56c5269dc@mail.gmail.com","threadId":"18939","inReplyTo":"b4087cc50904190739u54a9a9d7p6f011ab2b47c1d05@mail.gmail.com","subject":"Re: [PATCH RFC3.5 08/12] send-email: Move Subject sanitization from --compose code to send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T14:53:47Z","receivedAt":"2009-04-19T14:53:47Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 09:39, Michael Witten <mfwitten@gmail.com> wrote:\n> I'm morally opposed to this kind of thing. The caller should be\n> required to test whether quote_rfc2047() is required, as it's not the\n> job of quote_rfc2047 to validate. Suppose that quote_rfc2047 were\n> actually part of a library of useful functions that my program\n> imports. Perhaps my program knows that it must always quote some piece\n> of text. Why, then, should my program be forced to waste the cycles to\n> perform a useless test?\n>\n> IMnsHO, verification should always be done by the caller with one\n> exception: Interactive (human) input should always be verified,\n> because humans represent an unreliable component in the system (in\n> terms of digital systems, their asynchronous input must be\n> synchronized with the clocked system). WIth this model, there's are\n> fewer wasted cycles, because you can reuse verification across similar\n> functions, and the code (particularly library code) is easier to\n> understand.\n\nI should add, though, that making the logic of the program clear is a\ngood idea. In that sense, your approach makes sense. Since we 'own'\nquote_rfc2047(), I'd say we could take your approach, but rename the\nfunction to something like quote_rfc2047_if_necessary(). If\nquote_rfc2047() were part of a library, I think the only moral\nsolution would be to insist that callers wrap it in another function\nnamed quote_rfc2047_if_necessary().\n"},{"id":"111654","messageId":"1240159421-5643-1-git-send-email-mfwitten@gmail.com","threadId":"18939","inReplyTo":"b4087cc50904190753v6f5862c0sebe2dcc56c5269dc@mail.gmail.com","subject":"[PATCH RFC3.5.1 08/12] send-email: Simplify --compose subject sanitation","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-19T16:43:41Z","receivedAt":"2009-04-19T16:43:41Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"We might as well use the global variables while they exist; there's\nno reason to print the result to a file and then read it back in.\n\nAlso, the entire file is already read and checked for:\n\n\t/[^[:ascii:]]/\n\nby:\n\n\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n\nso we might as well use $need_8bit_cte until something less egregiously\ninefficient is implemented.\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-send-email.perl |    9 ++-------\n 1 files changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 3894a93..1f815d7 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -675,13 +675,8 @@ EOT\n \t\t} elsif (/^MIME-Version:/i) {\n \t\t\t$need_8bit_cte = 0;\n \t\t} elsif (/^Subject:\\s*(.+)\\s*$/i) {\n-\t\t\t$initial_subject = $1;\n-\t\t\tmy $subject = $initial_subject;\n-\t\t\t$_ = \"Subject: \" .\n-\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n-\t\t\t\t quote_rfc2047($subject) :\n-\t\t\t\t $subject) .\n-\t\t\t\t\"\\n\";\n+\t\t\t$initial_subject = $need_8bit_cte ? quote_rfc2047($1) : $1;\n+\t\t\tnext;\n \t\t} elsif (/^In-Reply-To:\\s*(.+)\\s*$/i) {\n \t\t\t$initial_reply_to = $1;\n \t\t\tnext;\n-- \n1.6.2.2.479.g2aec\n"},{"id":"111668","messageId":"7vljpwp0jr.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"1240074128-16132-6-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T01:38:00Z","receivedAt":"2009-04-20T01:38:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> +\n> +\t\t(my $pid = open my $pipe, '|-')\n> +\t\t\t// die \"Could not fork to run '$smtp_server': $!\\n\";\n\nHave I already rejected this \"5.10 or later\" construct in the previous\nround?  If I haven't, please consider now I have.\n"},{"id":"111669","messageId":"7veivop0dx.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"1240074128-16132-3-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T01:41:30Z","receivedAt":"2009-04-20T01:41:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> This is a minor change, but it's cleaner, and it sets up the\n> $smtp_server initialization code for future improvements.\n> ...\n> -if (!defined $smtp_server) {\n> +if (defined $smtp_server) {\n> +\n> +\t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n> +\n> +} else { # use a default:\n> +\n>  \tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n>  \t\tif (-x $_) {\n>  \t\t\t$smtp_server = $_;\n> +\t\t\t$smtp_server_is_a_command = 1;\n>  \t\t\tlast;\n>  \t\t}\n>  \t}\n> -\t$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n> +\n> +\t$smtp_server = 'localhost'; # 127.0.0.1 is not compatible with IPv6\n> +\t\tunless $smtp_server_is_a_command;\n\nNobody suggests to use 127.0.0.1 anymore with this change, so why not just\nget rid of that comment?\n\nAlso the new statement looks wrong.\n\n (1) you have ';' after assignment before the statement modifier \"unless\";\n     I do not think you meant it.  I generally *dis*like statement\n     modifiers, but if you use it, at least please use it correctly.\n\n (2) earlier, when $smtp_server is defined (say, the name of your smtp\n     host) but is not a command, we did not set smtp_server to\n     'localhost', but kept the value given by the user.  Now you seem to\n     kill the user's wish with this change.\n\nI think a genuine improvement would be something like:\n\n\tif (!defined $smtp_server) {\n        \t$smtp_server = 'localhost';\n\t}\n\nOf course if you are writing for a project that is \"5.8.1 or later only\",\nyou could say:\n\n\t$smtp_server //= 'localhost';\n"},{"id":"111670","messageId":"7v7i1gp0di.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"1240074128-16132-4-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T01:41:45Z","receivedAt":"2009-04-20T01:41:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> Why not? It's at least useful for testing.\n\nWhy so?  \"Use a default\" as opposed to using what?\n\nIt is unclear what \"a default\" is in this context.  Do configured values\ncount as \"a default\"?  I suspect not.\n\nI think you meant \"allow overriding the configured values and use the\ndefault\", but then you should spell what the defaults are (an available\nlocal MTA binary, or SMTP port on localhost, I think).  That is much more\ninformative than your \"Why not?...\"\n\nIn any case, I find it counterintuitive to trigger \"use the default\" with\nan option.  Something like \"--ignore-config=smtp-server,smtp-port\" might\nmake sense, though.\n"},{"id":"111671","messageId":"7vzlecnlsh.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"1240074128-16132-5-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 04/12] send-email: Verification for --smtp-server and --smpt-server-port","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T01:42:06Z","receivedAt":"2009-04-20T01:42:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> The server URI is verified according to RFCs (including IPv6 support).\n>\n> The $smtp_server and $smtp_server_port setup code has been moved\n> higher in the file, so that send-email fails fast if they are bad.\n>\n> Now, the 'host:port' server URI form is handled regardless of the\n> documentation deficiencies of Net::SMTP{,::SSL}.\n\nYou said that in 01/12, too but I do not think there is any problem with\nPerl documentation.\n\nMy installed copy of /usr/share/perl/5.10.0/Net/SMTP.pm has this:\n\n    B<Host> - SMTP host to connect to. It may be a single scalar, as defined for\n    the C<PeerAddr> option in L<IO::Socket::INET>, or a reference to\n    an array with hosts to try in turn. The L</host> method will return the value\n    which was used to connect to the host.\n\nand of course PeerAddr allows host:port.\n\nPlease stop placing a false blame on others.  I think it is you who lack\nability to read the documentation correctly in this particular case.\n"},{"id":"111672","messageId":"7vskk4nlrg.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"1240074128-16132-7-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T01:42:43Z","receivedAt":"2009-04-20T01:42:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> +\t\t\t\tdie \"Server does not support STARTTLS: \" . $smtp->message . \"\\n\"\n> +\t\t\t\t\tunless $smtp->code == 220;\n\nStatement modifiers merely make things even less readable, especially when\nthe conditional is the unlikely case.  Please do not add more of them.\n\n\tdo this;\n\tdo that;\n\tdo something\n        \tif some condition that holds true most of the time;\n\tdo some other thing;\n\nis already hard to follow, but it is probably excusable in some cases,\nbecause your thought can flow \"ah, Ok, these four things are done in\nsequence\" when you are quickly scanning the code to understand the overall\nstructure, letting your eyes ignore the \"true most of the time\" part.\n\nBut the following, which is equivalent to what you did, is inexcuable.\n\n\tdo this;\n\tdo that;\n\tdo something unusual\n        \tif some condition that rarely holds true;\n\tdo some other thing;\n\nWhen your eyes and brain are coasting over this segment of code, your\nthought process needs to stumble and hiccup at the statment that does\nsomething unusual, and then need to realize that it is qualified with a\nstatement modifier that says \"this is only for rare case\".\n\nWritten without statement modifier:\n\n\tdo this;\n\tdo that;\n\tif (some consition that rarely holds true) {\n\t\tdo something unusual\n        }\n\tdo some other thing;\n\nit is much easier to coast over; you can tell \"Ah, after doing this and\nthat, in the normal case we do some other thing\" and do not have to even\nlook at the details of \"something unusual\" part.\n\n> -\t\t$smtp->mail( $raw_from ) or die $smtp->message;\n> -\t\t$smtp->to( @recipients ) or die $smtp->message;\n> -\t\t$smtp->data or die $smtp->message;\n> -\t\t$smtp->datasend(\"$header\\n$message\") or die $smtp->message;\n> -\t\t$smtp->dataend() or die $smtp->message;\n> -\t\t$smtp->code =~ /250|200/ or die \"Failed to send $subject\\n\".$smtp->message;\n> +\t\tSEND_MAIL:\n> +\n> +\t\t$smtp->mail($raw_from)               and\n> +\t\t$smtp->to(@recipients)               and\n> +\t\t$smtp->data                          and\n> +\t\t$smtp->datasend(\"$header\\n$message\") and\n> +\t\t$smtp->dataend                       or\n> +\n> +\t\tdie \"Failed to send '$subject': \" . $smtp->message . \"\\n\";\n\nThese do make things more pleasant to read.\n"},{"id":"111673","messageId":"7vfxg4nl0e.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"7vljpwp0jr.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T01:58:57Z","receivedAt":"2009-04-20T01:58:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Michael Witten <mfwitten@gmail.com> writes:\n>\n>> +\n>> +\t\t(my $pid = open my $pipe, '|-')\n>> +\t\t\t// die \"Could not fork to run '$smtp_server': $!\\n\";\n>\n> Have I already rejected this \"5.10 or later\" construct in the previous\n> round?  If I haven't, please consider now I have.\n\nSorry, I should have checked myself.  defined-or \"//\" is 5.8.1 or later.\n\nNow the real question was if we still support anything older, and if so\nwhat is the bottom version?\n\nI certainly can go with \"5.8.1 or later\", but I vaguely recall during the\ngitweb discussion we said anything without the utf-8 support is unusable\nfor gitweb, but I think we also said that the rest of the git codebase\nshould support running with something older (5.6.1, perhaps).\n\nAnybody?\n"},{"id":"111674","messageId":"b4087cc50904191937x55f94dc3sb6fbda27f380b105@mail.gmail.com","threadId":"18939","inReplyTo":"7veivop0dx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a command","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T02:37:23Z","receivedAt":"2009-04-20T02:37:23Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 20:41, Junio C Hamano <gitster@pobox.com> wrote:\n> Michael Witten <mfwitten@gmail.com> writes:\n>\n>> This is a minor change, but it's cleaner, and it sets up the\n>> $smtp_server initialization code for future improvements.\n>> ...\n>> -if (!defined $smtp_server) {\n>> +if (defined $smtp_server) {\n>> +\n>> +     $smtp_server_is_a_command = ($smtp_server =~ m{^/});\n>> +\n>> +} else { # use a default:\n>> +\n>>       foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n>>               if (-x $_) {\n>>                       $smtp_server = $_;\n>> +                     $smtp_server_is_a_command = 1;\n>>                       last;\n>>               }\n>>       }\n>> -     $smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n>> +\n>> +     $smtp_server = 'localhost'; # 127.0.0.1 is not compatible with IPv6\n>> +             unless $smtp_server_is_a_command;\n>\n> Nobody suggests to use 127.0.0.1 anymore with this change, so why not just\n> get rid of that comment?\n\nFine with me.\n\n> Also the new statement looks wrong.\n>\n>  (1) you have ';' after assignment before the statement modifier \"unless\";\n>     I do not think you meant it.  I generally *dis*like statement\n>     modifiers, but if you use it, at least please use it correctly.\n\nHow embarassing. That's actually been fixed on my end since I sent\nthat patch; for some reason, I forget to send the update; sorry for\nwasting your time.\n\n>  (2) earlier, when $smtp_server is defined (say, the name of your smtp\n>     host) but is not a command, we did not set smtp_server to\n>     'localhost', but kept the value given by the user.  Now you seem to\n>     kill the user's wish with this change.\n\nI think you misread the code (with the exception of the error on my\npart). The code could be read:\n\n\tif $smtp_server is already defined {\n\t\tdetermine whether it is a command;\n\t} else {\n\t\tfind a suitable default for it;\n\t}\n\n> I think a genuine improvement would be something like:\n>\n>        if (!defined $smtp_server) {\n>                $smtp_server = 'localhost';\n>        }\n\nYou don't care to search for a possible sendmail?\n"},{"id":"111675","messageId":"7vzlecm4lg.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"7vzlecnlsh.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 04/12] send-email: Verification for --smtp-server and --smpt-server-port","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T02:38:51Z","receivedAt":"2009-04-20T02:38:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Please stop placing a false blame on others.  I think it is you who lack\n> ability to read the documentation correctly in this particular case.\n\nSorry, this came out stronger than I intended.  Your ability has never\nbeen an issue (otherwise there wouldn't have been this patch series).  I\nthink you just did not read the documentation carefully enough in this\ncase.\n"},{"id":"111677","messageId":"b4087cc50904191952x27ec0269nd12849688f720fb3@mail.gmail.com","threadId":"18939","inReplyTo":"7v7i1gp0di.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 03/12] send-email: Interpret --smtp-server \"\" as \"use a default\".","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T02:52:58Z","receivedAt":"2009-04-20T02:52:58Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 20:41, Junio C Hamano <gitster@pobox.com> wrote:\n> Michael Witten <mfwitten@gmail.com> writes:\n>\n>> Why not? It's at least useful for testing.\n>\n> Why so?  \"Use a default\" as opposed to using what?\n>\n\nUse a default as opposed to using the nonsensical empty string.\n\n> It is unclear what \"a default\" is in this context.  Do configured values\n> count as \"a default\"?  I suspect not.\n>\n> I think you meant \"allow overriding the configured values and use the\n> default\", but then you should spell what the defaults are (an available\n> local MTA binary, or SMTP port on localhost, I think).  That is much more\n> informative than your \"Why not?...\"\n\nI see your irritation is derived from my carefree (careless?) commit\nmessage. However, the patch doesn't do anything but trigger the\nalready present default-selecting code; there are already docs that\nspecify what those defaults are.\n\n> In any case, I find it counterintuitive to trigger \"use the default\" with\n> an option.  Something like \"--ignore-config=smtp-server,smtp-port\" might\n> make sense, though.\n\nI can get behind that kind of solution; however, I see no problem with\nthe shorthand --smtp-server \"\" either (other than the fact that it\nrequires an extra test in order to work).\n"},{"id":"111679","messageId":"49ebf2f6.050cc00a.2e8d.ffffbde4@mx.google.com","threadId":"18939","inReplyTo":"7vzlecm4lg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T03:49:29Z","receivedAt":"2009-04-20T03:49:29Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 20:42, Junio C Hamano <gitster@pobox.com> wrote:\n> Michael Witten <mfwitten@gmail.com> writes:\n> ...\n>> Now, the 'host:port' server URI form is handled regardless of the\n>> documentation deficiencies of Net::SMTP{,::SSL}.\n>\n> You said that in 01/12, too but I do not think there is any problem with\n> Perl documentation.\n>\n> My installed copy of /usr/share/perl/5.10.0/Net/SMTP.pm has this:\n>\n>    B<Host> - SMTP host to connect to. It may be a single scalar, as defined for\n>    the C<PeerAddr> option in L<IO::Socket::INET>, or a reference to\n>    an array with hosts to try in turn. The L</host> method will return the value\n>    which was used to connect to the host.\n>\n> and of course PeerAddr allows host:port.\n>\n> Please stop placing a false blame on others.  I think it is you who lack\n> ability to read the documentation correctly in this particular case.\n\nTake a look again at my commit message for 01/12:\n\n\tThe 'host:port' form of argument for --smtp-server was only\n\tworking for SSL connections, because the SSL connection code\n\twas relying on undocumented behavior of Net::SMTP::SSL (really,\n\tundocumented behavior of Net::SMTP's new method)...\n\nClearly my beef is with Net::SMTP--->::SSL<---\n\nI touch upon this in the commit message for 06/12:\n\n\tThe code could even be simplified further, because Net::SMTP{,::SSL}\n\tboth take the PORT variable in their new methods (which, as of this\n\tcommit, are actually the same method). Moreover, both take a server\n\tURI of the form 'host:port' that trumps any value passed to PORT.\n\n\tUnfortunately, none of this is documented publicly, so it isn't\n\texploited out of purity.\n\nNet::SMTP doesn't document the PORT key, even though it's the one that\nimplements the constructor for both Net::SMTP and Net::SMTP::SSL. Also,\nNet::SMTP:SSL doesn't document whether PORT shadows the ':port' in any\n'host:port' input.\n\nSo... I remain resolved in my stance: The documentation is poor and\n\"--smtp-server host:port\" only worked because the code relies on the\nundocumented behavior of the ':port' taking precedence of over any\nPORT specification. \n\n> I think you just did not read the documentation carefully enough in this\n> case.\n\nActually, I think I read it too carefully and thought about it too much.\n\nOn Sun, Apr 19, 2009 at 21:38, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Please stop placing a false blame on others.  I think it is you who lack\n>> ability to read the documentation correctly in this particular case.\n>\n> Sorry, this came out stronger than I intended.\n\nThat's OK. I tend to sound harsher than I want as well.\n\n> Your ability has never been an issue (otherwise there wouldn't have been\n> this patch series).\n\nI appreciate that remark; I'm admittedly not important, but I hope that\nI'm at least useful.\n\nNow let's get back to work!\n\nSincerely,\nMichael Witten\n"},{"id":"111680","messageId":"49ebf405.0609c00a.797d.ffffac3e@mx.google.com","threadId":"18939","inReplyTo":"7vzlecm4lg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 04/12] send-email: Verification for --smtp-server and --smpt-server-port","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T03:49:29Z","receivedAt":"2009-04-20T03:49:29Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 20:42, Junio C Hamano <gitster@pobox.com> wrote:\n> Michael Witten <mfwitten@gmail.com> writes:\n> ...\n>> Now, the 'host:port' server URI form is handled regardless of the\n>> documentation deficiencies of Net::SMTP{,::SSL}.\n>\n> You said that in 01/12, too but I do not think there is any problem with\n> Perl documentation.\n>\n> My installed copy of /usr/share/perl/5.10.0/Net/SMTP.pm has this:\n>\n>    B<Host> - SMTP host to connect to. It may be a single scalar, as defined for\n>    the C<PeerAddr> option in L<IO::Socket::INET>, or a reference to\n>    an array with hosts to try in turn. The L</host> method will return the value\n>    which was used to connect to the host.\n>\n> and of course PeerAddr allows host:port.\n>\n> Please stop placing a false blame on others.  I think it is you who lack\n> ability to read the documentation correctly in this particular case.\n\nTake a look again at my commit message for 01/12:\n\n\tThe 'host:port' form of argument for --smtp-server was only\n\tworking for SSL connections, because the SSL connection code\n\twas relying on undocumented behavior of Net::SMTP::SSL (really,\n\tundocumented behavior of Net::SMTP's new method)...\n\nClearly my beef is with Net::SMTP--->::SSL<---\n\nI touch upon this in the commit message for 06/12:\n\n\tThe code could even be simplified further, because Net::SMTP{,::SSL}\n\tboth take the PORT variable in their new methods (which, as of this\n\tcommit, are actually the same method). Moreover, both take a server\n\tURI of the form 'host:port' that trumps any value passed to PORT.\n\n\tUnfortunately, none of this is documented publicly, so it isn't\n\texploited out of purity.\n\nNet::SMTP doesn't document the PORT key, even though it's the one that\nimplements the constructor for both Net::SMTP and Net::SMTP::SSL. Also,\nNet::SMTP:SSL doesn't document whether PORT shadows the ':port' in any\n'host:port' input.\n\nSo... I remain resolved in my stance: The documentation is poor and\n\"--smtp-server host:port\" only worked because the code relies on the\nundocumented behavior of the ':port' taking precedence of over any\nPORT specification. \n\n> I think you just did not read the documentation carefully enough in this\n> case.\n\nActually, I think I read it too carefully and thought about it too much.\n\nOn Sun, Apr 19, 2009 at 21:38, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Please stop placing a false blame on others.  I think it is you who lack\n>> ability to read the documentation correctly in this particular case.\n>\n> Sorry, this came out stronger than I intended.\n\nThat's OK. I tend to sound harsher than I want as well.\n\n> Your ability has never been an issue (otherwise there wouldn't have been\n> this patch series).\n\nI appreciate that remark; I'm admittedly not important, but I hope that\nI'm at least useful.\n\nNow let's get back to work!\n\nSincerely,\nMichael Witten\n"},{"id":"111681","messageId":"7viql0lzuw.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"b4087cc50904191937x55f94dc3sb6fbda27f380b105@mail.gmail.com","subject":"Re: [PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T04:21:11Z","receivedAt":"2009-04-20T04:21:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> On Sun, Apr 19, 2009 at 20:41, Junio C Hamano <gitster@pobox.com> wrote:\n>> Michael Witten <mfwitten@gmail.com> writes:\n>>\n>>> This is a minor change, but it's cleaner, and it sets up the\n>>> $smtp_server initialization code for future improvements.\n>>> ...\n>>> -if (!defined $smtp_server) {\n>>> +if (defined $smtp_server) {\n>>> +\n>>> +     $smtp_server_is_a_command = ($smtp_server =~ m{^/});\n>>> +\n>>> +} else { # use a default:\n>>> +\n>>>       foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n>>>               if (-x $_) {\n>>>                       $smtp_server = $_;\n>>> +                     $smtp_server_is_a_command = 1;\n>>>                       last;\n>>>               }\n>>>       }\n>>> -     $smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*\n>>> +\n>>> +     $smtp_server = 'localhost'; # 127.0.0.1 is not compatible with IPv6\n>>> +             unless $smtp_server_is_a_command;\n> ...\n>> I think a genuine improvement would be something like:\n>>\n>>        if (!defined $smtp_server) {\n>>                $smtp_server = 'localhost';\n>>        }\n>\n> You don't care to search for a possible sendmail?\n\nThat's something you already did before setting smtp_server\nunconditionally to localhost, right?  You do (in the above):\n\n\tif (user gave $smtp_server) {\n        \tuse it, notice and note if it is a command;\n\t} else {\n                if (standard binary avaiable) {\n                \tuse it, note it is a command;\n\t\t}\n                # otherwise it still is undef\n\t}\n\tif (!defined $smtp_server) {\n        \tset it to localhost;\n\t}\n\nBut I would probably write it this way:\n\n\tif (user didn't give us $smtp_server) {\n                if (standard binary avaiable) {\n                \tuse it, note it is a command;\n\t\t} else {\n                \tuse localhost;\n\t\t}\n\t}\n\tif ($smtp_server looks like a command) {\n        \t$smtp_server_is_a_command = true;\n\t}\n"},{"id":"111683","messageId":"49ec020a.050cc00a.2a50.ffffd0e3@mx.google.com","threadId":"18939","inReplyTo":"7viql0lzuw.fsf@gitster.siamese.dyndns.org","subject":"Subject: Re: [PATCH RFC3.5 02/12] send-email: No longer repeatedly test if $smtp_server is a command","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T04:53:16Z","receivedAt":"2009-04-20T04:53:16Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 23:21, Junio C Hamano <gitster@pobox.com> wrote:\n> Michael Witten <mfwitten@gmail.com> writes:\n>\n>> ...\n>>> I think a genuine improvement would be something like:\n>>>\n>>> \tif (!defined $smtp_server) {\n>>> \t\t$smtp_server = 'localhost';\n>>> \t}\n>>\n>> You don't care to search for a possible sendmail?\n>\n> That's something you already did before setting smtp_server\n> unconditionally to localhost, right?  You do (in the above):\n>\n> \tif (user gave $smtp_server) {\n> \t\tuse it, notice and note if it is a command;\n> \t} else {\n> \t\tif (standard binary avaiable) {\n> \t\t\tuse it, note it is a command;\n> \t\t}\n> \t\t# otherwise it still is undef\n> \t}\n> \tif (!defined $smtp_server) {\n> \t\tset it to localhost;\n> \t}\n>\n> But I would probably write it this way:\n>\n> \tif (user didn't give us $smtp_server) {\n> \t\tif (standard binary avaiable) {\n> \t\t\tuse it, note it is a command;\n> \t\t} else {\n> \t\t\tuse localhost;\n> \t\t}\n> \t}\n> \tif ($smtp_server looks like a command) {\n> \t\t$smtp_server_is_a_command = true;\n> \t}\n>\n>\n\nI suppose it's hard to tell from the patch, but it's actually\na combination of those two:\n\n\tif (user gave $smtp_server) {\n\t\tuse it, notice and note if it is a command;\n\t} else { # use a default:\n\t\tif (standard binary avaiable) {\n\t\t\tuse it, note it is a command;\n\t\t} else {\n\t\t\tuse localhost;\n\t\t\t# automatically noted as a command\n\t\t\t# without doing anything (this would\n\t\t\t# cause warnings if $smtp_is_a_command\n\t\t\t# is used in places other than the bool\n\t\t\t# context, because it will be undef);\n\t\t\t# thus, my choice is a bad choice in\n\t\t\t# the long run, but I'm sticking to it.\n\t\t}\n\t}\n\nThe actual code:\n\n\tif (defined $smtp_server) {\n\n\t\t$smtp_server_is_a_command = ($smtp_server =~ m{^/});\n\n\t} else { # use a default:\n\n\t\tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n\t\t\tif (-x $_) {\n\t\t\t\t$smtp_server = $_;\n\t\t\t\t$smtp_server_is_a_command = 1;\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\n\t\t$smtp_server = 'localhost' # 127.0.0.1 is not compatible with IPv6\n\t\t\tunless $smtp_server_is_a_command;\n\t}\n\n(I'll remove the \"127.0.0.1\" comment).\n\nThere's a minimum of checking and assigning; it's beautiful.\nPlus, this organization fits in well with the server/port\nverification (if I recall).\n\nP.S.\n\nI also like:\n\n\t$smtp_server_is_a_command or ($smtp_server = 'localhost');\n\nor, maybe:\n\n\t$smtp_server_is_a_command or $smtp_server = 'localhost;\n\nHowever, I wasn't sure if that is acceptable to others; more\nimportantly (:-D), I'm not sure that perl is smart enough to\noptimize away the unnecessary comparison of the values, so I\nfigured that the modifier 'unless' is morally superior, because\nit probably has the advantage of fewer cycles than the 'or' form,\nand it has greater readability than the curly-braced conditional.\nI absolutely loathe curly braces around a body of one line:\n\n\tif ($you_loath_this) {\n\t\tprint \"Clap Your Hands!\\n\";\n\t}\n\nIf only the curly-braces weren't there. I don't know why, they\njust bug me terribly.\n"},{"id":"111684","messageId":"b4087cc50904192238j744f353dtf5f6a616cada8cd8@mail.gmail.com","threadId":"18939","inReplyTo":"7vskk4nlrg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T05:38:50Z","receivedAt":"2009-04-20T05:38:50Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 20:42, Junio C Hamano <gitster@pobox.com> wrote:\n> Michael Witten <mfwitten@gmail.com> writes:\n>\n>> +                             die \"Server does not support STARTTLS: \" . $smtp->message . \"\\n\"\n>> +                                     unless $smtp->code == 220;\n>\n> ...\n> But the following, which is equivalent to what you did, is inexcuable.\n>\n>        do this;\n>        do that;\n>        do something unusual\n>                if some condition that rarely holds true;\n>        do some other thing;\n>\n> When your eyes and brain are coasting over this segment of code, your\n> thought process needs to stumble and hiccup at the statment that does\n> something unusual, and then need to realize that it is qualified with a\n> statement modifier that says \"this is only for rare case\".\n\nI mostly agree, and I frequently consider[ed] exactly those points.\nHowever, there are 2 things that played a role in my decision:\n\n    * For most conditional cases, I personally\n      loathe curly braces around one statement.\n\n    * The flow is actually:\n\n            do this;\n            do that;\n\n            DIE \"whisper some curses with the last breath\"\n                UNLESS some condition that holds mostly true;\n\n            do some other thing;\n\n      The \"die\" and thoughtful spacing should be pretty good clues.\n      However, the \"unless\" can be strange to think with (at first);\n      I figured Perlers would be happy with it.\n\nIn any case, I also like:\n\n    condition and/or (do something);\n\nor:\n\n    condition and/or do something;\n\nThe only thing keeping me from using that more often is that I assume\nother people would be less comfortable with it and that it may\nintroduce an unnecessary comparison of the return value of \"do\nsomething\"; also, it might make the line a little long, which some\npeople get really angry about.\n\n> Written without statement modifier:\n>\n>        do this;\n>        do that;\n>        if (some consition that rarely holds true) {\n>                do something unusual\n>        }\n>        do some other thing;\n\nI just have a hard time stomaching those curly braces. I really wish\nperl didn't enforce them when there's only one statement. Also, I\nwould use some whitespace:\n\n    do this;\n    do that;\n\n    if (some consition that rarely holds true) {\n        do something unusual\n    }\n\n    do some other thing;\n\n>> +             $smtp->mail($raw_from)               and\n>> +             $smtp->to(@recipients)               and\n>> +             $smtp->data                          and\n>> +             $smtp->datasend(\"$header\\n$message\") and\n>> +             $smtp->dataend                       or\n>> +\n>> +             die \"Failed to send '$subject': \" . $smtp->message . \"\\n\";\n>\n> These do make things more pleasant to read.\n\nThanks!\n\nP.S.\n\nSorry if the formatting of this email is bad; I'm in the middle of a\nlarge move between systems, and currently I'm stuck with gmail's\nwebmail, which insists on reformatting my text and refusing to render\nin fixed-width font (though I bet I could hack firefox's css to get\nthat one working.... hmmm.....), and firefox doesn't make it easy to\ninput tabs.\n\nSo, I've actually been writing and sending some emails with a combination of:\n\n    * vim\n    * date +'%a, %e %b %Y %T %z'\n    * uuidgen (though I've found gmail makes a Message-ID for me)\n    * cat path/to/email.txt | perl -pe 's/\\n/\\r\\n/; END {print\n\"\\r\\n\"}' | msmtp -t\n\nThis email was written in the webmail in firefox; I actually counted\nspaces for indentation in the hope that things line up. ;-)\n"},{"id":"111686","messageId":"7veivnlt9l.fsf@gitster.siamese.dyndns.org","threadId":"18939","inReplyTo":"b4087cc50904192238j744f353dtf5f6a616cada8cd8@mail.gmail.com","subject":"Re: [PATCH RFC3.5 06/12] send-email: Cleanup and streamline the SMTP code in send_message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-20T06:43:34Z","receivedAt":"2009-04-20T06:43:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> In any case, I also like:\n>\n>     condition and/or (do something);\n>\n> or:\n>\n>     condition and/or do something;\n\nI do not have problem with (condition and/or do this).\n\nWhat I complained about was statement modifier that interrupts your\nthought process and forces you to read things twice.  You see \"DIE\", and\nyou have to stop \"Huh?\".  You only realize that the author did not mean to\nsay \"always die here\" after seeing the modifier that changes the meaning\nof \"die\" to \"only under this rare condition--sorry, I did not say this\nupfront, but I am checking for errors.\"\n\nI just do not want to hear \"sorry, I did not say this upfront\" part.  IOW,\nI have much less problem with this:\n\n\tdo this;\n\tdo that;\n\tcondition that usually holds true\n        \tor die ...\n\tdo some other thing;\n"},{"id":"111751","messageId":"b4087cc50904200853x225acbafne421e4edb6120dbb@mail.gmail.com","threadId":"18939","inReplyTo":"1240150785-3999-1-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5.1 04/12] send-email: Verification for --smtp-server and --smpt-server-port","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-20T15:53:11Z","receivedAt":"2009-04-20T15:53:11Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Sun, Apr 19, 2009 at 09:19, Michael Witten <mfwitten@gmail.com> wrote:\n> +               ($smtp_server, my $port) = parse_server_URI $smtp_server\n> +                       or die \"--smtp-server: Not a valid server URI: '$smtp_server'\\n\";\n\nWhoops! I used to have:\n\n    my ($host, $port) = ...\n\nbut I tried to be clever and replaced it with the above.\nUnfortunately, that means that an incorrect server 'URI' sets\n$smtp_server to undef, which perl complains about when it interpolates\nthe die string.\n"},{"id":"111821","messageId":"20090421020021.GA14479@coredump.intra.peff.net","threadId":"18939","inReplyTo":"7vfxg4nl0e.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-21T02:00:22Z","receivedAt":"2009-04-21T02:00:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Apr 19, 2009 at 06:58:57PM -0700, Junio C Hamano wrote:\n\n> >> +\t\t(my $pid = open my $pipe, '|-')\n> >> +\t\t\t// die \"Could not fork to run '$smtp_server': $!\\n\";\n> >\n> > Have I already rejected this \"5.10 or later\" construct in the previous\n> > round?  If I haven't, please consider now I have.\n> \n> Sorry, I should have checked myself.  defined-or \"//\" is 5.8.1 or later.\n\nI don't think that's right. perl581delta lists it in the \"Future\nDirections\" section and says\n\n  A new operator \"//\" (defined-or) _will_ be available.\n\n(emphasis mine). I don't think it was in a stable version until 5.10\n(where it is listed as \"now this is available\" in perl5100delta.\nWhich puts it squarely in the \"too new to use\" list.\n\n-Peff\n"},{"id":"111825","messageId":"20090421023423.GB14479@coredump.intra.peff.net","threadId":"18939","inReplyTo":"1240159421-5643-1-git-send-email-mfwitten@gmail.com","subject":"Re: [PATCH RFC3.5.1 08/12] send-email: Simplify --compose subject sanitation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-21T02:34:23Z","receivedAt":"2009-04-21T02:34:23Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Apr 19, 2009 at 11:43:41AM -0500, Michael Witten wrote:\n\n>  \t\t} elsif (/^Subject:\\s*(.+)\\s*$/i) {\n> -\t\t\t$initial_subject = $1;\n> -\t\t\tmy $subject = $initial_subject;\n> -\t\t\t$_ = \"Subject: \" .\n> -\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n> -\t\t\t\t quote_rfc2047($subject) :\n> -\t\t\t\t $subject) .\n> -\t\t\t\t\"\\n\";\n> +\t\t\t$initial_subject = $need_8bit_cte ? quote_rfc2047($1) : $1;\n> +\t\t\tnext;\n\nI don't think this is a good idea. need_8bit_cte is about the _whole_\nmessage, including all headers, and this is just about the subject.\nWhich means that we end up rfc2047-encoding the subject unnecessarily\nquite a bit (since at least in git itself, most of the time the\nnon-ascii bits are in people's names).\n\nThis makes the subject unnecessarily ugly for readers which don't do\nrfc2047 decoding. And while I expect that most real MUAs these days\nhandle the decoding, it also makes life harder for people looking\ndirectly at message, or doing \"grep -i ^subject: foo.mbox\". Yes, I know\nthat doesn't even remotely follow the standards (e.g., it won't handle\nline-wrapped headers), but I don't see any need to make it worse.\n\nAll of that being said, even if we decided that it _is_ OK to quote\neven when it wasn't unnecessary, your patch still isn't right.\nneed_8bit_cte is not \"does this message need an 8-bit cte at all?\" but\nrather \"does _we_ need to add an 8-bit cte?\". A few lines above the ones\nyou changed, notice that when we see the message already has a\nMIME-Version header, we turn set $need_8bit_cte to 0. But in that case,\nwe still may need to encode the subject if it has non-ascii characters.\n\n-Peff\n"},{"id":"111831","messageId":"20090421031408.GA18596@coredump.intra.peff.net","threadId":"18939","inReplyTo":"20090421020021.GA14479@coredump.intra.peff.net","subject":"Re: [PATCH RFC3.5 05/12] send-email: Improve redability and error-handling in send_message's sendmail code","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-21T03:14:08Z","receivedAt":"2009-04-21T03:14:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Apr 20, 2009 at 10:00:21PM -0400, Jeff King wrote:\n\n> I don't think that's right. perl581delta lists it in the \"Future\n> Directions\" section and says\n> \n>   A new operator \"//\" (defined-or) _will_ be available.\n\nBah, sorry for the noise. I didn't realize this was described with much\nmore detail in another thread (a pox on thread-breakers!):\n\n  http://article.gmane.org/gmane.comp.version-control.git/117006\n\n-Peff\n"},{"id":"111833","messageId":"b4087cc50904202029h3b9fee7p18e466d6aee0c133@mail.gmail.com","threadId":"18939","inReplyTo":"20090421023423.GB14479@coredump.intra.peff.net","subject":"Re: [PATCH RFC3.5.1 08/12] send-email: Simplify --compose subject sanitation","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-21T03:29:20Z","receivedAt":"2009-04-21T03:29:20Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Mon, Apr 20, 2009 at 21:34, Jeff King <peff@peff.net> wrote:\n> A few lines above the ones\n> you changed, notice that when we see the message already has a\n> MIME-Version header, we turn set $need_8bit_cte to 0. But in that case,\n> we still may need to encode the subject if it has non-ascii characters.\n\nI think this is the only problem with the patch, and I'm glad you\ncaught it. However, I can't make further comment until I read the RFC,\nso I'm going to withdraw his patch from consideration. Thanks!\n"}]}