[PATCH v2 2/2] checkpatch: enforce 12-char SHA for Fixes tags
From: Ignacio Peña
Date: Tue Jul 22 2025 - 23:03:18 EST
The kernel documentation recommends 12 character SHA-1 hashes
for Fixes tags. The current code allows 12-40 characters but
we should enforce exactly 12 for consistency.
The regex is changed from {12,40} to {12} and the warning
message updated accordingly.
Link: https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
Suggested-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Ignacio Peña <ignacio.pena87@xxxxxxxxx>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6953ad515..ea7b6c69e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3242,7 +3242,7 @@ sub process {
my $tag_case = not ($tag eq "Fixes:");
my $tag_space = not ($line =~ /^fixes:? [0-9a-f]{5,40} ($balanced_parens)/i);
- my $id_length = not ($orig_commit =~ /^[0-9a-f]{12,40}$/i);
+ my $id_length = not ($orig_commit =~ /^[0-9a-f]{12}$/i);
my $id_case = not ($orig_commit !~ /[A-F]/);
my $id = "0123456789ab";
@@ -3252,7 +3252,7 @@ sub process {
if (defined($cid) && ($ctitle ne $title || $tag_case || $tag_space || $id_length || $id_case || !$title_has_quotes)) {
my $fixed = "Fixes: $cid (\"$ctitle\")";
if (WARN("BAD_FIXES_TAG",
- "Please use correct Fixes: style 'Fixes: <12+ chars of sha1> (\"<title line>\")' - ie: '$fixed'\n" . $herecurr) &&
+ "Please use correct Fixes: style 'Fixes: <exactly 12 chars of sha1> (\"<title line>\")' - ie: '$fixed'\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] = $fixed;
}
--
2.50.1