]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
scripts/checkpatch.pl: remove bogus patch prefix warning
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Thu, 30 Oct 2025 20:13:19 +0000 (23:13 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 4 Nov 2025 12:21:50 +0000 (13:21 +0100)
Remove the 'patch prefix exists, appears to be a -p0 patch' warning
entirely as it is fundamentally flawed and can only produce false
positives.

Sometimes I create test files with names 'a' and 'b', and then get
surprised seeing this warning. It was not easy to understand where it
comes from.

How it works:
1. It extracts prefixes (a/, b/) from standard diff output
2. Checks if files/directories with these names exist in the project
   root
3. Warns if they exist, claiming it's a '-p0 patch' issue

This logic is wrong because:
- Standard diff/patch tools always use a/ and b/ prefixes by default
- The existence of files named 'a' or 'b' in the working directory is
  completely unrelated to patch format
- The working directory state may not correspond to the patch content
  (different commits, branches, etc.)
- In QEMU project, there are no single-letter files/directories in root,
  so this check can only generate false positives

The correct way to detect -p0 patches would be to analyze the path
format within the patch itself (e.g., absolute paths or paths without
prefixes), not check filesystem state.

So, let's finally drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Link: https://lore.kernel.org/r/20251030201319.858480-1-vsementsov@yandex-team.ru
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scripts/checkpatch.pl

index d3d75f3f139826fafeae1c314e961284ac18f448..d0f4537f25e24844a5e3d7dcf90f0955eff63db0 100755 (executable)
@@ -1741,13 +1741,7 @@ sub process {
                        }
                } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
                        $realfile = $1;
-                       $realfile =~ s@^([^/]*)/@@ if (!$file);
-
-                       $p1_prefix = $1;
-                       if (!$file && $tree && $p1_prefix ne '' &&
-                           -e "$root/$p1_prefix") {
-                               WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
-                       }
+                       $realfile =~ s@^[^/]*/@@  if (!$file);
 
                        if (defined $fileinfo && !$fileinfo->{isgit}) {
                                $fileinfo->{lineend} = $oldhere;