Support sendmail (and postfix) style email aliases in git-send-email.
This is the format of /etc/mail/aliases, documented by `man 5 aliases`.
The man page may be provided by sendmail or postfix on your system, or
by another email service that uses the same configuration file.

See also: http://www.postfix.org/aliases.5.html.

This format is more simple than the other alias file formats, so it may
be preferred by some users.  The format is as follows.

<alias>: <address|alias>[, <address|alias>...]

Example (no indent in aliases file):
        alice: Alice W Land <a...@example.com>
        bob: Robert Bobbyton <b...@example.com>
        chloe: ch...@example.com
        abgroup: alice, bob
        bcgrp: bob, chloe, Other <o...@example.com>

This patch DOES NOT support line continuations as are described by the
specification.  Line continuations are indicated by either (or both) a
trailing '\' on the line to be continued, or leading whitespace on the
continuing line.  This patch does not do anything with the trailing '\',
and ignores lines starting with whitespace.

This patch also ignores lines that starts with '#', comment character,
and empty lines.

Signed-off-by: Allen Hubbe <alle...@gmail.com>
---
 git-send-email.perl | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index e1e9b14..5f2ec0d 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -515,7 +515,12 @@ my %parse_alias = (
                               $aliases{$alias} = [ split_addrs($addr) ];
                          }
                      } },
-
+       sendmail => sub { my $fh = shift; while (<$fh>) {
+               next if /^$|^#|^\s/;
+               if (/^(\S+)\s*:\s*(.*?)\\?$/) {
+                       my ($alias, $addr) = ($1, $2);
+                       $aliases{$alias} = [ split_addrs($addr) ];
+               }}},
        gnus => sub { my $fh = shift; while (<$fh>) {
                if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
                        $aliases{$1} = [ $2 ];
-- 
2.3.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to