threads / patch / 39471

patch, 9 partssend-email: visually distinguish sendmail aliases parser warnings

Subject: [PATCH 2/9] send-email: visually distinguish sendmail aliases parser warnings

## tl;dr

15 messages between May 31, 2015 and Jun 1, 2015. Diffs are folded; open one to read it.

replies: 14people: 2as markdown or json

Eric Sunshine· May 31, 2015, 22:29 UTC · lore

[PATCH 0/9] send-email: add sendmail aliases line continuation support

This series adds line continuation support for sendmail aliases. It extends basic sendmail aliases functionality implemented by ah/send-email-sendmail-alias (currently d1205b07 in 'pu')

Eric Sunshine (9):
  send-email: further document missing sendmail aliases functionality
  send-email: visually distinguish sendmail aliases parser warnings
  send-email: drop noise comments which merely repeat what code says
  send-email: fix style: cuddle 'elsif' and 'else' with closing brace
  send-email: refactor sendmail aliases parser
  send-email: simplify sendmail aliases comment and blank line
    recognizer
  send-email: implement sendmail aliases line continuation support
  t9001: refactor sendmail aliases test infrastructure
  t9001: add sendmail aliases line continuation tests
 Documentation/git-send-email.txt |  5 ++-
 git-send-email.perl              | 54 ++++++++++++++-------------
 t/t9001-send-email.sh            | 81 +++++++++++++++++++++++++++++++---------
 3 files changed, 94 insertions(+), 46 deletions(-)
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 1/9] send-email: further document missing sendmail aliases functionality

Sendmail aliases[1] supports expansion to a file ("/path/name") or pipe ("|command"), as well as file inclusion (":include: /path/name"), however, our implementation does not support such functionality.

[1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 Documentation/git-send-email.txt | 3 +++
 1 file changed, 3 insertions(+)
Show changes to Documentation/git-send-email.txt +3 −0
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index b48a764..e6d466e 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -396,6 +396,9 @@ sendmail;;
 	contain a `"` symbol are ignored.
 *	Line continuations are not supported: lines that start with
 	whitespace characters, or end with a `\` symbol are ignored.
+*	Redirection to a file (`/path/name`) or pipe (`|command`) is not
+	supported.
+*	File inclusion (`:include: /path/name`) is not supported.
 *	Warnings are printed on the standard error output for any
 	explicitly unsupported constructs, and any other lines that are not
 	recognized by the parser.
-- 
2.4.2.538.g5f4350e
Allen Hubbe· Jun 1, 2015, 11:43 UTC · re: Eric Sunshine · lore

Re: [PATCH 1/9] send-email: further document missing sendmail aliases functionality

According to the documentation, the parser should print a warning for any explicitly unsupported constructs. These are now explicitly unsupported, so the parser should warn on |, /, and :include: . Perhaps the lines that match should be ignored like the others, too.

On Sun, May 31, 2015 at 6:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 28 quoted lines
> Sendmail aliases[1] supports expansion to a file ("/path/name") or
> pipe ("|command"), as well as file inclusion (":include: /path/name"),
> however, our implementation does not support such functionality.
>
> [1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5
>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  Documentation/git-send-email.txt | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
> index b48a764..e6d466e 100644
> --- a/Documentation/git-send-email.txt
> +++ b/Documentation/git-send-email.txt
> @@ -396,6 +396,9 @@ sendmail;;
>         contain a `"` symbol are ignored.
>  *      Line continuations are not supported: lines that start with
>         whitespace characters, or end with a `\` symbol are ignored.
> +*      Redirection to a file (`/path/name`) or pipe (`|command`) is not
> +       supported.
> +*      File inclusion (`:include: /path/name`) is not supported.
>  *      Warnings are printed on the standard error output for any
>         explicitly unsupported constructs, and any other lines that are not
>         recognized by the parser.
> --
> 2.4.2.538.g5f4350e
>
Eric Sunshine· Jun 1, 2015, 18:22 UTC · re: Allen Hubbe · lore

Re: [PATCH 1/9] send-email: further document missing sendmail aliases functionality

On Mon, Jun 01, 2015 at 07:43:08AM -0400, Allen Hubbe wrote:
Show 9 quoted lines
> On May 31, 2015 at 6:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> > Sendmail aliases[1] supports expansion to a file ("/path/name") or
> > pipe ("|command"), as well as file inclusion (":include: /path/name"),
> > however, our implementation does not support such functionality.
>
> According to the documentation, the parser should print a warning for
> any explicitly unsupported constructs.  These are now explicitly
> unsupported, so the parser should warn on |, /, and :include: .
> Perhaps the lines that match should be ignored like the others, too.

Indeed. I had that in mind and then promptly forgot about it. Here's a follow-on patch:

--- >8 ---
From: Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH 10/9] send-email: further warn about unsupported sendmail aliases features

The sendmail aliases parser diagnoses unsupported features and unrecognized lines. For completeness, also warn about unsupported redirection to "/path/name" and "|command", as well as ":include:".

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 git-send-email.perl | 4 ++++
 1 file changed, 4 insertions(+)
Show changes to git-send-email.perl +4 −0
diff --git a/git-send-email.perl b/git-send-email.perl
index eb1d678..ae9f869 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -492,6 +492,10 @@ 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) ];
-- 
2.4.2.538.g5f4350e

--- >8 ---
Allen Hubbe· Jun 1, 2015, 22:44 UTC · re: Eric Sunshine · lore

Re: [PATCH 1/9] send-email: further document missing sendmail aliases functionality

This looks good.
On Mon, Jun 1, 2015 at 2:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 46 quoted lines
> On Mon, Jun 01, 2015 at 07:43:08AM -0400, Allen Hubbe wrote:
>> On May 31, 2015 at 6:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> > Sendmail aliases[1] supports expansion to a file ("/path/name") or
>> > pipe ("|command"), as well as file inclusion (":include: /path/name"),
>> > however, our implementation does not support such functionality.
>>
>> According to the documentation, the parser should print a warning for
>> any explicitly unsupported constructs.  These are now explicitly
>> unsupported, so the parser should warn on |, /, and :include: .
>> Perhaps the lines that match should be ignored like the others, too.
>
> Indeed. I had that in mind and then promptly forgot about it. Here's a
> follow-on patch:
>
> --- >8 ---
> From: Eric Sunshine <sunshine@sunshineco.com>
> Subject: [PATCH 10/9] send-email: further warn about unsupported sendmail aliases features
>
> The sendmail aliases parser diagnoses unsupported features and
> unrecognized lines. For completeness, also warn about unsupported
> redirection to "/path/name" and "|command", as well as ":include:".
>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  git-send-email.perl | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index eb1d678..ae9f869 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -492,6 +492,10 @@ 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) ];
> --
> 2.4.2.538.g5f4350e
>
> --- >8 ---
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

Although emitted to stderr, warnings from the sendmail aliases parser are not visually distinguished as such, and thus can easily be overlooked in the normal noisy send-email output.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

This prepends lowercase "warning:" rather than uppercase since lowercase is used elsewhere in git-send-email.perl for diagnostic message prefixes.

 git-send-email.perl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Show changes to git-send-email.perl +3 −3
diff --git a/git-send-email.perl b/git-send-email.perl
index 6bedf74..819f87e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -522,12 +522,12 @@ my %parse_alias = (
 
 		# warn on lines that contain quotes
 		elsif (/"/) {
-			print STDERR "sendmail alias with quotes is not supported: $_\n";
+			print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
 		}
 
 		# warn on lines that continue
 		elsif (/^\s|\\$/) {
-			print STDERR "sendmail continuation line is not supported: $_\n";
+			print STDERR "warning: sendmail continuation line is not supported: $_\n";
 		}
 
 		# recognize lines that look like an alias
@@ -538,7 +538,7 @@ my %parse_alias = (
 
 		# warn on lines that are not recognized
 		else {
-			print STDERR "sendmail line is not recognized: $_\n";
+			print STDERR "warning: sendmail line is not recognized: $_\n";
 		}}},
 
 	gnus => sub { my $fh = shift; while (<$fh>) {
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 3/9] send-email: drop noise comments which merely repeat what code says

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 git-send-email.perl | 5 -----
 1 file changed, 5 deletions(-)
Show changes to git-send-email.perl +0 −5
diff --git a/git-send-email.perl b/git-send-email.perl
index 819f87e..0b18682 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -517,26 +517,21 @@ my %parse_alias = (
 		      } },
 
 	sendmail => sub { my $fh = shift; while (<$fh>) {
-		# ignore blank lines and comment lines
 		if (/^\s*(?:#.*)?$/) { }
 
-		# warn on lines that contain quotes
 		elsif (/"/) {
 			print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
 		}
 
-		# warn on lines that continue
 		elsif (/^\s|\\$/) {
 			print STDERR "warning: 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 "warning: sendmail line is not recognized: $_\n";
 		}}},
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 4/9] send-email: fix style: cuddle 'elsif' and 'else' with closing brace

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 git-send-email.perl | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
Show changes to git-send-email.perl +5 −12
diff --git a/git-send-email.perl b/git-send-email.perl
index 0b18682..1380e6e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -517,22 +517,15 @@ my %parse_alias = (
 		      } },
 
 	sendmail => sub { my $fh = shift; while (<$fh>) {
-		if (/^\s*(?:#.*)?$/) { }
-
-		elsif (/"/) {
+		if (/^\s*(?:#.*)?$/) {
+		} elsif (/"/) {
 			print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
-		}
-
-		elsif (/^\s|\\$/) {
+		} elsif (/^\s|\\$/) {
 			print STDERR "warning: sendmail continuation line is not supported: $_\n";
-		}
-
-		elsif (/^(\S+?)\s*:\s*(.+)$/) {
+		} elsif (/^(\S+?)\s*:\s*(.+)$/) {
 			my ($alias, $addr) = ($1, $2);
 			$aliases{$alias} = [ split_addrs($addr) ];
-		}
-
-		else {
+		} else {
 			print STDERR "warning: sendmail line is not recognized: $_\n";
 		}}},
 
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 5/9] 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>
---
 git-send-email.perl | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)
Show changes to git-send-email.perl +24 −14
diff --git a/git-send-email.perl b/git-send-email.perl
index 1380e6e..76bb499 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 ];
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer

Replace unnecessarily complex regular expression for recognizing comment and blanks lines in sendmail aliases with idiomatic expressions which can be easily understood at a glance.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to git-send-email.perl +1 −1
diff --git a/git-send-email.perl b/git-send-email.perl
index 76bb499..e777bd3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -505,7 +505,7 @@ sub parse_sendmail_alias {
 sub parse_sendmail_aliases {
 	my $fh = shift;
 	while (<$fh>) {
-		if (/^\s*(?:#.*)?$/) { next; }
+		next if /^\s*$/ || /^\s*#/;
 		parse_sendmail_alias($_);
 	}
 }
-- 
2.4.2.538.g5f4350e
Eric Sunshine· Jun 1, 2015, 03:30 UTC · re: Eric Sunshine · lore

Re: [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer

On Sun, May 31, 2015 at 6:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> Replace unnecessarily complex regular expression for recognizing comment
> and blanks lines in sendmail aliases with idiomatic expressions which
s/blanks/blank/
Show 22 quoted lines
> can be easily understood at a glance.
>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  git-send-email.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 76bb499..e777bd3 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -505,7 +505,7 @@ sub parse_sendmail_alias {
>  sub parse_sendmail_aliases {
>         my $fh = shift;
>         while (<$fh>) {
> -               if (/^\s*(?:#.*)?$/) { next; }
> +               next if /^\s*$/ || /^\s*#/;
>                 parse_sendmail_alias($_);
>         }
>  }
> --
> 2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 7/9] 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>
---

This implementation silently and "sanely" tolerates continuation line scenarios for which behavior is not defined by [1]. In particular, an indented line which is the first (non-comment) line in the file is treated as a single logical line. Ditto for a line ending with '\' which is the last (non-comment) line in the file.

An earlier iteration emitted warnings for such cases, but it wasn't clear if warning about undefined behavior was useful; and it made the implementation much more noisy, so this version silently tolerates such anomalies.

 Documentation/git-send-email.txt |  2 --
 git-send-email.perl              | 10 +++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)
Show changes to 2 files +7 −5

Documentation/git-send-email.txt, git-send-email.perl

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index e6d466e..7ae467b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -394,8 +394,6 @@ described below:
 sendmail;;
 *	Quoted aliases and quoted addresses are not supported: lines that
 	contain a `"` symbol are ignored.
-*	Line continuations are not supported: lines that start with
-	whitespace characters, or end with a `\` symbol are ignored.
 *	Redirection to a file (`/path/name`) or pipe (`|command`) is not
 	supported.
 *	File inclusion (`:include: /path/name`) is not supported.
diff --git a/git-send-email.perl b/git-send-email.perl
index e777bd3..eb1d678 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -492,8 +492,6 @@ 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) ];
@@ -504,10 +502,16 @@ sub parse_sendmail_alias {
 
 sub parse_sendmail_aliases {
 	my $fh = shift;
+	my $s = '';
 	while (<$fh>) {
+		chomp;
 		next if /^\s*$/ || /^\s*#/;
-		parse_sendmail_alias($_);
+		$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 = (
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 8/9] t9001: refactor sendmail aliases test infrastructure

Several new tests of sendmail aliases parsing will be added in a subsequent patch, so factor out functionality common to all of them into a new helper function.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t9001-send-email.sh | 47 +++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 18 deletions(-)
Show changes to t/t9001-send-email.sh +29 −18
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index a3663da..1012fa3 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1549,10 +1549,35 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
 	grep "^!someone@example\.org!$" commandline1
 '
 
-test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' '
-	clean_fake_sendmail && rm -fr outdir &&
-	git format-patch -1 -o outdir &&
-	cat >>.tmp-email-aliases <<-\EOF &&
+test_sendmail_aliases () {
+	msg="$1" && shift &&
+	expect="$@" &&
+	cat >.tmp-email-aliases &&
+
+	test_expect_success $PREREQ "$msg" '
+		clean_fake_sendmail && rm -fr outdir &&
+		git format-patch -1 -o outdir &&
+		git config --replace-all sendemail.aliasesfile \
+			"$(pwd)/.tmp-email-aliases" &&
+		git config sendemail.aliasfiletype sendmail &&
+		git send-email \
+			--from="Example <nobody@example.com>" \
+			--to=alice --to=bcgrp \
+			--smtp-server="$(pwd)/fake.sendmail" \
+			outdir/0001-*.patch \
+			2>errors >out &&
+		for i in $expect
+		do
+			grep "^!$i!$" commandline1 || return 1
+		done
+	'
+}
+
+test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
+	'awol@example\.com' \
+	'bob@example\.com' \
+	'chloe@example\.com' \
+	'o@example\.com' <<-\EOF
 	alice: Alice W Land <awol@example.com>
 	bob: Robert Bobbyton <bob@example.com>
 	# this is a comment
@@ -1561,20 +1586,6 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' '
 	abgroup: alice, bob
 	bcgrp: bob, chloe, Other <o@example.com>
 	EOF
-	git config --replace-all sendemail.aliasesfile \
-		"$(pwd)/.tmp-email-aliases" &&
-	git config sendemail.aliasfiletype sendmail &&
-	git send-email \
-		--from="Example <nobody@example.com>" \
-		--to=alice --to=bcgrp \
-		--smtp-server="$(pwd)/fake.sendmail" \
-		outdir/0001-*.patch \
-		2>errors >out &&
-	grep "^!awol@example\.com!$" commandline1 &&
-	grep "^!bob@example\.com!$" commandline1 &&
-	grep "^!chloe@example\.com!$" commandline1 &&
-	grep "^!o@example\.com!$" commandline1
-'
 
 do_xmailer_test () {
 	expected=$1 params=$2 &&
-- 
2.4.2.538.g5f4350e
Eric Sunshine· May 31, 2015, 22:29 UTC · re: Eric Sunshine · lore

[PATCH 9/9] t9001: add sendmail aliases line continuation tests

A line beginning with whitespace is folded into the preceding line. A line ending with '\' consumes the following line.

While here, also test an empty sendmail aliases file.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t9001-send-email.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
Show changes to t/t9001-send-email.sh +34 −0
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 1012fa3..db2f45e 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1587,6 +1587,40 @@ test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
 	bcgrp: bob, chloe, Other <o@example.com>
 	EOF
 
+test_sendmail_aliases 'sendmail aliases line folding' \
+	alice1 \
+	bob1 bob2 \
+	chuck1 chuck2 \
+	darla1 darla2 darla3 \
+	elton1 elton2 elton3 \
+	fred1 fred2 \
+	greg1 <<-\EOF
+	alice: alice1
+	bob: bob1,\
+	bob2
+	chuck: chuck1,
+	    chuck2
+	darla: darla1,\
+	darla2,
+	    darla3
+	elton: elton1,
+	    elton2,\
+	elton3
+	fred: fred1,\
+	    fred2
+	greg: greg1
+	bcgrp: bob, chuck, darla, elton, fred, greg
+	EOF
+
+test_sendmail_aliases 'sendmail aliases tolerate bogus line folding' \
+	alice1 bob1 <<-\EOF
+	    alice: alice1
+	bcgrp: bob1\
+	EOF
+
+test_sendmail_aliases 'sendmail aliases empty' alice bcgrp <<-\EOF
+	EOF
+
 do_xmailer_test () {
 	expected=$1 params=$2 &&
 	git format-patch -1 &&
-- 
2.4.2.538.g5f4350e
Allen Hubbe· Jun 1, 2015, 11:49 UTC · re: Eric Sunshine · lore

Re: [PATCH 0/9] send-email: add sendmail aliases line continuation support

This series looks very good to me. Thanks for the extra work you've done to make the sendmail alias support much better :)

I'm not too concerned about this, but if you think it would be
appropriate you may use it:
Acked-by: Allen Hubbe <allenbh@gmail.com>
On Sun, May 31, 2015 at 6:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 24 quoted lines
> This series adds line continuation support for sendmail aliases.
> It extends basic sendmail aliases functionality implemented by
> ah/send-email-sendmail-alias (currently d1205b07 in 'pu')
>
> Eric Sunshine (9):
>   send-email: further document missing sendmail aliases functionality
>   send-email: visually distinguish sendmail aliases parser warnings
>   send-email: drop noise comments which merely repeat what code says
>   send-email: fix style: cuddle 'elsif' and 'else' with closing brace
>   send-email: refactor sendmail aliases parser
>   send-email: simplify sendmail aliases comment and blank line
>     recognizer
>   send-email: implement sendmail aliases line continuation support
>   t9001: refactor sendmail aliases test infrastructure
>   t9001: add sendmail aliases line continuation tests
>
>  Documentation/git-send-email.txt |  5 ++-
>  git-send-email.perl              | 54 ++++++++++++++-------------
>  t/t9001-send-email.sh            | 81 +++++++++++++++++++++++++++++++---------
>  3 files changed, 94 insertions(+), 46 deletions(-)
>
> --
> 2.4.2.538.g5f4350e
>

← back to recent threads