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

[PATCH v3] git-send-email.perl: make initial In-Reply-To apply only to first email

From
Antonio Ospite <ospite@studenti.unina.it>
Date
Nov 5, 2010, 20:59 UTC
Message-ID
<1288990769-13307-1-git-send-email-ospite@studenti.unina.it>
In-Reply-To
<20101020004533.b64d446c.ospite@studenti.unina.it>

When an initial In-Reply-To is supplied it should apply only to the first email, second and subsequent messages should behave just according to the --[no-]chain-reply-to setting; this is the typical behaviour we want when we send a series with cover letter in reply to some discussion, this is what the man page says about the --[no-]chain-reply-to option and this is also how the --in-reply-to option behaves in git-format-patch.

Moreover, when $initial_reply_to is asked to the user interactively it is asked as the "Message-ID to be used as In-Reply-To for the _first_ email", this makes the user think that the second and subsequent patches are not using it but are considered as replies to the first message or chained according to the --[no-]chain-reply setting.

Adjust also the documentation about --in-reply-to to avoid ambiguities.
NOTE: This patch changes the current behaviour and brings it to be what
I think was the intentions stated in the documentation, also aligning it
to how git-format-patch behaves; in order to achieve the old behaviour
of a flat structure in reply to something the user can always use
"--no-thread --in-reply-to <...>".
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---
Changes since v2:
 - Make the purpose of the patch more explicit
 - Adjust the documentation
 - Make the test narrower and more explicit as well
I am CCing some of the latest contributors to git-send-email.perl

Juno, there are still some unanswered questions (one about the and-chains in tests) in one of previous mails in this thread.

With Best Regards,
   Antonio
 Documentation/git-send-email.txt |    8 +++++---
 git-send-email.perl              |    3 ++-
 t/t9001-send-email.sh            |   14 ++++++++++++++
 3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 05904e0..acbff9b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -82,9 +82,11 @@ See the CONFIGURATION section for 'sendemail.multiedit'.
 	set, as returned by "git var -l".
 
 --in-reply-to=<identifier>::
-	Specify the contents of the first In-Reply-To header.
-	Subsequent emails will refer to the previous email
-	instead of this if --chain-reply-to is set.
+	Make the first mail (or all the mails with `--no-thread`) appear as a
+	reply to the given Message-Id, which avoids breaking threads to
+	provide a new patch series.
+	The second and subsequent emails will be sent as replies according to
+	the --[no]-chain-reply-to setting.
 	Only necessary if --compose is also set.  If --compose
 	is not set, this will be prompted for.
 
diff --git a/git-send-email.perl b/git-send-email.perl
index f68ed5a..fe6b848 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1319,7 +1319,8 @@ foreach my $t (@files) {
 
 	# set up for the next message
 	if ($thread && $message_was_sent &&
-		(chain_reply_to() || !defined $reply_to || length($reply_to) == 0)) {
+		(chain_reply_to() || !defined $reply_to || length($reply_to) == 0 ||
+		$message_num == 1)) {
 		$reply_to = $message_id;
 		if (length $references > 0) {
 			$references .= "\n $message_id";
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index d1ba252..c85be0f 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -313,6 +313,20 @@ test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
 	! grep "^In-Reply-To: < *>" msgtxt1
 '
 
+test_expect_success $PREREQ 'Apply initial In-Reply-To only to first patch with --thread' '
+	clean_fake_sendmail &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--thread \
+		--in-reply-to="<unique-message-id@example.com>" \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		$patches $patches \
+		2>errors
+        # The second message should not have the initial In-Reply-To
+        test $(sed -n -e "s/^In-Reply-To: \(.*\)/\1/p" msgtxt2) != "<unique-message-id@example.com>"
+'
+
 test_expect_success $PREREQ 'setup fake editor' '
 	(echo "#!$SHELL_PATH" &&
 	 echo "echo fake edit >>\"\$1\""
-- 
1.7.2.3
Previous: Antonio OspiteNext: Matthieu Moy
Message 9 of 19 in “git-send-email.perl: fix In-Reply-To for second and subsequent patches”
  1. git-send-email.perl: fix In-Reply-To for second and subsequent patchesAntonio Ospite, Oct 14, 2010
  2. Jonathan NiederOct 14, 2010
  3. Antonio OspiteOct 15, 2010
  4. git-send-email.perl: fix In-Reply-To for second and subsequent patchesAntonio Ospite, Oct 19, 2010
  5. Junio C HamanoOct 19, 2010
  6. Junio C HamanoOct 19, 2010
  7. Antonio OspiteOct 19, 2010
  8. Antonio OspiteOct 26, 2010
  9. git-send-email.perl: make initial In-Reply-To apply only to first emailAntonio Ospite, Nov 5, 2010
  10. Matthieu MoyNov 5, 2010
  11. Junio C HamanoNov 9, 2010
  12. Antonio OspiteNov 10, 2010
  13. Junio C HamanoNov 10, 2010
  14. [PATCHi v4] git-send-email.perl: make initial In-Reply-To apply only to first emailAntonio Ospite, Nov 12, 2010
  15. Junio C HamanoNov 12, 2010
  16. Junio C HamanoNov 12, 2010
  17. Antonio OspiteNov 12, 2010
  18. Jonathan NiederNov 5, 2010
  19. Antonio OspiteNov 8, 2010

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.