Skip to content

Commit

Permalink
send-email: 'References:' should only reference what is sent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Witten authored and Junio C Hamano committed Apr 14, 2009
1 parent 40e6e8a commit 15da108
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -864,7 +868,7 @@ sub send_message
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);
Expand Down Expand Up @@ -945,7 +949,7 @@ sub send_message
$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);
Expand All @@ -966,6 +970,8 @@ sub send_message
print "Result: OK\n";
}
}

return 1;
}

$reply_to = $initial_reply_to;
Expand Down Expand Up @@ -1126,10 +1132,10 @@ sub send_message

@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";
Expand Down

0 comments on commit 15da108

Please sign in to comment.