public inbox for tools@linux.kernel.org
 help / color / mirror / Atom feed
* [PATCH b4] send: add --in-reply-to option for threading cover letters
@ 2026-03-06 14:13 Christian Brauner
  2026-03-06 14:36 ` Vlastimil Babka (SUSE)
  2026-03-06 15:02 ` Konstantin Ryabitsev
  0 siblings, 2 replies; 8+ messages in thread
From: Christian Brauner @ 2026-03-06 14:13 UTC (permalink / raw)
  To: Kernel.org Tools
  Cc: Konstantin Ryabitsev, Christian Brauner, Claude Opus 4.6,
	Christian Brauner

Add a --in-reply-to flag to b4 send that sets the In-Reply-To and
References headers on the cover letter (or single patch). This allows
sending a new series version as a reply to the previous version or to
an existing discussion thread, which is a common workflow on mailing
lists that b4 did not directly support until now.

The message ID is automatically wrapped in angle brackets if not
already provided with them.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 src/b4/command.py |  2 ++
 src/b4/ez.py      | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/b4/command.py b/src/b4/command.py
index a49a8bc..c246d30 100644
--- a/src/b4/command.py
+++ b/src/b4/command.py
@@ -425,6 +425,8 @@ def setup_parser() -> argparse.ArgumentParser:
                          help='Do not add any addresses found in the cover or patch trailers to To: or Cc:')
     sp_send.add_argument('--to', nargs='+', metavar='ADDR', help='Addresses to add to the To: list')
     sp_send.add_argument('--cc', nargs='+', metavar='ADDR', help='Addresses to add to the Cc: list')
+    sp_send.add_argument('--in-reply-to', dest='in_reply_to', metavar='MSGID',
+                         help='Message ID to use as In-Reply-To for the cover letter (or single patch)')
     sp_send.add_argument('--not-me-too', action='store_true', default=False,
                          help='Remove yourself from the To: or Cc: list')
     sp_send.add_argument('--resend', metavar='vN', nargs='?', const='latest',
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 52eb239..3e703ed 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -2203,6 +2203,20 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
             logger.info('')
             sys.exit(130)
 
+    if cmdargs.in_reply_to:
+        irt = cmdargs.in_reply_to.strip()
+        if not irt.startswith('<'):
+            irt = f'<{irt}>'
+        cover_msg = patches[0][1]
+        if cover_msg['In-Reply-To']:
+            cover_msg.replace_header('In-Reply-To', irt)
+        else:
+            cover_msg.add_header('In-Reply-To', irt)
+        if cover_msg['References']:
+            cover_msg.replace_header('References', irt)
+        else:
+            cover_msg.add_header('References', irt)
+
     # And now we go through each message to set addressees and send them off
     sign = True
     _csnps = str(config.get('send-no-patatt-sign', ''))

---
base-commit: 5b4eaae60fd938a865dda1916885e9a1c7ddce8a
change-id: 20260306-b4-send-in-reply-to-907e8e36d7f8


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-07 14:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-06 14:13 [PATCH b4] send: add --in-reply-to option for threading cover letters Christian Brauner
2026-03-06 14:36 ` Vlastimil Babka (SUSE)
2026-03-06 15:02 ` Konstantin Ryabitsev
2026-03-06 15:26   ` Christian Brauner
2026-03-06 15:41     ` Konstantin Ryabitsev
2026-03-06 16:17       ` Christian Brauner
2026-03-06 17:26         ` Konstantin Ryabitsev
2026-03-07 14:11           ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox