git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH RFC 06/10] send-email: References: should only reference what is actually sent

From
Michael Witten <mfwitten@gmail.com>
Date
Apr 11, 2009, 19:08 UTC
Message-ID
<1239476908-25944-6-git-send-email-mfwitten@gmail.com>
In-Reply-To
<1239476908-25944-5-git-send-email-mfwitten@gmail.com>

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>
---
 git-send-email.perl |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 502f5af..d90c76e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -802,6 +802,10 @@ sub sanitize_address
 
 }
 
+# returns 1 of the message was sent, 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);
@@ -870,7 +874,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);
@@ -951,7 +955,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);
@@ -972,6 +976,8 @@ X-Mailer: git-send-email $gitversion
 			print "Result: OK\n";
 		}
 	}
+
+	return 1;
 }
 
 $reply_to = $initial_reply_to;
@@ -1132,10 +1138,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";
-- 
1.6.2.2.479.g2aec
Previous: Michael WittenNext: Michael Witten
Message 6 of 23 in “Docs: send-email: Put options back into alphabetical order”
  1. 01/10 Docs: send-email: Put options back into alphabetical orderMichael Witten, Apr 11, 2009
  2. 02/10 Docs: send-email: Remove superfluous information in CONFIGURATIONMichael Witten, Apr 11, 2009
  3. 03/10 send-email: Cleanup the usage text and docs a bitMichael Witten, Apr 11, 2009
  4. 04/10 send-email: --smtp-server-port should take an integerMichael Witten, Apr 11, 2009
  5. 05/10 send-email: Handle "GIT:" rather than "GIT: " during --composeMichael Witten, Apr 11, 2009
  6. 06/10 send-email: References: should only reference what is actually sentMichael Witten, Apr 11, 2009
  7. 07/10 send-email: Remove horrible mix of tabs and spacesMichael Witten, Apr 11, 2009
  8. 08/10 send-email: Add --sleep for email throttlingMichael Witten, Apr 11, 2009
  9. 09/10 send-email: Minor cleanup of $smtp_server usage and send_message()Michael Witten, Apr 11, 2009
  10. 10/10 send-email: --compose takes optional argument to existing fileMichael Witten, Apr 11, 2009
  11. Sverre RabbelierApr 11, 2009
  12. Michael WittenApr 11, 2009
  13. Stephen BoydApr 11, 2009
  14. Michael WittenApr 11, 2009
  15. Jay SoffianApr 12, 2009
  16. Michael WittenApr 12, 2009
  17. Sverre RabbelierApr 11, 2009
  18. Michael WittenApr 11, 2009
  19. Miles BaderApr 13, 2009
  20. Michael WittenApr 13, 2009
  21. Stephen BoydApr 11, 2009
  22. Michael WittenApr 11, 2009
  23. Stephen BoydApr 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.