#1081436 git-buildpackage: should escape indented diffs somehow

#1081436#5
Date:
2024-09-11 15:50:20 UTC
From:
To:
gtk+3.0_3.24.43-3 contains a patch in the `git format-patch` dialect of
DEP-3 format, whose long description contains a diff illustrating how
to test the change (patch attached for reference).

The author of this patch clearly meant for the machine-readable part
of the patch to apply changes to gtk/gtkmessagedialog.c only.
`git apply` and `git am` have this behaviour, therefore so does `gbp pq`.

However, patch(1) and therefore dpkg-source looks for anything in the
patch text that looks vaguely diff-like, even if it's indented (!), and
applies it. The result is that in the uploaded gtk+3.0_3.24.43-3 package,
both gtk/gtkmessagedialog.c and demos/gtk-demo/dialog.c have been edited
(reported as #1081179).

I could even imagine this becoming a security issue, if the long
description of a patch contains instructions for changes to be made
during testing that are not suitable for production (for example if the
long description describes how to stub out authentication in order to
test something).

I've reported a separate dpkg-source bug asking for it to refuse to apply
the indented part of diffs like the attached.

To address this interop issue from both sides, I think that when
`gbp-pq export` serializes patches into debian/patches to become input
to dpkg-source, it should try to identify parts of the long commit
message that patch(1) would consider to be the beginning of a diff (I
think this means lines matching regexes r'^\s+-{3}' and r'^\s+[+]{3}',
or something like that?) and escape them somehow, perhaps by prepending
"#", ">" or ".".

Thanks,
    smcv

#1081436#10
Date:
2024-10-09 18:04:22 UTC
From:
To:
Hi,

Ouch. That's unexpected.

That make sense to me. A patch would be welcome.
Cheers,
 -- Guido
`

#1081436#15
Date:
2026-01-10 10:10:54 UTC
From:
To:
Es gibt eine Familienspende in Höhe von 1.850.000,00 USD von Cheng Charlie
Saephan. Bitte antworten Sie für weitere Informationen. Denken Sie daran,
Ihrer Familie und den Bedürftigen in Ihrer Umgebung Gutes zu tun.

Dies ist bereits der zweite Versuch, Sie zu erreichen. Bitte antworten Sie
für weitere Details.