checkpatch: warn when patch version changelog is in wrong place
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 <[email protected]>
Signed-off-by Ignacio Peña <[email protected]>
--- scripts/checkpatch.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +14 -0
@@ -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) {
Signature · 1 line
2.39.5 (Apple Git-154)