author | Junio C Hamano <gitster@pobox.com> | |
Wed, 27 Oct 2010 05:02:52 +0000 (22:02 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 27 Oct 2010 05:02:52 +0000 (22:02 -0700) |
* ab/send-email-perl:
send-email: extract_valid_address use qr// regexes
send-email: is_rfc2047_quoted use qr// regexes
send-email: use Perl idioms in while loop
send-email: make_message_id use "require" instead of "use"
send-email: send_message die on $!, not $?
send-email: use (?:) instead of () if no match variables are needed
send-email: sanitize_address use qq["foo"], not "\"foo\""
send-email: sanitize_address use $foo, not "$foo"
send-email: use \E***\Q instead of \*\*\*
send-email: cleanup_compose_files doesn't need a prototype
send-email: unique_email_list doesn't need a prototype
send-email: file_declares_8bit_cte doesn't need a prototype
send-email: get_patch_subject doesn't need a prototype
send-email: use lexical filehandles during sending
send-email: use lexical filehandles for $compose
send-email: use lexical filehandle for opendir
Conflicts:
git-send-email.perl
send-email: extract_valid_address use qr// regexes
send-email: is_rfc2047_quoted use qr// regexes
send-email: use Perl idioms in while loop
send-email: make_message_id use "require" instead of "use"
send-email: send_message die on $!, not $?
send-email: use (?:) instead of () if no match variables are needed
send-email: sanitize_address use qq["foo"], not "\"foo\""
send-email: sanitize_address use $foo, not "$foo"
send-email: use \E***\Q instead of \*\*\*
send-email: cleanup_compose_files doesn't need a prototype
send-email: unique_email_list doesn't need a prototype
send-email: file_declares_8bit_cte doesn't need a prototype
send-email: get_patch_subject doesn't need a prototype
send-email: use lexical filehandles during sending
send-email: use lexical filehandles for $compose
send-email: use lexical filehandle for opendir
Conflicts:
git-send-email.perl
1 | 2 | |||
---|---|---|---|---|
git-send-email.perl | patch | | diff1 | | diff2 | | blob | history |
t/t9001-send-email.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc git-send-email.perl
index f304ef913ecde17db0ad7ad4c57ad52028abc9a3,db17aae0207ed501a479e21e36f6d6ab6aa67adb..f68ed5a5d3208eb0669d7dc1289f40c567e077c7
--- 1/git-send-email.perl
--- 2/git-send-email.perl
+++ b/git-send-email.perl
my $smtp;
my $auth;
- sub unique_email_list(@);
- sub cleanup_compose_files();
-
# Variables we fill in automatically, or via prompting:
-my (@to,$no_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,
+my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,
$initial_reply_to,$initial_subject,@files,
$author,$sender,$smtp_authpass,$annotate,$compose,$time);
$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;
$message_id = undef;
}
- open(F, "$cmd \Q$file\E |")
+# 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 = ();
- while(<F>) {
- my $address = $_;
++ open my $fh, "$cmd \Q$file\E |"
+ or die "($prefix) Could not execute '$cmd'";
- close F
++ 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 $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;
}
diff --cc t/t9001-send-email.sh
Simple merge