[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250718035113.49455-1-ignacio.pena87@gmail.com>
Date: Thu, 17 Jul 2025 23:51:13 -0400
From: Ignacio Peña <ignacio.pena87@...il.com>
To: Andy Whitcroft <apw@...onical.com>,
Joe Perches <joe@...ches.com>,
Dwaipayan Ray <dwaipayanray1@...il.com>,
Lukas Bulwahn <lukas.bulwahn@...il.com>
Cc: linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ignacio Peña <ignacio.pena87@...il.com>
Subject: [PATCH 2/2] checkpatch: warn when patch version changelog is in wrong place
Add a check to warn when a patch version changelog (e.g., "v2: Fixed
review comments") appears in the commit message instead of after the
--- separator.
The kernel documentation and maintainer preferences indicate that
patch version changelogs should be placed after the --- separator
so they don't become part of the permanent git history.
This check warns on patterns like:
- "v2: description of changes"
- "changes in v2:"
- "changes since v2:"
The check only triggers for patches labeled v2 or higher in the
Subject line.
Example output:
WARNING: Version changelog should be after the --- separator, not in commit message
v2: Fixed review comments from maintainer
Suggested-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Ignacio Peña <ignacio.pena87@...il.com>
---
scripts/checkpatch.pl | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 664f7b7a6..af8a05f3e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2669,6 +2669,7 @@ sub process {
my $commit_log_has_diff = 0;
my $reported_maintainer_file = 0;
my $non_utf8_charset = 0;
+ my $patch_version = 0; #Patch version from Subject line
my $last_git_commit_id_linenr = -1;
@@ -3265,6 +3266,11 @@ sub process {
"A patch subject line should describe the change not the tool that found it\n" . $herecurr);
}
+# Check patch version from Subject line
+ if ($line =~ /^Subject:\s*\[PATCH\s+v(\d+)(?:\s+\d+\/\d+)?\]/i) {
+ $patch_version = $1;
+ }
+
# Check for Gerrit Change-Ids not in any patch context
if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
if (ERROR("GERRIT_CHANGE_ID",
@@ -3485,6 +3491,14 @@ sub process {
"8-bit UTF-8 used in possible commit log\n" . $herecurr);
}
+# Warn if version changelog is in commit message instead of after ---
+ if ($in_commit_log && $patch_version > 1 && !$has_patch_separator &&
+ ($line =~ /^\s*v\d+\s*:/ ||
+ $line =~ /^\s*changes\s+(?:in|since)\s+v\d+/i)) {
+ WARN("VERSION_CHANGELOG_PLACEMENT",
+ "Version changelog should be after the --- separator, not in commit message\n" . $herecurr);
+ }
+
# Check for absolute kernel paths in commit message
if ($tree && $in_commit_log) {
while ($line =~ m{(?:^|\s)(/\S*)}g) {
--
2.39.5 (Apple Git-154)
Powered by blists - more mailing lists