Merge branch 'jk/send-email-ssl-errors'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Dec 2015 18:59:06 +0000 (10:59 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Dec 2015 18:59:06 +0000 (10:59 -0800)
Improve error reporting when SMTP TLS fails.

* jk/send-email-ssl-errors:
send-email: enable SSL level 1 debug output

1  2 
git-send-email.perl
diff --combined git-send-email.perl
index 2a3873b744b313c8871f339911ed7fba4fb34d99,72508bed93147078ff26b61174f7240b92b21320..6caa5b563fafb09cee5eb8f35283e7b9fa967439
@@@ -46,7 -46,6 +46,7 @@@ package main
  sub usage {
        print <<EOT;
  git send-email [options] <file | directory | rev-list options >
 +git send-email --dump-aliases
  
    Composing:
      --from                  <str>  * Email From:
                                       `git format-patch` ones.
      --force                        * Send even if safety checks would prevent it.
  
 +  Information:
 +    --dump-aliases                 * Dump configured aliases and exit.
 +
  EOT
        exit(1);
  }
@@@ -184,7 -180,6 +184,7 @@@ my ($quiet, $dry_run) = (0, 0)
  my $format_patch;
  my $compose_filename;
  my $force = 0;
 +my $dump_aliases = 0;
  
  # Handle interactive edition of files.
  my $multiedit;
@@@ -244,6 -239,7 +244,6 @@@ my %config_settings = 
      "smtpserveroption" => \@smtp_server_options,
      "smtpuser" => \$smtp_authuser,
      "smtppass" => \$smtp_authpass,
 -    "smtpsslcertpath" => \$smtp_ssl_cert_path,
      "smtpdomain" => \$smtp_domain,
      "smtpauth" => \$smtp_auth,
      "to" => \@initial_to,
  
  my %config_path_settings = (
      "aliasesfile" => \@alias_files,
 +    "smtpsslcertpath" => \$smtp_ssl_cert_path,
  );
  
  # Handle Uncouth Termination
@@@ -296,11 -291,6 +296,11 @@@ $SIG{INT}  = \&signal_handler
  
  my $help;
  my $rc = GetOptions("h" => \$help,
 +                    "dump-aliases" => \$dump_aliases);
 +usage() unless $rc;
 +die "--dump-aliases incompatible with other options\n"
 +    if !$help and $dump_aliases and @ARGV;
 +$rc = GetOptions(
                    "sender|from=s" => \$sender,
                      "in-reply-to=s" => \$initial_reply_to,
                    "subject=s" => \$initial_subject,
@@@ -561,11 -551,6 +561,11 @@@ if (@alias_files and $aliasfiletype an
        }
  }
  
 +if ($dump_aliases) {
 +    print "$_\n" for (sort keys %aliases);
 +    exit(0);
 +}
 +
  # is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if
  # $f is a revision list specification to be passed to format-patch.
  sub is_format_patch_arg {
@@@ -1211,7 -1196,8 +1211,7 @@@ sub ssl_verify_params 
                return (SSL_verify_mode => SSL_VERIFY_PEER(),
                        SSL_ca_file => $smtp_ssl_cert_path);
        } else {
 -              print STDERR "Not using SSL_VERIFY_PEER because the CA path does not exist.\n";
 -              return (SSL_verify_mode => SSL_VERIFY_NONE());
 +              die "CA path \"$smtp_ssl_cert_path\" does not exist";
        }
  }
  
@@@ -1332,6 -1318,13 +1332,13 @@@ Message-Id: $message_i
                        require Net::SMTP::SSL;
                        $smtp_domain ||= maildomain();
                        require IO::Socket::SSL;
+                       # Suppress "variable accessed once" warning.
+                       {
+                               no warnings 'once';
+                               $IO::Socket::SSL::DEBUG = 1;
+                       }
                        # Net::SMTP::SSL->new() does not forward any SSL options
                        IO::Socket::SSL::set_client_defaults(
                                ssl_verify_params());