[PATCH] checkpatch: handle sha1 of at least 12 hex digits

Yu-Chun Lin posted 1 patch 1 month, 3 weeks ago
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] checkpatch: handle sha1 of at least 12 hex digits
Posted by Yu-Chun Lin 1 month, 3 weeks ago
Modify the regular expression to set $id_length to 0 if the commit hash
is 12 characters or longer, which allows the script to properly handle
longer commit hashes.

Link: https://lore.kernel.org/lkml/20240921151642.60b89e86@canb.auug.org.au/
Suggested-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
---
 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 39032224d504..71900eaffa06 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3228,7 +3228,7 @@ sub process {
 				$tag_case = 0 if $tag eq "Fixes:";
 				$tag_space = 0 if ($line =~ /^fixes:? [0-9a-f]{5,} ($balanced_parens)/i);
 
-				$id_length = 0 if ($orig_commit =~ /^[0-9a-f]{12}$/i);
+				$id_length = 0 if ($orig_commit =~ /^[0-9a-f]{12,}$/i);
 				$id_case = 0 if ($orig_commit !~ /[A-F]/);
 
 				# Always strip leading/trailing parens then double quotes if existing
@@ -3245,7 +3245,7 @@ sub process {
 			if ($ctitle ne $title || $tag_case || $tag_space ||
 			    $id_length || $id_case || !$title_has_quotes) {
 				if (WARN("BAD_FIXES_TAG",
-				     "Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) &&
+				     "Please use correct Fixes: style 'Fixes: <12+ chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) &&
 				    $fix) {
 					$fixed[$fixlinenr] = "Fixes: $cid (\"$ctitle\")";
 				}
-- 
2.43.0