summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJacob Keller <jacob.keller@gmail.com>2015-11-19 14:52:11 -0800
committerJeff King <peff@peff.net>2015-11-20 08:02:06 -0500
commit17b7a8324402ab1e5bb66adb287e5463757c9326 (patch)
tree3dcd180aa22323de6b1a902226777284f40e485a /git-send-email.perl
parent0c83680e9c047170614fb08ef222ea4f460e514d (diff)
downloadgit-17b7a8324402ab1e5bb66adb287e5463757c9326.tar.gz
sendemail: teach git-send-email to dump alias names
Add an option "--dump-aliases" which changes the default behavior of git-send-email. This mode will simply read the alias files configured by sendemail.aliasesfile and sendemail.aliasfiletype and dump a list of all configured aliases, one per line. The intended use case for this option is the bash-completion script which will use it to autocomplete aliases on the options which take addresses. Add some tests for the new option using various alias file formats. A possible future extension to the alias dump format could be done by extending the --dump-aliases to take an optional argument defining the format to display. This has not been done in this patch as no user of this information has been identified. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl15
1 files changed, 15 insertions, 0 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index e907e0eacf..a475b0d753 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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:
@@ -101,6 +102,9 @@ git send-email [options] <file | directory | rev-list options >
`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 @@ 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;
@@ -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,
@@ -551,6 +561,11 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
}
}
+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 {