#1099170 dpkg-source: Source/Patch: fix parsing of patch header

#1099170#5
Date:
2025-03-01 07:45:22 UTC
From:
To:
analyze() fails to correctly parse a patch header that has a line that
matches two of the three hunk detection regular expressions because it
treats them in isolation rather than as a linked, ordered, series.

josch in IRC's #debian-mentors reported this error:

dpkg-source: error: expected ^--- in line 7 of diff 'mesa-24.3.4.orig.JVu23i/debian/patches/mesa25/2079-radeonsi-fix-a-TCS-regression.patch'

The cause being the isolated "@@ -" in the patch header that was directly
taken from git-format-patch (here prefixed with "> " to avoid causing
the same error!):
...

My patch revises the parsing logic to treat the three hunk markers as ordered and
linked.

#1099170#10
Date:
2025-03-01 13:51:11 UTC
From:
To:
Hi!

Thanks for looking into it, and the patch! Although as I mentioned to
josch on IRC, this is #1081434, where accepting such change would not
be correct. I'm thus going to close this as a duplicate. If there's
anything new not covered in that other report, then please update that
one instead.

Thanks,
Guillem

#1099170#15
Date:
2025-03-02 08:55:41 UTC
From:
To:
Revised patch that fixes an issue where $patchheader incorrectly
included the hunk preamble.

#1099170#20
Date:
2025-03-02 08:57:46 UTC
From:
To:
The (forgotten) revised patch!
#1099170#25
Date:
2025-03-02 09:33:20 UTC
From:
To:
Apologies that the previous attached patch did NOT include the changes I
described. This one definitely does include dealing with partial hunk
preambles correctly.

#1099170#30
Date:
2025-03-10 03:09:11 UTC
From:
To:
Hi!

Ah, right (thanks for the private reply with the reasoning, although
in general it would be better to send those to the bug directly! :), I
see I was probably too quick to put this and the bug I referred in the
same category, but they are indeed slightly different.

I'm reopening for now to avoid it being archived, but I've still got
some concerns that are similar to the ones affecting the other related
bug, so in the end I think both might end up being unfixable for now.

I'll ponder about this a bit, then give a reasoned reply later on.

Thanks,
Guillem