[PATCH] checkpatch: improve signature check on empty description

Scott Branden posted 1 patch 3 years ago
scripts/checkpatch.pl | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
[PATCH] checkpatch: improve signature check on empty description
Posted by Scott Branden 3 years ago
Existing check assumed there could be a single Signed-off-by line which
should be ignored when checking for an empty commit message.
Other lines with identifiers "Reported-by:", "Acked-by:", or anything
invented by the person who constructed the commit were counted as a
body of the commit message.

Improve the check for an empty body of the commit message by not counting
any lines that begin with a $signature or similar formatted line of a
keyword followed by a colon.

Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
 scripts/checkpatch.pl | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bd44d12965c9..5922a6df7f5d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2901,15 +2901,14 @@ sub process {
 		$cnt_lines++ if ($realcnt != 0);
 
 # Verify the existence of a commit log if appropriate
-# 2 is used because a $signature is counted in $commit_log_lines
 		if ($in_commit_log) {
-			if ($line !~ /^\s*$/) {
-				$commit_log_lines++;	#could be a $signature
+			if ($line !~ /^\s*($|[a-zA-Z0-9_-]+:)/) {
+				$commit_log_lines++;
 			}
-		} elsif ($has_commit_log && $commit_log_lines < 2) {
+		} elsif ($has_commit_log && $commit_log_lines < 1) {
 			WARN("COMMIT_MESSAGE",
 			     "Missing commit description - Add an appropriate one\n");
-			$commit_log_lines = 2;	#warn only once
+			$commit_log_lines = 1;	#warn only once
 		}
 
 # Check if the commit log has what seems like a diff which can confuse patch
-- 
2.40.0