From: Junio C Hamano Date: Thu, 30 Sep 2010 22:00:03 +0000 (-0700) Subject: Merge branch 'jp/send-email-to-cmd' into next X-Git-Tag: ko-next~195 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4284ddbb8d7761937f8cbf7ca3a6ceaf5dd42876;p=git.git Merge branch 'jp/send-email-to-cmd' into next * jp/send-email-to-cmd: git-send-email.perl: Add --to-cmd Conflicts: git-send-email.perl --- 4284ddbb8d7761937f8cbf7ca3a6ceaf5dd42876 diff --cc git-send-email.perl index b9bb18cd5,a73b655e4..aef359451 --- a/git-send-email.perl +++ b/git-send-email.perl @@@ -189,10 -188,10 +190,11 @@@ sub do_edit } # Variables with corresponding config settings - my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd); + my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc); + my ($to_cmd, $cc_cmd); -my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption); -my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain); +my ($smtp_server, $smtp_server_port, @smtp_server_options); +my ($smtp_authuser, $smtp_encryption); +my ($identity, $aliasfiletype, @alias_files, $smtp_domain); my ($validate, $confirm); my (@suppress_cc); my ($auto_8bit_encoding); @@@ -213,11 -212,11 +215,12 @@@ my %config_bool_settings = my %config_settings = ( "smtpserver" => \$smtp_server, "smtpserverport" => \$smtp_server_port, + "smtpserveroption" => \@smtp_server_options, "smtpuser" => \$smtp_authuser, "smtppass" => \$smtp_authpass, - "smtpdomain" => \$smtp_domain, + "smtpdomain" => \$smtp_domain, "to" => \@to, + "tocmd" => \$to_cmd, "cc" => \@initial_cc, "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype, @@@ -1261,22 -1240,12 +1265,12 @@@ foreach my $t (@files) $c, $_) unless $quiet; } } - close F; + close $fh; - if (defined $cc_cmd && !$suppress_cc{'cccmd'}) { - open my $fh, "$cc_cmd \Q$t\E |" - or die "(cc-cmd) Could not execute '$cc_cmd'"; - while(my $c = <$fh>) { - chomp $c; - $c =~ s/^\s*//g; - next if ($c eq $sender and $suppress_from); - push @cc, $c; - printf("(cc-cmd) Adding cc: %s from: '%s'\n", - $c, $cc_cmd) unless $quiet; - } - close $fh - or die "(cc-cmd) failed to close pipe to '$cc_cmd'"; - } + push @to, recipients_cmd("to-cmd", "to", $to_cmd, $t) + if defined $to_cmd; + push @cc, recipients_cmd("cc-cmd", "cc", $cc_cmd, $t) + if defined $cc_cmd && !$suppress_cc{'cccmd'}; if ($broken_encoding{$t} && !$has_content_type) { $has_content_type = 1; @@@ -1334,9 -1303,33 +1328,32 @@@ $message_id = undef; } + # Execute a command (e.g. $to_cmd) to get a list of email addresses + # and return a results array + sub recipients_cmd { + my ($prefix, $what, $cmd, $file) = @_; + + my $sanitized_sender = sanitize_address($sender); + my @addresses = (); - open(F, "$cmd \Q$file\E |") ++ open my $fh, "$cmd \Q$file\E |" + or die "($prefix) Could not execute '$cmd'"; - while() { - my $address = $_; ++ while (my $address = <$fh>) { + $address =~ s/^\s*//g; + $address =~ s/\s*$//g; + $address = sanitize_address($address); + next if ($address eq $sanitized_sender and $suppress_from); + push @addresses, $address; + printf("($prefix) Adding %s: %s from: '%s'\n", + $what, $address, $cmd) unless $quiet; + } - close F ++ close $fh + or die "($prefix) failed to close pipe to '$cmd'"; + return @addresses; + } + cleanup_compose_files(); -sub cleanup_compose_files() { +sub cleanup_compose_files { unlink($compose_filename, $compose_filename . ".final") if $compose; }