Your message dated Sat, 1 Mar 2025 14:51:11 +0100
with message-id <[email protected]>
and subject line Re: Bug#1099170: dpkg-source: Source/Patch: fix parsing of 
patch header
has caused the Debian Bug report #1099170,
regarding dpkg-source: Source/Patch: fix parsing of patch header
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1099170: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1099170
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: dpkg-dev
Version: 1.21.22
Severity: normal
File: /usr/bin/dpkg-source
Tags: patch
X-Debbugs-Cc: [email protected]

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!):

> From a0579f75fb5aa6926f4acfdee3fa91f2666df559 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= <[email protected]>
> Date: Tue, 24 Dec 2024 15:00:39 -0500
> Subject: [PATCH 2079/3849] radeonsi: fix a TCS regression
>
> This change caused the regression:
> @@ -853,7 +853,7 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, 
> struct ac_llvm_compiler *
...
>
> Reviewed-by: Qiang Yu <[email protected]>
> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32780>
> ---
>  src/gallium/drivers/radeonsi/si_shader_llvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c 
> b/src/gallium/drivers/radeonsi/si_shader_llvm.c
> index 620953e817f..bd0309744de 100644
> --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
> +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
> @@ -840,12 +840,12 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, 
> struct ac_llvm_compiler *
>        struct si_shader prev_shader = {};

My patch revises the parsing logic to treat the three hunk markers as ordered 
and
linked.
>From f6cbe0c3e240e66e8ad71a4003068b7b1fdf413a Mon Sep 17 00:00:00 2001
From: Tj <[email protected]>
Date: Sat, 1 Mar 2025 07:27:23 +0000
Subject: [PATCH] Source/Patch: fix parsing of patch header

analyze() failed 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!):

> From a0579f75fb5aa6926f4acfdee3fa91f2666df559 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= <[email protected]>
> Date: Tue, 24 Dec 2024 15:00:39 -0500
> Subject: [PATCH 2079/3849] radeonsi: fix a TCS regression
>
> This change caused the regression:
> @@ -853,7 +853,7 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, 
> struct ac_llvm_compiler *
...
>
> Reviewed-by: Qiang Yu <[email protected]>
> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32780>
> ---
>  src/gallium/drivers/radeonsi/si_shader_llvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c 
> b/src/gallium/drivers/radeonsi/si_shader_llvm.c
> index 620953e817f..bd0309744de 100644
> --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
> +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
> @@ -840,12 +840,12 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, 
> struct ac_llvm_compiler *
>        struct si_shader prev_shader = {};

Revise the parsing logic to treat the three hunk markers as ordered and
linked.

Signed-off-by: Tj <[email protected]>
---
 scripts/Dpkg/Source/Patch.pm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index 57468fc4e..e9d59a3e9 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -422,6 +422,9 @@ sub analyze {
     my @patchorder;
     my $patch_header = '';
     my $diff_count = 0;
+    my @patchprefix = ( '^--- ', '^\+\+\+ ', '^@@ -' );
+    my $prefixindex = 0;
+    my $offset;
 
     my $line = _getline($self);
 
@@ -433,11 +436,22 @@ sub analyze {
        # look for an Index: pseudo-header in the comments, because we would
        # not use it anyway, as we require both ---/+++ filename headers.
        while (1) {
-           if ($line =~ /^(?:--- |\+\+\+ |@@ -)/) {
+           if ($line =~ $patchprefix[$prefixindex]) {
+               $prefixindex++;
+           } else {
+               $prefixindex = 0;
+           }
+           if ($prefixindex == 3) {
+               $prefixindex = 0;
+               seek($self, $offset, 0);
+               $line = _getline($self);
                last;
            } else {
                $patch_header .= "$line\n";
            }
+           if ($prefixindex == 0) {
+               $offset = tell($self);
+           }
            $line = _getline($self);
            last HUNK if not defined $line;
        }
-- 
2.39.5


--- End Message ---
--- Begin Message ---
Hi!

On Sat, 2025-03-01 at 07:45:22 +0000, Tj wrote:
Package: dpkg-dev
Version: 1.21.22
Severity: normal
File: /usr/bin/dpkg-source
Tags: patch
X-Debbugs-Cc: [email protected]

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!):

From a0579f75fb5aa6926f4acfdee3fa91f2666df559 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= <[email protected]>
Date: Tue, 24 Dec 2024 15:00:39 -0500
Subject: [PATCH 2079/3849] radeonsi: fix a TCS regression

This change caused the regression:
@@ -853,7 +853,7 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, 
struct ac_llvm_compiler *
...

Reviewed-by: Qiang Yu <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32780>
---
 src/gallium/drivers/radeonsi/si_shader_llvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c 
b/src/gallium/drivers/radeonsi/si_shader_llvm.c
index 620953e817f..bd0309744de 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
@@ -840,12 +840,12 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, 
struct ac_llvm_compiler *
       struct si_shader prev_shader = {};

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

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

--- End Message ---

Reply via email to