{"thread":{"id":"23388","subject":"[PATCH 1/3] send-email: Don't use FQDNs without a '.'","startedAt":"2010-04-09T05:11:43Z","lastAt":"2010-04-16T17:00:16Z","messageCount":12,"participants":["Brian Gernhardt","Junio C Hamano","Jakub Narebski","Jari Aalto"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"139005","messageId":"1270789906-23735-1-git-send-email-brian@gernhardtsoftware.com","threadId":"23388","inReplyTo":null,"subject":"[PATCH 0/3] send-email: --smtp-domain improvements","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-04-09T05:11:43Z","receivedAt":"2010-04-09T05:11:43Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"The first patch keeps send-email from using a bogus FQDN for my laptop.\nOddly enough, my MTA doesn't mind \"localhost.localdomain\" but complains\nabout \"My-Computer\".\n\nThe second adds documentation for --smtp-domain to the git-send-email man\npage.  The only documentation for it was in the code and the usage message.\n\nThe last is just an enhancement, but I was honestly surprised that\n--smtp-domain didn't have a configuration.\n\nBrian Gernhardt (3):\n  send-email: Don't use FQDNs without a '.'\n  Document send-email --smtp-domain\n  send-email: Add sendemail.smtpdomain\n\n Documentation/git-send-email.txt |    7 +++++++\n git-send-email.perl              |   26 ++++++++++++++------------\n 2 files changed, 21 insertions(+), 12 deletions(-)\n"},{"id":"139004","messageId":"1270789906-23735-2-git-send-email-brian@gernhardtsoftware.com","threadId":"23388","inReplyTo":"1270789906-23735-1-git-send-email-brian@gernhardtsoftware.com","subject":"[PATCH 1/3] send-email: Don't use FQDNs without a '.'","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-04-09T05:11:44Z","receivedAt":"2010-04-09T05:11:44Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"Although Net::Domain::domainname attempts to be very thorough, the\nhost's configuration can still refuse to give a FQDN.  Check to see if\nwhat we receive contains a dot as a basic sanity check.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n My OS X machine doesn't add \".local\" to it's hostname for some reason.\n Since a FQDN requires at least one . between the TLD and hostname,\n we can check for it to avoid nonsense results like \"My-Computer\".\n\n git-send-email.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ce569a9..85fe374 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -870,7 +870,8 @@ sub maildomain_net\n \tif (eval { require Net::Domain; 1 }) {\n \t\tmy $domain = Net::Domain::domainname();\n \t\t$maildomain = $domain\n-\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/\n+\t\t\t\tor $domain !~ /\\./;\n \t}\n \n \treturn $maildomain;\n@@ -888,7 +889,8 @@ sub maildomain_mta\n \t\t\t\t$smtp->quit;\n \n \t\t\t\t$maildomain = $domain\n-\t\t\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/\n+\t\t\t\t\t\tor $domain !~ /\\./;\n \n \t\t\t\tlast if $maildomain;\n \t\t\t}\n-- \n1.7.1.rc0.210.ge6da\n"},{"id":"139006","messageId":"1270789906-23735-3-git-send-email-brian@gernhardtsoftware.com","threadId":"23388","inReplyTo":"1270789906-23735-1-git-send-email-brian@gernhardtsoftware.com","subject":"[PATCH 2/3] Document send-email --smtp-domain","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-04-09T05:11:45Z","receivedAt":"2010-04-09T05:11:45Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n --smtp-debug is still undocumented.  It also appears to be a boolean that\n takes 0 or 1 instead of being of the form --[no-]smtp-debug.\n\n Documentation/git-send-email.txt |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex ced35b2..f171471 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -119,6 +119,12 @@ Sending\n \tvalue reverts to plain SMTP.  Default is the value of\n \t'sendemail.smtpencryption'.\n \n+--smtp-domain=<FQDN>::\n+\tSpecifies the Fully Qualified Domain Name (FQDN) used in the\n+\tHELO/EHLO command to the SMTP server.  Some servers require the\n+\tFQDN to match your IP address.  If not set, git send-email attempts\n+\tto determine your FQDN automatically.\n+\n --smtp-pass[=<password>]::\n \tPassword for SMTP-AUTH. The argument is optional: If no\n \targument is specified, then the empty string is used as\n-- \n1.7.1.rc0.210.ge6da\n"},{"id":"139007","messageId":"1270789906-23735-4-git-send-email-brian@gernhardtsoftware.com","threadId":"23388","inReplyTo":"1270789906-23735-1-git-send-email-brian@gernhardtsoftware.com","subject":"[PATCH 3/3] send-email: Add sendemail.smtpdomain","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-04-09T05:11:46Z","receivedAt":"2010-04-09T05:11:46Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"--smtp-domain is an option that if you need once, you probably will\nneed again.  To help with that, allow the user to set it in their\n.gitconfig\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n Seemed like a natural thing to add.  Was surprised it wasn't there when I went\n poking around.\n\n Documentation/git-send-email.txt |    3 ++-\n git-send-email.perl              |   20 ++++++++++----------\n 2 files changed, 12 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex f171471..288a4ec 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -123,7 +123,8 @@ Sending\n \tSpecifies the Fully Qualified Domain Name (FQDN) used in the\n \tHELO/EHLO command to the SMTP server.  Some servers require the\n \tFQDN to match your IP address.  If not set, git send-email attempts\n-\tto determine your FQDN automatically.\n+\tto determine your FQDN automatically.  Default is the value of\n+\t'sendemail.smtpdomain'.\n \n --smtp-pass[=<password>]::\n \tPassword for SMTP-AUTH. The argument is optional: If no\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 85fe374..14b996e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -132,8 +132,7 @@ my $have_email_valid = eval { require Email::Valid; 1 };\n my $have_mail_address = eval { require Mail::Address; 1 };\n my $smtp;\n my $auth;\n-my $mail_domain_default = \"localhost.localdomain\";\n-my $mail_domain;\n+my $smtp_domain_default = \"localhost.localdomain\";\n \n sub unique_email_list(@);\n sub cleanup_compose_files();\n@@ -190,7 +189,7 @@ sub do_edit {\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 ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);\n+my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);\n my ($validate, $confirm);\n my (@suppress_cc);\n \n@@ -212,6 +211,7 @@ my %config_settings = (\n     \"smtpserverport\" => \\$smtp_server_port,\n     \"smtpuser\" => \\$smtp_authuser,\n     \"smtppass\" => \\$smtp_authpass,\n+\t\"smtpdomain\" => \\$smtp_domain,\n     \"to\" => \\@to,\n     \"cc\" => \\@initial_cc,\n     \"cccmd\" => \\$cc_cmd,\n@@ -283,7 +283,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-ssl\" => sub { $smtp_encryption = 'ssl' },\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"smtp-debug:i\" => \\$debug_net_smtp,\n-\t\t    \"smtp-domain:s\" => \\$mail_domain,\n+\t\t    \"smtp-domain:s\" => \\$smtp_domain,\n \t\t    \"identity=s\" => \\$identity,\n \t\t    \"annotate\" => \\$annotate,\n \t\t    \"compose\" => \\$compose,\n@@ -902,7 +902,7 @@ sub maildomain_mta\n \n sub maildomain\n {\n-\treturn maildomain_net() || maildomain_mta() || $mail_domain_default;\n+\treturn maildomain_net() || maildomain_mta() || $smtp_domain_default;\n }\n \n # Returns 1 if the message was sent, and 0 otherwise.\n@@ -1007,18 +1007,18 @@ X-Mailer: git-send-email $gitversion\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$mail_domain ||= maildomain();\n+\t\t\t$smtp_domain ||= maildomain();\n \t\t\t$smtp ||= Net::SMTP::SSL->new($smtp_server,\n-\t\t\t\t\t\t      Hello => $mail_domain,\n+\t\t\t\t\t\t      Hello => $smtp_domain,\n \t\t\t\t\t\t      Port => $smtp_server_port);\n \t\t}\n \t\telse {\n \t\t\trequire Net::SMTP;\n-\t\t\t$mail_domain ||= maildomain();\n+\t\t\t$smtp_domain ||= maildomain();\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\t\t\t\t Hello => $mail_domain,\n+\t\t\t\t\t\t Hello => $smtp_domain,\n \t\t\t\t\t\t Debug => $debug_net_smtp);\n \t\t\tif ($smtp_encryption eq 'tls' && $smtp) {\n \t\t\t\trequire Net::SMTP::SSL;\n@@ -1041,7 +1041,7 @@ X-Mailer: git-send-email $gitversion\n \t\t\tdie \"Unable to initialize SMTP properly. Check config and use --smtp-debug. \",\n \t\t\t    \"VALUES: server=$smtp_server \",\n \t\t\t    \"encryption=$smtp_encryption \",\n-\t\t\t    \"maildomain=$mail_domain\",\n+\t\t\t    \"maildomain=$smtp_domain\",\n \t\t\t    defined $smtp_server_port ? \"port=$smtp_server_port\" : \"\";\n \t\t}\n \n-- \n1.7.1.rc0.210.ge6da\n"},{"id":"139010","messageId":"7v1vep427o.fsf@alter.siamese.dyndns.org","threadId":"23388","inReplyTo":"1270789906-23735-2-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH 1/3] send-email: Don't use FQDNs without a '.'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-09T05:36:11Z","receivedAt":"2010-04-09T05:36:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n\n>  \t\t$maildomain = $domain\n> -\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n> +\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/\n> +\t\t\t\tor $domain !~ /\\./;\n\nIt would become *much* easier to read if we stop using the statement\nmodifier, and write it in a more straightforward way:\n\n\tunless (($^O eq 'darwin' && $domain =~ /\\.local$/)\n        \t|| $domain !~ /\\./) {\n                $maildomain = $domain;\n\t}\n\nas the condition seems to have grown large enough to exceed \"by the way\ndon't do this under this narrow condition\", which is what statement\nmodifiers are designed to be used.  Also mixing && and or that have\ndifferent precedence taxes readers' brainpower unnecessarily.\n\nI also think that this particular exception logic should probably be in a\nseparate helper function that is called from the two places.\n\nJari, you are the last person who touched code around this area.  What do\nyou think?\n"},{"id":"139018","messageId":"m3wrwhglnd.fsf@localhost.localdomain","threadId":"23388","inReplyTo":"1270789906-23735-4-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH 3/3] send-email: Add sendemail.smtpdomain","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-09T06:56:30Z","receivedAt":"2010-04-09T06:56:30Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n\n> --smtp-domain is an option that if you need once, you probably will\n> need again.  To help with that, allow the user to set it in their\n> .gitconfig\n             via 'sendemail.smtpdomain' ?\n> \n> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n> ---\n> \n>  Seemed like a natural thing to add.  Was surprised it wasn't there when I went\n>  poking around.\n> \n>  Documentation/git-send-email.txt |    3 ++-\n>  git-send-email.perl              |   20 ++++++++++----------\n>  2 files changed, 12 insertions(+), 11 deletions(-)\n\nYou should also add one-liner to Documentation/config.txt, mentioning\n'sendemail.smtpdomain' configuration variable (the part referring reader\nto git-send-email(1) documentation).\n\n\nP.S. Some of git-send-email configuration variables: sendemail.identity,\nsendemail.smtpencryption, sendemail.smtpssl (deprecated), and the concept\nof sendemail.<identity>.* are described in Documentation/config.txt, \nwhich means that they are present in git-config(1) manpage.  Some of them\nare described in \"Configuration\" section of Documentation/git-send-email.txt\n(which means git-send-email(1) manpage): sendemail.aliasesfile, \nsendemail.aliasfiletype, sendemail.multiedit, sendemail.confirm; I think\nthose are config variables which do not have corresponding command line\noption.  The rest: sendemail.bcc, sendemail.cc, sendemail.from, \nsendemail.to, sendemail.envelopesender, sendemail.smtpencryption (which\nis described in git-config(1)), sendemail.smtppass, sendemail.smtpserver,\nsendemail.smtpserverport, sendemail.smtpuser, sendemail.cccmd, \nsendemail.chainreplyto, sendemail.identity and 'sendemail.<identity>' \nsubsection (described in git-config(1)), sendemail.signedoffbycc,\nsendemail.suppresscc, sendemail.suppressfrom, sendemail.thread, and\nsendemail.validate are described only with corresponding command-line\noption.\n\nHuh...\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"139399","messageId":"87ljcrwxni.fsf_-_@jondo.cante.net","threadId":"23388","inReplyTo":"7v1vep427o.fsf@alter.siamese.dyndns.org","subject":"[PATCH] git-send-email.perl: Add sub maildomain_sanitize","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-13T08:43:13Z","receivedAt":"2010-04-13T08:43:13Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"Move duplicate maildomain checks to a single subroutine.\nRequire that a FQDN contains at least one period.\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-send-email.perl |   21 +++++++++++++++++----\n 1 files changed, 17 insertions(+), 4 deletions(-)\n\n    Here is improved version.\n\n    -- Jari\n\n    >Re: [PATCH 1/3] send-email: Don't use FQDNs without a '.'\n    >Junio C Hamano <gitster@pobox.com> writes:\n    >> Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n    >\n    >>  \t\t$maildomain = $domain\n    >> -\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n    >> +\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/\n    >> +\t\t\t\tor $domain !~ /\\./;\n    >\n    > [Junio] It would become *much* easier to read if we stop using the statement\n    > modifier, and write it in a more straightforward way:\n    >\n    > \tunless (($^O eq 'darwin' && $domain =~ /\\.local$/)\n    >         \t|| $domain !~ /\\./) {\n    >                 $maildomain = $domain;\n    > \t}\n    >\n    > as the condition seems to have grown large enough to exceed \"by the way\n    > don't do this under this narrow condition\", which is what statement\n    > modifiers are designed to be used.  Also mixing && and or that have\n    > different precedence taxes readers' brainpower unnecessarily.\n    >\n    > I also think that this particular exception logic should probably be in a\n    > separate helper function that is called from the two places.\n    >\n    > Jari, you are the last person who touched code around this area.  What do\n    > you think?\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ce569a9..7a1c00f 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -863,14 +863,28 @@ sub sanitize_address\n # This maildomain*() code is based on ideas in Perl library Test::Reporter\n # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()\n \n+sub maildomain_sanitize\n+{\n+    local $_ = shift;\n+\n+    #\tOn Mac, the the domain name is not necessarily in FQDN format\n+    #\tRequire a period in the string\n+\n+    if ( $^O eq 'darwin'  and  /\\.local$/ ) {\n+\t# Nope, pass this one.\n+    }\n+    elsif ( /\\./ ) {\n+\t$_;\n+    }\n+}\n+\n sub maildomain_net\n {\n \tmy $maildomain;\n \n \tif (eval { require Net::Domain; 1 }) {\n \t\tmy $domain = Net::Domain::domainname();\n-\t\t$maildomain = $domain\n-\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t$maildomain = maildomain_sanitize($domain);\n \t}\n \n \treturn $maildomain;\n@@ -887,8 +901,7 @@ sub maildomain_mta\n \t\t\t\tmy $domain = $smtp->domain;\n \t\t\t\t$smtp->quit;\n \n-\t\t\t\t$maildomain = $domain\n-\t\t\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t\t\t$maildomain = maildomain_sanitize($domain);\n \n \t\t\t\tlast if $maildomain;\n \t\t\t}\n-- \n1.7.0\n"},{"id":"139417","messageId":"87bpdnwpoh.fsf_-_@jondo.cante.net","threadId":"23388","inReplyTo":"87ljcrwxni.fsf_-_@jondo.cante.net","subject":"[PATCH] git-send-email.perl: add maildomain_sanitize()","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-13T11:35:26Z","receivedAt":"2010-04-13T11:35:26Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"Move duplicate maildomain checks to a single subroutine.\nRequire that a FQDN contains at least one period.\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-send-email.perl |   21 +++++++++++++++++----\n 1 files changed, 17 insertions(+), 4 deletions(-)\n\n      Here is improved version 2 (use \"tab\" for indentation).\n \n      -- Jari\n \n      >Re: [PATCH 1/3] send-email: Don't use FQDNs without a '.'\n      >Junio C Hamano <gitster@pobox.com> writes:\n      >> Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n      >\n      >>  \t\t$maildomain = $domain\n      >> -\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n      >> +\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/\n      >> +\t\t\t\tor $domain !~ /\\./;\n      >\n      > [Junio] It would become *much* easier to read if we stop using the statement\n      > modifier, and write it in a more straightforward way:\n      >\n      > \tunless (($^O eq 'darwin' && $domain =~ /\\.local$/)\n      >         \t|| $domain !~ /\\./) {\n      >                 $maildomain = $domain;\n      > \t}\n      >\n      > as the condition seems to have grown large enough to exceed \"by the way\n      > don't do this under this narrow condition\", which is what statement\n      > modifiers are designed to be used.  Also mixing && and or that have\n      > different precedence taxes readers' brainpower unnecessarily.\n      >\n      > I also think that this particular exception logic should probably be in a\n      > separate helper function that is called from the two places.\n      >\n      > Jari, you are the last person who touched code around this area.  What do\n      > you think?\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ce569a9..0e8f18c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -863,14 +863,28 @@ sub sanitize_address\n # This maildomain*() code is based on ideas in Perl library Test::Reporter\n # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()\n \n+sub maildomain_sanitize\n+{\n+\tlocal $_ = shift;\n+\n+\t#  On Mac, the the domain name is not necessarily in FQDN format\n+\t#  Require a period in the string\n+\n+\tif ( $^O eq 'darwin'  and  /\\.local$/ ) {\n+\t\t# Nope, pass this one.\n+\t}\n+\telsif ( /\\./ ) {\n+\t\t$_;\n+\t}\n+}\n+\n sub maildomain_net\n {\n \tmy $maildomain;\n \n \tif (eval { require Net::Domain; 1 }) {\n \t\tmy $domain = Net::Domain::domainname();\n-\t\t$maildomain = $domain\n-\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t$maildomain = maildomain_sanitize($domain);\n \t}\n \n \treturn $maildomain;\n@@ -887,8 +901,7 @@ sub maildomain_mta\n \t\t\t\tmy $domain = $smtp->domain;\n \t\t\t\t$smtp->quit;\n \n-\t\t\t\t$maildomain = $domain\n-\t\t\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t\t\t$maildomain = maildomain_sanitize($domain);\n \n \t\t\t\tlast if $maildomain;\n \t\t\t}\n-- \n1.7.0\n"},{"id":"139581","messageId":"m38w8og9w4.fsf@localhost.localdomain","threadId":"23388","inReplyTo":"87bpdnwpoh.fsf_-_@jondo.cante.net","subject":"Re: [PATCH] git-send-email.perl: add maildomain_sanitize()","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-15T12:47:45Z","receivedAt":"2010-04-15T12:47:45Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jari Aalto <jari.aalto@cante.net> writes:\n\n> Move duplicate maildomain checks to a single subroutine.\n> Require that a FQDN contains at least one period.\n> \n> Signed-off-by: Jari Aalto <jari.aalto@cante.net>\n> ---\n\nGood idea.\n\n[...]\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index ce569a9..0e8f18c 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -863,14 +863,28 @@ sub sanitize_address\n>  # This maildomain*() code is based on ideas in Perl library Test::Reporter\n>  # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()\n>  \n> +sub maildomain_sanitize\n> +{\n> +\tlocal $_ = shift;\n> +\n> +\t#  On Mac, the the domain name is not necessarily in FQDN format\n> +\t#  Require a period in the string\n> +\n> +\tif ( $^O eq 'darwin'  and  /\\.local$/ ) {\n> +\t\t# Nope, pass this one.\n> +\t}\n> +\telsif ( /\\./ ) {\n> +\t\t$_;\n> +\t}\n> +}\n\nStyle:\n\n  +sub maildomain_sanitize {\n  +\tlocal $domain = shift;\n  +\n  +\t#  On Mac, the the domain name is not necessarily in FQDN format\n  +\t#  Require a period in the string\n  +\n  +\tif ($^O eq 'darwin'  &&  $domain =~ /\\.local$/) {\n  +\t\t# Nope, pass this one.\n  +\t} elsif ($domain =~ /\\./) {\n  +\t\treturn $domain;\n  +\t}\n  +}\n\n(probably fixed in new version of this series).\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"139669","messageId":"87wrw7qtx8.fsf_-_@jondo.cante.net","threadId":"23388","inReplyTo":"m38w8og9w4.fsf@localhost.localdomain","subject":"[PATCH v2] git-send-email.perl: Add sub maildomain_sanitize","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-16T15:49:23Z","receivedAt":"2010-04-16T15:49:23Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"Move duplicate maildomain checks to a single subroutine.\nRequire that a FQDN contains at least one period.\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-send-email.perl |   19 +++++++++++++++----\n 1 files changed, 15 insertions(+), 4 deletions(-)\n\n    Jakub Narebski <jnareb@gmail.com> writes:\n    >   +sub maildomain_sanitize {\n    >   +\tlocal $domain = shift;\n    >   +\n    >   +\t#  On Mac, the the domain name is not necessarily in FQDN format\n    >   +\t#  Require a period in the string\n    >   +\n    >   +\tif ($^O eq 'darwin'  &&  $domain =~ /\\.local$/) {\n    >   +\t\t# Nope, pass this one.\n    >   +\t} elsif ($domain =~ /\\./) {\n    >   +\t\treturn $domain;\n    >   +\t}\n    >   +}\n\n    Thanks for 2nd eye. Changed these in above:\n\n    * Starting brace placement at function start\n    * Placement of else\n    * Maybe: use or \"return\" (debatable).\n\n    But not these. Motivation:\n\n    * The \"$_\" simplifies ussage everywhere in the function. XP: less is more.\n    * The \"and\" is more readable than \"&&\". The \"and\" is also safer\n      due to its lower precedence.\n\n    Jari\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ce569a9..d52a8c3 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -863,14 +863,26 @@ sub sanitize_address\n # This maildomain*() code is based on ideas in Perl library Test::Reporter\n # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()\n \n+sub maildomain_sanitize {\n+\tlocal $_ = shift;\n+\n+\t#  On Mac, the the domain name is not necessarily in FQDN format.\n+\t#  Require a period in the string.\n+\n+\tif ( $^O eq 'darwin'  and  /\\.local$/ ) {\n+\t\t# Nope, pass this one.\n+\t} elsif ( /\\./ ) {\n+\t\treturn $_;\n+\t}\n+}\n+\n sub maildomain_net\n {\n \tmy $maildomain;\n \n \tif (eval { require Net::Domain; 1 }) {\n \t\tmy $domain = Net::Domain::domainname();\n-\t\t$maildomain = $domain\n-\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t$maildomain = maildomain_sanitize($domain);\n \t}\n \n \treturn $maildomain;\n@@ -887,8 +899,7 @@ sub maildomain_mta\n \t\t\t\tmy $domain = $smtp->domain;\n \t\t\t\t$smtp->quit;\n \n-\t\t\t\t$maildomain = $domain\n-\t\t\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t\t\t$maildomain = maildomain_sanitize($domain);\n \n \t\t\t\tlast if $maildomain;\n \t\t\t}\n-- \n1.7.0\n"},{"id":"139671","messageId":"201004161811.14259.jnareb@gmail.com","threadId":"23388","inReplyTo":"87wrw7qtx8.fsf_-_@jondo.cante.net","subject":"Re: [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-16T16:11:11Z","receivedAt":"2010-04-16T16:11:11Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jari Aalto wrote:\n\n>     Jakub Narebski <jnareb@gmail.com> writes:\n>     >   +sub maildomain_sanitize {\n>     >   +\tlocal $domain = shift;\n>     >   +\n>     >   +\t#  On Mac, the the domain name is not necessarily in FQDN format\n>     >   +\t#  Require a period in the string\n>     >   +\n>     >   +\tif ($^O eq 'darwin'  &&  $domain =~ /\\.local$/) {\n>     >   +\t\t# Nope, pass this one.\n>     >   +\t} elsif ($domain =~ /\\./) {\n>     >   +\t\treturn $domain;\n>     >   +\t}\n>     >   +}\n> \n>     Thanks for 2nd eye. Changed these in above:\n> \n>     * Starting brace placement at function start\n>     * Placement of else\n>     * Maybe: use or \"return\" (debatable).\n> \n>     But not these. Motivation:\n> \n>     * The \"$_\" simplifies usage everywhere in the function. XP: less is more.\n>     * The \"and\" is more readable than \"&&\". The \"and\" is also safer\n>       due to its lower precedence.\n\nO.K.\n\n\nNote however that while setting $_ ($ARG with English) simplifies regexp\nmatching, you have to take care to use\n\n   local $_ = shift;\n\nand not\n\n   my $_ = shift; \n\nAnd to use 'local'.\n\nA bit of \"difficulty conservation\" at work.\n\n[...]\n> +sub maildomain_sanitize {\n> +\tlocal $_ = shift;\n> +\n> +\t#  On Mac, the the domain name is not necessarily in FQDN format.\n> +\t#  Require a period in the string.\n> +\n> +\tif ( $^O eq 'darwin'  and  /\\.local$/ ) {\n> +\t\t# Nope, pass this one.\n> +\t} elsif ( /\\./ ) {\n> +\t\treturn $_;\n> +\t}\n> +}\n\n-- \nJakub Narebski\nPoland\n"},{"id":"139687","messageId":"87iq7rqqn3.fsf_-_@jondo.cante.net","threadId":"23388","inReplyTo":"201004161811.14259.jnareb@gmail.com","subject":"Re: Start encouraging English.pm (Was: [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize)","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-16T17:00:16Z","receivedAt":"2010-04-16T17:00:16Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n> O.K.\n>\n>\n> Note however that while setting $_ ($ARG with English) simplifies regexp\n> matching\n\nSpeaking of which...\n\nCould we please move to using this everywhere:\n\n    use English qw( -no_match_vars );\n\nThat would give all the benefits of readability without performance\npenalties. The load time seems to be neglible:\n\n    $ perl --version | grep v5\n\n    This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi\n\n    $ time perl -e 'print'\n\n    real    0m0.005s\n    user    0m0.000s\n    sys     0m0.004s\n\n    $ time perl -e 'use English qw( -no_match_vars ); print'\n\n    real    0m0.017s\n    user    0m0.008s\n    sys     0m0.008s\n\n> you have to take care to use\n>\n>> +sub maildomain_sanitize {\n>> +\tlocal $_ = shift;\n\n>    local $_ = shift;\n>\n> and not\n>\n>    my $_ = shift; \n>\n> And to use 'local'.\n\nAs done.\n\nThe Perl 5.12 now finally allow my'ing of $ARG too. But maybe we don't\nswitch to it just yet...\n\nJari\n"}]}