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

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-03-06 14:36 UTC (permalink / raw)
  To: Christian Brauner, Kernel.org Tools
  Cc: Konstantin Ryabitsev, Christian Brauner

On 3/6/26 15:13, Christian Brauner wrote:
> 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

Ewww, don't give people bad ideas please :) That usecase is a mess.

> an existing discussion thread, which is a common workflow on mailing

This makes sense. And it would be really amazing if the given message id was
also used to grab all people from the thread and add them to cc! I find that
part most tedious in these situations. I'm aware the lore page of the
message gives you a command line, but it strips people's names, leaving only
addresses. And it's still manual work.

Thanks!

> 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	[flat|nested] 8+ messages in thread

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Konstantin Ryabitsev @ 2026-03-06 15:02 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Kernel.org Tools, Christian Brauner, Claude Opus 4.6

On Fri, Mar 06, 2026 at 03:13:06PM +0100, Christian Brauner wrote:
> 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.

Isn't this already implemented with send-same-thread?
https://b4.docs.kernel.org/en/latest/config.html#term-b4.send-same-thread

-K

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

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  2026-03-06 15:02 ` Konstantin Ryabitsev
@ 2026-03-06 15:26   ` Christian Brauner
  2026-03-06 15:41     ` Konstantin Ryabitsev
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Brauner @ 2026-03-06 15:26 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: Kernel.org Tools, Christian Brauner, Claude Opus 4.6

On Fri, Mar 06, 2026 at 10:02:39AM -0500, Konstantin Ryabitsev wrote:
> On Fri, Mar 06, 2026 at 03:13:06PM +0100, Christian Brauner wrote:
> > 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.
> 
> Isn't this already implemented with send-same-thread?
> https://b4.docs.kernel.org/en/latest/config.html#term-b4.send-same-thread

I don't think so. At leat not for what I want to use this for.
Here's an example where I used b4 send --in-reply-to already:

https://lore.kernel.org/all/20260306-work-kernel-exit-v1-1-8f871f6281cb@kernel.org

I wanted the bugfix to be a reply to the original bug and I didn't see a
good way of doing this.

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

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  2026-03-06 15:26   ` Christian Brauner
@ 2026-03-06 15:41     ` Konstantin Ryabitsev
  2026-03-06 16:17       ` Christian Brauner
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Ryabitsev @ 2026-03-06 15:41 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Kernel.org Tools, Christian Brauner, Claude Opus 4.6

On Fri, Mar 06, 2026 at 04:26:52PM +0100, Christian Brauner wrote:
> > > 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.
> > 
> > Isn't this already implemented with send-same-thread?
> > https://b4.docs.kernel.org/en/latest/config.html#term-b4.send-same-thread
> 
> I don't think so. At leat not for what I want to use this for.
> Here's an example where I used b4 send --in-reply-to already:
> 
> https://lore.kernel.org/all/20260306-work-kernel-exit-v1-1-8f871f6281cb@kernel.org
> 
> I wanted the bugfix to be a reply to the original bug and I didn't see a
> good way of doing this.

I see the desire to do this, but this is also the kind of pattern that causes
all sorts of grief:

- you have to pass --no-parent if you want to retrieve your patch

- you can no longer retrieve the parent series at all. Try it yourself:
  b4 am 20260120-work-pidfs-rhashtable-v2-1-d593c4d0f576@kernel.org
  You will only be able to retrieve your patch now, not the original patch.

I don't see a way to reconcile what you're trying to do and keeping automation
working reliably, do you?

