Subject: Re: [PATCH] git-send-email.perl: Add sendmail aliases support

From: Junio C Hamano <[email-masked]>
Date: Thu, 21 May 2015 13:19:47 -0700

Allen Hubbe <[email-masked]> writes:

> 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) ];
> +		}}},

Let me unfold the line only to make commenting it easier.

	sendmail => sub {
        	my $fh = shift;
                while (<$fh>) {
			next if /^$|^#|^\s/;
			if (/^(\S+)\s*:\s*(.*?)\\?$/) {
				my ($alias, $addr) = ($1, $2);
				$aliases{$alias} = [ split_addrs($addr) ];
			}
		}
	},

It is probably OK to omit support for folded lines, but wouldn't it
be easy enough to be a bit more helpful to give a warning when you
find such lines in the input?  Otherwise you will leave the users
wondering why some of their aliases work while others don't.

Perhaps like this (this is not even an output from "diff" but typed
in my MUA, so there may be typos---take it just as illustrating
ideas)?

That way, users can fold the input themselves and try again if they
wanted to.  The warning _may_ have to be squelched after a few hits
to keep the result usable, though.

	sendmail => sub {
        	my $fh = shift;
                while (<$fh>) {
-			next if /^$|^#|^\s/;
-			if (/^(\S+)\s*:\s*(.*?)\\?$/) {
+			next if /^$|^#/;
+			if (/^\s/ || /\\$/) {
+				print STDERR "$.: $_";
+				print STDERR "continuation lines in alias not supported\n";
+				next;
+			}
+			if (/^(\S+)\s*:\s*(.*)$/) {
				my ($alias, $addr) = ($1, $2);
				$aliases{$alias} = [ split_addrs($addr) ];
			}
		}
	},

Thanks.