Skip to contentSkip to conversation

checkpatch: add warning for lines starting with a '#' in commit log

PATCH Superseded Dwaipayan Ray 2 participants 2 messages Dec 2, 2020 Checkpatch

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: add warning for lines starting with a '#' in commit log

Commit log lines starting with a '#' can be dropped by git if the corresponding commit message is reworded by a maintainer. This minor 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 in front of such lines.

---
Changes in v2:
- Modify warning message and type
- Style fixes

 scripts/checkpatch.pl | 9 +++++++++
 1 file changed, 9 insertions(+)
scripts/checkpatch.pl +9 -0
index e8c1ed0b1fad..eb8b13cf3f40 100755
@@ -2966,6 +2966,15 @@ sub process {
 			$commit_log_possible_stack_dump = 0;
 		}
 
+# Check for lines starting with a #
+		if ($in_commit_log && $line =~ /^#/) {
+			if (WARN("COMMIT_COMMENT_SYMBOL",
+				 "Commit log lines starting with a '#' will be dropped by git as a comment\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 &&
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
maintainer
#1 lore raw
Quoted 4 lines · Dwaipayan Ray

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

This makes no sense to me.

How about:

Commit log lines starting with # are dropped by git as comments so emit a warning for these comment lines.

Add a --fix option to insert a space before leading # comments

scripts/checkpatch.pl sub process { · line 2972

Quoted 4 lines
scripts/checkpatch.pl +4 -0
+# Check for lines starting with a #
+		if ($in_commit_log && $line =~ /^#/) {
+			if (WARN("COMMIT_COMMENT_SYMBOL",
+				 "Commit log lines starting with a '#' will be dropped by git as a comment\n" . $herecurr) &&

Perhaps:

				 "Commit log lines starting with '#' are dropped by git as comments\n" . $herecurr) &&

scripts/checkpatch.pl sub process { · line 2974

Quoted 2 lines
scripts/checkpatch.pl +2 -0
+			    $fix) {
+				$fixed[$fixlinenr] =~ s/^#/\t#/;

I suggest using a space char and not a tab to avoid excess indentation.

				$fixed[$fixlinenr] =~ s/^/ /;

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees