All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] send-email: add sendmail aliases line continuation support
@ 2015-05-31 22:29 Eric Sunshine
  2015-05-31 22:29 ` [PATCH 1/9] send-email: further document missing sendmail aliases functionality Eric Sunshine
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/9] send-email: further document missing sendmail aliases functionality
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-06-01 11:43   ` Allen Hubbe
  2015-05-31 22:29 ` [PATCH 2/9] send-email: visually distinguish sendmail aliases parser warnings Eric Sunshine
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/9] send-email: visually distinguish sendmail aliases parser warnings
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
  2015-05-31 22:29 ` [PATCH 1/9] send-email: further document missing sendmail aliases functionality Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 3/9] send-email: drop noise comments which merely repeat what code says Eric Sunshine
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/9] send-email: drop noise comments which merely repeat what code says
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
  2015-05-31 22:29 ` [PATCH 1/9] send-email: further document missing sendmail aliases functionality Eric Sunshine
  2015-05-31 22:29 ` [PATCH 2/9] send-email: visually distinguish sendmail aliases parser warnings Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 4/9] send-email: fix style: cuddle 'elsif' and 'else' with closing brace Eric Sunshine
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 git-send-email.perl | 5 -----
 1 file changed, 5 deletions(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/9] send-email: fix style: cuddle 'elsif' and 'else' with closing brace
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (2 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 3/9] send-email: drop noise comments which merely repeat what code says Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 5/9] send-email: refactor sendmail aliases parser Eric Sunshine
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 git-send-email.perl | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/9] send-email: refactor sendmail aliases parser
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (3 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 4/9] send-email: fix style: cuddle 'elsif' and 'else' with closing brace Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer Eric Sunshine
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (4 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 5/9] send-email: refactor sendmail aliases parser Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-06-01  3:30   ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 7/9] send-email: implement sendmail aliases line continuation support Eric Sunshine
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/9] send-email: implement sendmail aliases line continuation support
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (5 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 8/9] t9001: refactor sendmail aliases test infrastructure Eric Sunshine
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 8/9] t9001: refactor sendmail aliases test infrastructure
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (6 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 7/9] send-email: implement sendmail aliases line continuation support Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-05-31 22:29 ` [PATCH 9/9] t9001: add sendmail aliases line continuation tests Eric Sunshine
  2015-06-01 11:49 ` [PATCH 0/9] send-email: add sendmail aliases line continuation support Allen Hubbe
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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(-)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 9/9] t9001: add sendmail aliases line continuation tests
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (7 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 8/9] t9001: refactor sendmail aliases test infrastructure Eric Sunshine
@ 2015-05-31 22:29 ` Eric Sunshine
  2015-06-01 11:49 ` [PATCH 0/9] send-email: add sendmail aliases line continuation support Allen Hubbe
  9 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-05-31 22:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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(+)

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer
  2015-05-31 22:29 ` [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer Eric Sunshine
@ 2015-06-01  3:30   ` Eric Sunshine
  0 siblings, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2015-06-01  3:30 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Allen Hubbe, Eric Sunshine

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/

> 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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/9] send-email: further document missing sendmail aliases functionality
  2015-05-31 22:29 ` [PATCH 1/9] send-email: further document missing sendmail aliases functionality Eric Sunshine
@ 2015-06-01 11:43   ` Allen Hubbe
  2015-06-01 18:22     ` Eric Sunshine
  0 siblings, 1 reply; 15+ messages in thread
From: Allen Hubbe @ 2015-06-01 11:43 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: git, Junio C Hamano

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:
> 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
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/9] send-email: add sendmail aliases line continuation support
  2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
                   ` (8 preceding siblings ...)
  2015-05-31 22:29 ` [PATCH 9/9] t9001: add sendmail aliases line continuation tests Eric Sunshine
@ 2015-06-01 11:49 ` Allen Hubbe
  9 siblings, 0 replies; 15+ messages in thread
From: Allen Hubbe @ 2015-06-01 11:49 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: git, Junio C Hamano

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:
> 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
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/9] send-email: further document missing sendmail aliases functionality
  2015-06-01 11:43   ` Allen Hubbe
@ 2015-06-01 18:22     ` Eric Sunshine
  2015-06-01 22:44       ` Allen Hubbe
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Sunshine @ 2015-06-01 18:22 UTC (permalink / raw)
  To: Allen Hubbe; +Cc: git, Junio C Hamano

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 ---

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/9] send-email: further document missing sendmail aliases functionality
  2015-06-01 18:22     ` Eric Sunshine
@ 2015-06-01 22:44       ` Allen Hubbe
  0 siblings, 0 replies; 15+ messages in thread
From: Allen Hubbe @ 2015-06-01 22:44 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: git, Junio C Hamano

This looks good.

On Mon, Jun 1, 2015 at 2:22 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 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 ---

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-06-01 22:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-31 22:29 [PATCH 0/9] send-email: add sendmail aliases line continuation support Eric Sunshine
2015-05-31 22:29 ` [PATCH 1/9] send-email: further document missing sendmail aliases functionality Eric Sunshine
2015-06-01 11:43   ` Allen Hubbe
2015-06-01 18:22     ` Eric Sunshine
2015-06-01 22:44       ` Allen Hubbe
2015-05-31 22:29 ` [PATCH 2/9] send-email: visually distinguish sendmail aliases parser warnings Eric Sunshine
2015-05-31 22:29 ` [PATCH 3/9] send-email: drop noise comments which merely repeat what code says Eric Sunshine
2015-05-31 22:29 ` [PATCH 4/9] send-email: fix style: cuddle 'elsif' and 'else' with closing brace Eric Sunshine
2015-05-31 22:29 ` [PATCH 5/9] send-email: refactor sendmail aliases parser Eric Sunshine
2015-05-31 22:29 ` [PATCH 6/9] send-email: simplify sendmail aliases comment and blank line recognizer Eric Sunshine
2015-06-01  3:30   ` Eric Sunshine
2015-05-31 22:29 ` [PATCH 7/9] send-email: implement sendmail aliases line continuation support Eric Sunshine
2015-05-31 22:29 ` [PATCH 8/9] t9001: refactor sendmail aliases test infrastructure Eric Sunshine
2015-05-31 22:29 ` [PATCH 9/9] t9001: add sendmail aliases line continuation tests Eric Sunshine
2015-06-01 11:49 ` [PATCH 0/9] send-email: add sendmail aliases line continuation support Allen Hubbe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.