]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
checkpatch: add an invalid patch separator test
authorJoe Perches <joe@perches.com>
Fri, 16 Jan 2026 17:42:52 +0000 (09:42 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 1 Feb 2026 00:16:03 +0000 (16:16 -0800)
Some versions of tools that apply patches incorrectly allow lines that
start with 3 dashes and have additional content on the same line.

Checkpatch will now emit an ERROR on these lines and optionally convert
those lines from dashes to equals with --fix.

Link: https://lkml.kernel.org/r/6ec1ed08328340db42655287afd5fa4067316b11.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Ian Rogers <irogers@google.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Namhyung kim <namhyung@kernel.org>
Cc: Stehen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/dev-tools/checkpatch.rst
scripts/checkpatch.pl

index deb3f67a633cfc59c15cd859f8ceaa7934720d78..baf0b42ebba9e0c585e8724adbe24e4614de9611 100644 (file)
@@ -601,6 +601,11 @@ Commit message
 
     See: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
 
+  **BAD_COMMIT_SEPARATOR**
+    The commit separator is a single line with 3 dashes.
+    The regex match is '^---$'
+    Lines that start with 3 dashes and have more content on the same line
+    may confuse tools that apply patches.
 
 Comparison style
 ----------------
index c0250244cf7a3cb5e289b04fa4a9f644692dc278..3932f07e6adac3887c996fc70bd9a82a22f6ad32 100755 (executable)
@@ -3031,6 +3031,16 @@ sub process {
                        }
                }
 
+# Check for invalid patch separator
+               if ($in_commit_log &&
+                   $line =~ /^---.+/) {
+                       if (ERROR("BAD_COMMIT_SEPARATOR",
+                                 "Invalid commit separator - some tools may have problems applying this\n" . $herecurr) &&
+                           $fix) {
+                               $fixed[$fixlinenr] =~ s/-/=/g;
+                       }
+               }
+
 # Check for patch separator
                if ($line =~ /^---$/) {
                        $has_patch_separator = 1;