-- 
KR

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

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  2026-03-06 15:41     ` Konstantin Ryabitsev
@ 2026-03-06 16:17       ` Christian Brauner
  2026-03-06 17:26         ` Konstantin Ryabitsev
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Brauner @ 2026-03-06 16:17 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: Kernel.org Tools, Christian Brauner, Claude Opus 4.6

On Fri, Mar 06, 2026 at 10:41:38AM -0500, Konstantin Ryabitsev wrote:
> On Fri, Mar 06, 2026 at 04:26:52PM +0100, Christian Brauner wrote:
> > > > 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.
> > > 
> > > Isn't this already implemented with send-same-thread?
> > > https://b4.docs.kernel.org/en/latest/config.html#term-b4.send-same-thread
> > 
> > I don't think so. At leat not for what I want to use this for.
> > Here's an example where I used b4 send --in-reply-to already:
> > 
> > https://lore.kernel.org/all/20260306-work-kernel-exit-v1-1-8f871f6281cb@kernel.org
> > 
> > I wanted the bugfix to be a reply to the original bug and I didn't see a
> > good way of doing this.
> 
> I see the desire to do this, but this is also the kind of pattern that causes
> all sorts of grief:
> 
> - you have to pass --no-parent if you want to retrieve your patch
> 
> - you can no longer retrieve the parent series at all. Try it yourself:
>   b4 am 20260120-work-pidfs-rhashtable-v2-1-d593c4d0f576@kernel.org
>   You will only be able to retrieve your patch now, not the original patch.
> 
> I don't see a way to reconcile what you're trying to do and keeping automation
> working reliably, do you?

Yeah, I wasn't aware that this is a limitation. If this isn't super
uncommon, than it is broken with similar mail chains. Good to know that
this breaks b4.

Maybe what Vlastimil proposed would serve at least a similar purpose
where it adds the people on the bug report to the Cc and automatically
inserts a Link: to the report in the message or the commit.

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

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  2026-03-06 16:17       ` Christian Brauner
@ 2026-03-06 17:26         ` Konstantin Ryabitsev
  2026-03-07 14:11           ` Christian Brauner
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Ryabitsev @ 2026-03-06 17:26 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Kernel.org Tools, Christian Brauner

On Fri, Mar 06, 2026 at 05:17:57PM +0100, Christian Brauner wrote:
> > I don't see a way to reconcile what you're trying to do and keeping automation
> > working reliably, do you?
> 
> Yeah, I wasn't aware that this is a limitation. If this isn't super
> uncommon, than it is broken with similar mail chains. Good to know that
> this breaks b4.
> 
> Maybe what Vlastimil proposed would serve at least a similar purpose
> where it adds the people on the bug report to the Cc and automatically
> inserts a Link: to the report in the message or the commit.

Right, so if I understand it correctly, we want to be able to post a "here's a
related patch" but without it being confused as a patch within the same
series. I think one way to accomplish this would be to post the patch under
the scissors, like so:

    Hey, how about this patch...

    -- >8 --

    From: ...
    Subject: [PATCH ...] Unrelated Foo Patch

    This is foo patch for bar.

    git --diff ...

I *think* this would do the right thing, but I need to test it first. From
your perspective, would this do what you're looking for?

Regards,
-- 
KR

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

* Re: [PATCH b4] send: add --in-reply-to option for threading cover letters
  2026-03-06 17:26         ` Konstantin Ryabitsev
@ 2026-03-07 14:11           ` Christian Brauner
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Brauner @ 2026-03-07 14:11 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: Kernel.org Tools, Christian Brauner

On Fri, Mar 06, 2026 at 12:26:57PM -0500, Konstantin Ryabitsev wrote:
> On Fri, Mar 06, 2026 at 05:17:57PM +0100, Christian Brauner wrote:
> > > I don't see a way to reconcile what you're trying to do and keeping automation
> > > working reliably, do you?
> > 
> > Yeah, I wasn't aware that this is a limitation. If this isn't super
> > uncommon, than it is broken with similar mail chains. Good to know that
> > this breaks b4.
> > 
> > Maybe what Vlastimil proposed would serve at least a similar purpose
> > where it adds the people on the bug report to the Cc and automatically
> > inserts a Link: to the report in the message or the commit.
> 
> Right, so if I understand it correctly, we want to be able to post a "here's a
> related patch" but without it being confused as a patch within the same
> series. I think one way to accomplish this would be to post the patch under

Yes, absolutely.

> the scissors, like so:
> 
>     Hey, how about this patch...
> 
>     -- >8 --
> 
>     From: ...
>     Subject: [PATCH ...] Unrelated Foo Patch
> 
>     This is foo patch for bar.
> 
>     git --diff ...
> 
> I *think* this would do the right thing, but I need to test it first. From
> your perspective, would this do what you're looking for?

Yes, I think this would work great.

^ permalink raw reply	[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