send-email: implement sendmail aliases line continuation support

Logical lines in sendmail aliases files can be spread over multiple physical lines[1]. A line beginning with whitespace is folded into the preceding line. A line ending with '\' consumes the following line. [1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5 Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed May 31, 2015 at 18:29 UTC 2532dd0605b15eeed41312558bf5babb50290236
2 files changed +7 -5
Documentation/git-send-email.txt
-2
@@ -394,8 +394,6 @@ described below:
394 sendmail;;
395 * Quoted aliases and quoted addresses are not supported: lines that
396 contain a `"` symbol are ignored.
397 -* Line continuations are not supported: lines that start with
398 - whitespace characters, or end with a `\` symbol are ignored.
397 * Redirection to a file (`/path/name`) or pipe (`|command`) is not
398 supported.
399 * File inclusion (`:include: /path/name`) is not supported.
git-send-email.perl
+7 -3
@@ -492,8 +492,6 @@ sub parse_sendmail_alias {
492 local $_ = shift;
493 if (/"/) {
494 print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
495 - } elsif (/^\s|\\$/) {
496 - print STDERR "warning: sendmail continuation line is not supported: $_\n";
495 } elsif (/^(\S+?)\s*:\s*(.+)$/) {
496 my ($alias, $addr) = ($1, $2);
497 $aliases{$alias} = [ split_addrs($addr) ];
@@ -504,10 +502,16 @@ sub parse_sendmail_alias {
502
503 sub parse_sendmail_aliases {
504 my $fh = shift;
505 + my $s = '';
506 while (<$fh>) {
507 + chomp;
508 next if /^\s*$/ || /^\s*#/;
509 - parse_sendmail_alias($_);
509 + $s .= $_, next if $s =~ s/\\$// || s/^\s+//;
510 + parse_sendmail_alias($s) if $s;
511 + $s = $_;
512 }
513 + $s =~ s/\\$//; # silently tolerate stray '\' on last line
514 + parse_sendmail_alias($s) if $s;
515 }
516
517 my %parse_alias = (