On Fri, Jan 30, 2026 at 12:05:35PM -0800, Josh Poimboeuf wrote:
> On Fri, Jan 30, 2026 at 12:59:48PM -0500, Joe Lawrence wrote:
> > Consider a patch offset by a line:
> >
> > $ cat combined.patch
> > --- src.orig/fs/proc/cmdline.c 2022-10-24 15:41:08.858760066 -0400
> > +++ src/fs/proc/cmdline.c 2022-10-24 15:41:11.698715352 -0400
> > @@ -6,8 +6,7 @@
> >
> > static int cmdline_proc_show(struct seq_file *m, void *v)
> > {
> > - seq_puts(m, saved_command_line);
> > - seq_putc(m, '\n');
> > + seq_printf(m, "%s livepatch=1\n", saved_command_line);
> > return 0;
> > }
> >
> > --- a/fs/proc/version.c
> > +++ b/fs/proc/version.c
> > @@ -9,6 +9,7 @@
> >
> > static int version_proc_show(struct seq_file *m, void *v)
> > {
> > + seq_printf(m, "livepatch ");
> > seq_printf(m, linux_proc_banner,
> > utsname()->sysname,
> > utsname()->release,
> >
> > GNU patch reports the offset:
> >
> > $ patch --dry-run -p1 < combined.patch
> > checking file fs/proc/cmdline.c
> > Hunk #1 succeeded at 7 (offset 1 line).
> > checking file fs/proc/version.c
> >
> > It would pass the initial check as per validate_patches():
> >
> > $ git apply --check < combined.patch && echo "ok"
> > ok
> >
> > But later fail the patch application by refresh_patch():
> >
> > $ git apply --check --recount < combined.patch
> > error: patch failed: fs/proc/cmdline.c:6
> > error: fs/proc/cmdline.c: patch does not apply
>
> Hm, isn't the whole point of --recount that it ignores the line numbers?
> Or does it just ignore the numbers after the commas (the counts)?
>
I don't know exactly. As I continue digging into the test that sent me
down this path, I just found that `git apply --recount` doesn't like
some output generated by `combinediff -q --combine` even with NO line
drift... then if I manually added in corresponding diff command lines
(to make it look more like a .patch file generated by `diff -Nu`), ie:
diff -Nu src.orig/fs/proc/array.c src/fs/proc/array.c <---
--- src.orig/fs/proc/array.c
+++ src/fs/proc/array.c
Suddenly `git apply --recount` is happy with the patch.
So I suspect that I started with git not liking the hunks generated by
combinediff and drove it to the rebase feature, which solves a more
interesting problem, but by side effect smoothed over this format
issue when it recreated the patch with git.
Anyway, I think this patch still stands on it's own: perform the same
apply/revert check as what would happen in the fixup steps to fail
faster for the user?
--
Joe