On Mon, Dec 15, 2025 at 11:52:38AM +1300, [email protected] wrote:

> using the mbox.gz from your link, I get a different failure, this time
> on patch 11
> [...]
> jimc@frodo:~/projects/lx/linux.git$ gunzip
> ~/Downloads/PATCH-v6-00-31-drm-dyndbg-Fix-dynamic-debug-classmap-regression.mbox.gz
> gzip: 
> /home/jimc/Downloads/PATCH-v6-00-31-drm-dyndbg-Fix-dynamic-debug-classmap-regression.mbox
> already exists; do you wish to overwrite (y or n)? y
> jimc@frodo:~/projects/lx/linux.git$ git am --empty=drop

Ah, that is the difference: you are applying directly from the
downloaded mbox file, whereas I picked out the messages using mutt.

The mbox provided by lore is generally in the order the messages were
received, which does not necessarily correspond to the order they were
sent, or the rfc822 dates, or the subject lines. But "git am" does not
do any sorting; it applies the messages in the order it finds them in
the input mbox. So you get out-of-order patch application.

There's another possible gotcha, as well. The mbox for the thread will
contain other non-patch messages like the cover letter and any review
responses. Adding --empty=drop as you did will generally skip past
those, but not always. If somebody responds and says "Maybe do it like
this" with an inline patch, then "git am" will pick up that patch, too!


It worked for me because when I picked the patches out of the thread in
mutt, it showed them sorted by rfc822 date header and used that same
ordering to dump them to the new, filtered mbox. And of course I
manually decided on which messages were part of the patch series and
excluded the rest (based on subject lines).

It would probably be possible to teach "git am" to sort by date header,
but that's not always right, either (you could have a local series with
out-of-order author dates due to rebasing). You could use the subject
lines as heuristics, if you know that the sender didn't use any exotic
format-patch options. So there are probably some heuristics at play.

And none of those ideas helps with the selection problem, which is
another heuristics ball of wax.

Fortunately, I think b4 has melted that wax for us already (OK, maybe
I'm losing the metaphor). If you do:

  b4 mbox 
https://lore.kernel.org/lkml/[email protected]/

you'll get that unordered mbox again. But if you use the "am" command:

  b4 am 
https://lore.kernel.org/lkml/[email protected]/

it figures everything out and gives you the clean series in an mbox. It
also knows how to pick the latest version of the series (your v6 is in
its own thread here, but if it were in a thread with v1..v5, you again
get into another message-selection problem).

-Peff

Reply via email to