[PATCH] checkpatch: Add an invalid patch separator test

From: Joe Perches

Date: Fri Jan 16 2026 - 12:43:04 EST


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.

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
Documentation/dev-tools/checkpatch.rst | 5 +++++
scripts/checkpatch.pl | 10 ++++++++++
2 files changed, 15 insertions(+)

diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
index ca475805df4c8..dccede68698ca 100644
--- a/Documentation/dev-tools/checkpatch.rst
+++ b/Documentation/dev-tools/checkpatch.rst
@@ -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
----------------
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e0f1d6a6bc636..a11f88d11edd8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3035,6 +3035,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;