[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251205053457.8556-1-irogers@google.com>
Date: Thu, 4 Dec 2025 21:34:57 -0800
From: Ian Rogers <irogers@...gle.com>
To: Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>,
Dwaipayan Ray <dwaipayanray1@...il.com>, Lukas Bulwahn <lukas.bulwahn@...il.com>,
linux-kernel@...r.kernel.org
Cc: Namhyung Kim <namhyung@...nel.org>, Stephen Rothwell <sfr@...b.auug.org.au>,
Ian Rogers <irogers@...gle.com>
Subject: [PATCH v1] checkpatch: Warn about sign offs if there's an accidental
patch separator
The regex ^---$ to detect a patch separator, means a patch is
considerd to have been separated only when the line is exactly just
"---". git-mailinfo (and thus git am) treats any line starting with
"---" as the start of a patch. This can mean a comment causes
git-mailinfo to truncate the commit message if the line in the comment
starts with "---". checkpatch won't warn about things like missing
sign offs after the "---" started comment as it doesn't see the patch
as having started yet. The recording of sign offs is made to ignore
the case it is in a patch. This issue caused missing tags in commit
6528cdd61590 ("perf tests stat: Add test for error for an offline CPU")
as reported by Stephen Rothwell <sfr@...b.auug.org.au> in:
https://lore.kernel.org/lkml/20251205092428.3e2b94e3@canb.auug.org.au/
Before:
$ ./scripts/checkpatch.pl v2-0006-perf-tests-stat-Add-test-for-error-for-an-offline.patch
total: 0 errors, 0 warnings, 39 lines checked
v2-0006-perf-tests-stat-Add-test-for-error-for-an-offline.patch has no obvious style problems and is ready for submission.
After:
$ ./scripts/checkpatch.pl v2-0006-perf-tests-stat-Add-test-for-error-for-an-offline.patch
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 39 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
v2-0006-perf-tests-stat-Add-test-for-error-for-an-offline.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
scripts/checkpatch.pl | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 92669904eecc..4fb04162ee56 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2819,6 +2819,11 @@ sub process {
$is_patch = 1;
}
+# Once the patch separator is encountered git-mailinfo will treat the rest as a patch
+ if ($has_patch_separator) {
+ $is_patch = 1;
+ }
+
#extract the line range in the file after the patch is applied
if (!$in_commit_log &&
$line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
@@ -2989,7 +2994,7 @@ sub process {
}
# Check the patch for a signoff:
- if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
+ if (!$is_patch && $line =~ /^\s*signed-off-by:\s*(.*)/i) {
$signoff++;
$in_commit_log = 0;
if ($author ne '' && $authorsignoff != 1) {
@@ -3028,7 +3033,7 @@ sub process {
}
# Check for patch separator
- if ($line =~ /^---$/) {
+ if ($line =~ /^---/) {
$has_patch_separator = 1;
$in_commit_log = 0;
}
--
2.52.0.223.gf5cc29aaa4-goog
Powered by blists - more mailing lists