summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-05-31 18:29:27 -0400
committerJunio C Hamano <gitster@pobox.com>2015-06-01 15:52:49 -0700
commit09f1157bbf5daa8a4fd8de1d25edbb8961d44521 (patch)
tree5915537d16d555fdb78be72d48c0ed0cd9bf9f35 /git-send-email.perl
parent22e3b46ff95ac01add2d1e8874708b06c9e7db91 (diff)
downloadgit-09f1157bbf5daa8a4fd8de1d25edbb8961d44521.tar.gz
send-email: refactor sendmail aliases parser
The sendmail aliases parser inlined into %parse_alias is already uncomfortably large and is expected to grow as additional functionality is implemented, so extract it to improve manageability. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl38
1 files changed, 24 insertions, 14 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 1380e6e163..76bb499fbb 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -487,6 +487,29 @@ sub split_addrs {
}
my %aliases;
+
+sub parse_sendmail_alias {
+ local $_ = shift;
+ if (/"/) {
+ print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
+ } elsif (/^\s|\\$/) {
+ print STDERR "warning: sendmail continuation line is not supported: $_\n";
+ } elsif (/^(\S+?)\s*:\s*(.+)$/) {
+ my ($alias, $addr) = ($1, $2);
+ $aliases{$alias} = [ split_addrs($addr) ];
+ } else {
+ print STDERR "warning: sendmail line is not recognized: $_\n";
+ }
+}
+
+sub parse_sendmail_aliases {
+ my $fh = shift;
+ while (<$fh>) {
+ if (/^\s*(?:#.*)?$/) { next; }
+ parse_sendmail_alias($_);
+ }
+}
+
my %parse_alias = (
# multiline formats can be supported in the future
mutt => sub { my $fh = shift; while (<$fh>) {
@@ -515,20 +538,7 @@ my %parse_alias = (
$aliases{$alias} = [ split_addrs($addr) ];
}
} },
-
- sendmail => sub { my $fh = shift; while (<$fh>) {
- if (/^\s*(?:#.*)?$/) {
- } elsif (/"/) {
- print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
- } elsif (/^\s|\\$/) {
- print STDERR "warning: sendmail continuation line is not supported: $_\n";
- } elsif (/^(\S+?)\s*:\s*(.+)$/) {
- my ($alias, $addr) = ($1, $2);
- $aliases{$alias} = [ split_addrs($addr) ];
- } else {
- print STDERR "warning: sendmail line is not recognized: $_\n";
- }}},
-
+ sendmail => \&parse_sendmail_aliases,
gnus => sub { my $fh = shift; while (<$fh>) {
if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
$aliases{$1} = [ $2 ];