From: Brian Masney <masneyb@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
Jerome Brunet <jbrunet@baylibre.com>,
Brian Masney <masneyb@kernel.org>
Subject: [PATCH b4 1/2] correctly walk a series when a message is missing from the lore archive
Date: Tue, 17 Nov 2026 11:44:40 -0500 [thread overview]
Message-ID: <20261117-lore-missing-msg-id-fix-v1-1-a5d13a11eb10@kernel.org> (raw)
In-Reply-To: <20261117-lore-missing-msg-id-fix-v1-0-a5d13a11eb10@kernel.org>
When a parent message does not make it's way into the lore archive, walk
the references to look for the closet ancestor that is available to
allow parsing what all is available.
A practical effect of this bug is that it can cause a trailer that
someone left will not be picked up. For example, look at the thread
linked below and it shows the message from Brian with ID
avXhA9mJL0EIcm_0@x1g10 is missing from the lore archive. This causes
the Reviewed-by from Jerome that is in the archive to not be picked
up when 'git am' is used. With this change, the trailer is picked up
as expected.
Let's also add a test case for this scenario.
Link: https://lore.kernel.org/linux-clk/20261112-upstream-clk-divider-large-rates-v2-0-18f3bb888b0c@baylibre.com/
Assisted-by: LLM
Signed-off-by: Brian Masney <masneyb@kernel.org>
---
src/b4/__init__.py | 15 +++++++++++++++
src/tests/test___init__.py | 31 +++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 1ea899c35fa9..e2c1b617a609 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -643,6 +643,21 @@ class LoreMailbox:
break
elif (pmsg := self.msgid_map.get(fmsg.in_reply_to)) is not None:
logger.debug('Found in-reply-to %s in msgid_map', fmsg.in_reply_to)
+ else:
+ # The parent never made it into the thread (e.g. it is
+ # missing from the archive), so use the closest ancestor
+ # from References that we do have
+ for refid in reversed(fmsg.references):
+ if (
+ refid not in (fmsg.msgid, fmsg.in_reply_to)
+ and (pmsg := self.msgid_map.get(refid)) is not None
+ ):
+ logger.debug(
+ 'Missing in-reply-to %s, using references entry %s',
+ fmsg.in_reply_to,
+ refid,
+ )
+ break
if pmsg is None:
# Can't find the message we're replying to here
continue
diff --git a/src/tests/test___init__.py b/src/tests/test___init__.py
index 8b041340e9e5..50ba2928e64e 100644
--- a/src/tests/test___init__.py
+++ b/src/tests/test___init__.py
@@ -539,6 +539,37 @@ def test_get_series_twice_adds_no_duplicate_trailers(
assert _followup_trailer_keys(again) == before
+def test_followup_with_missing_parent_uses_references(sampledir: str) -> None:
+ """A reply whose In-Reply-To parent is absent from the thread still
+ has its trailers attached via the closest known References entry."""
+ lmbx = b4.LoreMailbox()
+ for msg in b4.get_msgs_from_mailbox_or_maildir(
+ f'{sampledir}/trailers-followup-with-cover.mbox'
+ ):
+ lmbx.add_message(msg)
+ reply = email.message.EmailMessage()
+ reply['From'] = 'Missing Parent <missing.parent@example.com>'
+ reply['Subject'] = 'Re: [PATCH v2 2/2] Simple test 2'
+ reply['Date'] = 'Tue, 30 Aug 2022 11:19:07 -0400'
+ reply['Message-Id'] = '<late-reply@example.com>'
+ reply['In-Reply-To'] = '<not-in-archive@example.com>'
+ reply['References'] = (
+ '<cover-message@example.com> <patch-2-message@example.com> '
+ '<not-in-archive@example.com>'
+ )
+ reply.set_content(
+ 'Agreed.\n\nReviewed-by: Missing Parent <missing.parent@example.com>\n'
+ )
+ lmbx.add_message(reply)
+ lser = lmbx.get_series()
+ assert lser is not None
+ patch2 = lser.patches[2]
+ assert patch2 is not None
+ assert ('Reviewed-by', 'Missing Parent <missing.parent@example.com>') in [
+ (t.name, t.value) for t in patch2.followup_trailers
+ ]
+
+
def test_same_trailer_in_two_replies_is_kept_twice(sampledir: str) -> None:
"""Only a repeat from the same message is a duplicate, not a second reply."""
msgs = b4.get_msgs_from_mailbox_or_maildir(
--
2.56.1
next prev parent reply other threads:[~2026-11-17 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 16:44 [PATCH b4 0/2] correctly walk a series when a message is missing from the lore archive Brian Masney
2026-11-17 16:44 ` Brian Masney [this message]
2026-11-17 16:44 ` [PATCH b4 2/2] review: tui: " Brian Masney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117-lore-missing-msg-id-fix-v1-1-a5d13a11eb10@kernel.org \
--to=masneyb@kernel.org \
--cc=jbrunet@baylibre.com \
--cc=konstantin@linuxfoundation.org \
--cc=tools@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox