[PATCH] checkpatch: Add an invalid patch separator test

Joe Perches posted 1 patch 3 weeks, 1 day ago
Documentation/dev-tools/checkpatch.rst |  5 +++++
scripts/checkpatch.pl                  | 10 ++++++++++
2 files changed, 15 insertions(+)
[PATCH] checkpatch: Add an invalid patch separator test
Posted by Joe Perches 3 weeks, 1 day ago
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@perches.com>
---
 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;
Re: [PATCH] checkpatch: Add an invalid patch separator test
Posted by Andrew Morton 3 weeks ago
On Fri, 16 Jan 2026 09:42:52 -0800 Joe Perches <joe@perches.com> wrote:

> 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.
> 

lgtm, thanks.  I think Suggested-by:Ian is appropriate.