linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ignacio Peña" <ignacio.pena87@gmail.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
	Dwaipayan Ray <dwaipayanray1@gmail.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Ignacio Peña" <ignacio.pena87@gmail.com>
Subject: [PATCH 2/2] checkpatch: warn when patch version changelog is in wrong place
Date: Thu, 17 Jul 2025 23:51:13 -0400	[thread overview]
Message-ID: <20250718035113.49455-1-ignacio.pena87@gmail.com> (raw)

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@linuxfoundation.org>
Signed-off-by: Ignacio Peña <ignacio.pena87@gmail.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)


                 reply	other threads:[~2025-07-18  3:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250718035113.49455-1-ignacio.pena87@gmail.com \
    --to=ignacio.pena87@gmail.com \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).