On Tue, 2024-11-05 at 15:32 +0100, Kristoffer Haugsbakk wrote: > You could make it more robust with some backtracking, like finding > the > last `^diff` and movig back. That’s OK in a file with only one patch > (`.patch`) but harder to do for an mbox file. I wonder whether that (parsing from the end) is really a proper solution or whether it could still break. A patch can contain multiple diffs, like in: From b3b82e59ea52fc059dc23ecc1a3cc0810d297b10 Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer <mail@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 5 Nov 2024 15:40:13 +0100 Subject: [PATCH] foo --- a | 1 + b | 1 + 2 files changed, 2 insertions(+) create mode 100644 a create mode 100644 b diff --git a/a b/a new file mode 100644 index 0000000..ae5b3c5 --- /dev/null +++ b/a @@ -0,0 +1 @@ +Aaa diff --git a/b b/b new file mode 100644 index 0000000..f761ec1 --- /dev/null +++ b/b @@ -0,0 +1 @@ +bbb -- 2.45.2 But the unified diff shouldn't be able to contain newlines or a line consisting only of --- . So would a proper description be: