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>
Michael Witten committed
Apr 13, 2009 at 13:23 UTC
15da10843135490e12efca7f8bc806ae0bcf5c53
1 file changed
+10
-4
git-send-email.perl
+10
-4
@@ -796,6 +796,10 @@ sub sanitize_address
796
797
}
798
799
+# Returns 1 if the message was sent, and 0 otherwise.
800
+# In actuality, the whole program dies when a there
801
+# is an error sending a message.
802
+
803
sub send_message
804
{
805
my @recipients = unique_email_list(@to);
@@ -864,7 +868,7 @@ X-Mailer: git-send-email $gitversion
868
default => $ask_default);
869
die "Send this email reply required" unless defined $_;
870
if (/^n/i) {
867
- return;
871
+ return 0;
872
} elsif (/^q/i) {
873
cleanup_compose_files();
874
exit(0);
@@ -945,7 +949,7 @@ X-Mailer: git-send-email $gitversion
949
$smtp->data or die $smtp->message;
950
$smtp->datasend("$header\n$message") or die $smtp->message;
951
$smtp->dataend() or die $smtp->message;
948
- $smtp->ok or die "Failed to send $subject\n".$smtp->message;
952
+ $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
953
}
954
if ($quiet) {
955
printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
@@ -966,6 +970,8 @@ X-Mailer: git-send-email $gitversion
970
print "Result: OK\n";
971
}
972
}
973
+
974
+ return 1;
975
}
976
977
$reply_to = $initial_reply_to;
@@ -1126,10 +1132,10 @@ foreach my $t (@files) {
1132
1133
@cc = (@initial_cc, @cc);
1134
1129
- send_message();
1135
+ my $message_was_sent = send_message();
1136
1137
# set up for the next message
1132
- if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) {
1138
+ if ($message_was_sent and $chain_reply_to || not defined $reply_to || length($reply_to) == 0) {
1139
$reply_to = $message_id;
1140
if (length $references > 0) {
1141
$references .= "\n $message_id";