aboutsummaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorMichael Witten <mfwitten@gmail.com>2009-04-13 13:23:51 -0500
committerJunio C Hamano <gitster@pobox.com>2009-04-14 01:56:23 -0700
commit15da10843135490e12efca7f8bc806ae0bcf5c53 (patch)
tree5e1d1a4cb67cfec247c0a2a5e7e524f17c0c79f4 /git-send-email.perl
parent40e6e8a0c485e618be366f13247fd745ac00b911 (diff)
downloadgit-15da10843135490e12efca7f8bc806ae0bcf5c53.tar.gz
git-15da10843135490e12efca7f8bc806ae0bcf5c53.tar.xz
send-email: 'References:' should only reference what is sent
If someone responded with a negative (n|no) to the confirmation, then the Message-ID of the discarded email is no longer used in the References: header of subsequent emails. Consequently, send_message() now returns 1 if the message was sent and 0 otherwise. Signed-off-by: Michael Witten <mfwitten@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl14
1 files changed, 10 insertions, 4 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 7526ade76..43f956b78 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -796,6 +796,10 @@ sub sanitize_address
}
+# Returns 1 if the message was sent, and 0 otherwise.
+# In actuality, the whole program dies when a there
+# is an error sending a message.
+
sub send_message
{
my @recipients = unique_email_list(@to);
@@ -864,7 +868,7 @@ X-Mailer: git-send-email $gitversion
default => $ask_default);
die "Send this email reply required" unless defined $_;
if (/^n/i) {
- return;
+ return 0;
} elsif (/^q/i) {
cleanup_compose_files();
exit(0);
@@ -945,7 +949,7 @@ X-Mailer: git-send-email $gitversion
$smtp->data or die $smtp->message;
$smtp->datasend("$header\n$message") or die $smtp->message;
$smtp->dataend() or die $smtp->message;
- $smtp->ok or die "Failed to send $subject\n".$smtp->message;
+ $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
}
if ($quiet) {
printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
@@ -966,6 +970,8 @@ X-Mailer: git-send-email $gitversion
print "Result: OK\n";
}
}
+
+ return 1;
}
$reply_to = $initial_reply_to;
@@ -1126,10 +1132,10 @@ foreach my $t (@files) {
@cc = (@initial_cc, @cc);
- send_message();
+ my $message_was_sent = send_message();
# set up for the next message
- if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) {
+ if ($message_was_sent and $chain_reply_to || not defined $reply_to || length($reply_to) == 0) {
$reply_to = $message_id;
if (length $references > 0) {
$references .= "\n $message_id";