[Linux-kernel-mentees] [PATCH RFC] checkpatch: add warning for lines starting with a '#' in commit log

Dwaipayan Ray dwaipayanray1 at gmail.com
Tue Dec 1 15:52:12 UTC 2020


Commit log lines starting with a '#' can be ignored by git if the
corresponding commit message is reworded by a maintainer using
git commit --ammend. This minute error can be easily avoided if
checkpatch warns for the same.

Add a new check which emits a warning on finding lines starting with
a '#'. Also add a quick fix by adding a tab infront of such lines.

Suggested-by: Peilin Ye <yepeilin.cs at gmail.com>
Signed-off-by: Dwaipayan Ray <dwaipayanray1 at gmail.com>
---
 scripts/checkpatch.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dabe39ca819e..10665b9a3d77 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2966,6 +2966,15 @@ sub process {
 			$commit_log_possible_stack_dump = 0;
 		}
 
+# Check for lines starting with an #
+		if ($in_commit_log && $line =~ /^#/) {
+			if (WARN("POSSIBLE_IGNORED_LINE",
+				 "Commit log lines starting with a '#' might be ignored if the commit message is reworded using git commit --ammend.\n" . $herecurr)
+			    && $fix) {
+				$fixed[$fixlinenr] =~ s/^#/\t#/;
+			}
+		}
+
 # Check for git id commit length and improperly formed commit descriptions
 		if ($in_commit_log && !$commit_log_possible_stack_dump &&
 		    $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
-- 
2.27.0



More information about the Linux-kernel-mentees mailing list