t3418: non-interactive rebase --continue with rerere enabled
[gitweb.git] / git-send-email.perl
index 6bedf745e72d3935f7feaae2cfca95d44a3e6df5..ae9f8698c5a4842c2c0d63db51dde067ddeeb1c9 100755 (executable)
@@ -487,6 +487,37 @@ sub split_addrs {
 }
 
 my %aliases;
+
+sub parse_sendmail_alias {
+       local $_ = shift;
+       if (/"/) {
+               print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
+       } elsif (/:include:/) {
+               print STDERR "warning: `:include:` not supported: $_\n";
+       } elsif (/[\/|]/) {
+               print STDERR "warning: `/file` or `|pipe` redirection 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;
+       my $s = '';
+       while (<$fh>) {
+               chomp;
+               next if /^\s*$/ || /^\s*#/;
+               $s .= $_, next if $s =~ s/\\$// || s/^\s+//;
+               parse_sendmail_alias($s) if $s;
+               $s = $_;
+       }
+       $s =~ s/\\$//; # silently tolerate stray '\' on last line
+       parse_sendmail_alias($s) if $s;
+}
+
 my %parse_alias = (
        # multiline formats can be supported in the future
        mutt => sub { my $fh = shift; while (<$fh>) {
@@ -515,32 +546,7 @@ sub split_addrs {
                               $aliases{$alias} = [ split_addrs($addr) ];
                          }
                      } },
-
-       sendmail => sub { my $fh = shift; while (<$fh>) {
-               # ignore blank lines and comment lines
-               if (/^\s*(?:#.*)?$/) { }
-
-               # warn on lines that contain quotes
-               elsif (/"/) {
-                       print STDERR "sendmail alias with quotes is not supported: $_\n";
-               }
-
-               # warn on lines that continue
-               elsif (/^\s|\\$/) {
-                       print STDERR "sendmail continuation line is not supported: $_\n";
-               }
-
-               # recognize lines that look like an alias
-               elsif (/^(\S+?)\s*:\s*(.+)$/) {
-                       my ($alias, $addr) = ($1, $2);
-                       $aliases{$alias} = [ split_addrs($addr) ];
-               }
-
-               # warn on lines that are not recognized
-               else {
-                       print STDERR "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 ];