[RFC/PATCH 3/2 (squash!)] git-send-email: Warn about rejected automatically added recipients

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
On Thu, 5 May 2011, Jakub Narebski wrote:
> On Wed, 4 May 2011, Jeff King wrote:
>> On Wed, May 04, 2011 at 06:12:08PM +0200, Jakub Narebski wrote:
>>> On Fri, 15 Apr 2011, Jeff King wrote:

>>>> [...] You could probably remember which recipients are "important"
>>>> (i.e., given on the command line) and which were pulled automatically
>>>> from the commit information, and then feed each recipient individually.
>>>> If important ones fail, abort the message. If an unimportant one fails,
>>>> send the message anyway, but remember the bad address and report the
>>>> error at the end.
> 
> It does not warn about bad addresses from body, and there are no tests yet!

Now it does warn, though I don't know if we should warn after each message,
or all together at the end, and if we should warn only about _new_ addresses.

Still no tests, and no idea how to write one...

Also if it is to be standalone commit, it needs better commit message.
But if it is to squashed with previous, it doesn't ;-)

 git-send-email.perl |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index e758fd9..b8d4fb9 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1136,11 +1136,20 @@ X-Mailer: git-send-email $gitversion
 
 		$smtp->mail( $raw_from ) or die $smtp->message;
 		$smtp->to( @recipients ) or die $smtp->message;
-		$smtp->to( @recipients_extra, { Notify => ['NEVER'], SkipBad => 1 });
+		my @good_recips =
+			$smtp->to( @recipients_extra, { Notify => ['NEVER'], SkipBad => 1 });
 		$smtp->data or die $smtp->message;
 		$smtp->datasend("$header\n$message") or die $smtp->message;
 		$smtp->dataend() or die $smtp->message;
 		$smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
+
+		%seen = ();
+		unique_email_list(\%seen, @good_recips);
+		# bad recipients are those not seen on list of good recipients
+		my @bad_recips = unique_email_list(\%seen, @recipients_extra);
+		@bad_recips and
+			warn "W: The following addresses added from body were rejected:\n\t".
+				join("\n\t", @bad_recips)."\n";
 	}
 	if ($quiet) {
 		printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
-- 
1.7.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]