Merge branch 'jk/send-email-complete-aliases'
authorJunio C Hamano <gitster@pobox.com>
Fri, 4 Dec 2015 19:19:10 +0000 (11:19 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Dec 2015 19:19:11 +0000 (11:19 -0800)
Teach send-email to dump mail aliases, so that we can do tab completion
on the command line.

* jk/send-email-complete-aliases:
completion: add support for completing email aliases
sendemail: teach git-send-email to dump alias names

1  2 
git-send-email.perl
diff --combined git-send-email.perl
index 77cc2cc3712a61fc54926d40267336251136dcec,a475b0d7537006df2d541764c7580062518088a4..2a3873b744b313c8871f339911ed7fba4fb34d99
@@@ -46,6 -46,7 +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);
  }
@@@ -180,6 -184,7 +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;
@@@ -239,6 -244,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
@@@ -291,6 -296,11 +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,
@@@ -551,6 -561,11 +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 {
@@@ -1196,7 -1211,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";
        }
  }