Skip to contentSkip to conversation

checkpatch: add checks for fixes tags

PATCH In review Wen Yang 2 participants 2 messages Oct 17, 2019 Checkpatch

lore
Share & tools
lore

Wen Yang

author
#0 lore raw

PATCH 1/1 checkpatch: add checks for fixes tags

SHA1 should be at least 12 digits long, as suggested by Stephen:
Https://lkml.org/lkml/2019/9/10/626 Https://lkml.org/lkml/2019/7/10/304

And the fixes tag should also be capitalized (Fixes:), as suggested by David:
Https://lkml.org/lkml/2019/10/1/1067

Add checks to the above issues.

Cc Andy Whitcroft <[email protected]> (maintainer:CHECKPATCH)
Cc Joe Perches <[email protected]> (maintainer:CHECKPATCH)
Cc Stephen Rothwell <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc [email protected] (open list)
---
 scripts/checkpatch.pl | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +20 -1
index a85d719df1f4..daefd0c546ff 100755
@@ -2925,7 +2925,7 @@ sub process {
 		}
 
 # check for invalid commit id
-		if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
+		if ($in_commit_log && $line =~ /(\bcommit)\s+([0-9a-f]{6,40})\b/i) {
 			my $id;
 			my $description;
 			($id, $description) = git_commit_info($2, undef, undef);
@@ -2935,6 +2935,25 @@ sub process {
 			}
 		}
 
+# check for invalid fixes tag
+		if ($in_commit_log && $line =~ /(^fixes:)\s+([0-9a-f]{6,40})\b/i) {
+			my $id;
+			my $description;
+			($id, $description) = git_commit_info($2, undef, undef);
+			if (!defined($id)) {
+				WARN("UNKNOWN_COMMIT_ID",
+				     "Unknown commit id '$2', maybe rebased or not pulled?\n" . $herecurr);
+			}
+			if ($1 ne "Fixes:") {
+				WARN("FIXES_TAG_STYLE",
+				     "The fixes tag should be capitalized (Fixes:).\n" . $hereprev);
+			}
+			if (length($2) < 12) {
+				WARN("FIXES_TAG_STYLE",
+				     "SHA1 should be at least 12 digits long.\n" . $hereprev);
+			}
+		}
+
 # ignore non-hunk lines and lines being removed
 		next if (!$hunk_line || $line =~ /^-/);
 
Signature · 1 line
2.23.0
#1 lore raw

Hi Wen,

Quoted 5 lines · On Thu, 17 Oct 2019 20:37:01 +0800 Wen Yang <[email protected]> wrote:

SHA1 should be at least 12 digits long, as suggested by Stephen:
Https://lkml.org/lkml/2019/9/10/626 Https://lkml.org/lkml/2019/7/10/304

This should apply to any reference to a commit.

Signature · 2 lines
Cheers,
Stephen Rothwell