Skip to contentSkip to conversation

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

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

lore
Share & tools
lore
#0 lore raw

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

Commit log lines starting with '#' are dropped by git as comments. Add a check to emit a warning for these lines.

Also add a --fix option to insert a space before the leading '#' in such lines.

---
Changes in v3:
- Modify commit message for more clarity
- Modify warning message
- Modify --fix option to substitute single space instead of tab

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..7940889877ba 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 '#' are dropped by git as comments\n" . $herecurr) &&
+			    $fix) {
+				$fixed[$fixlinenr] =~ s/^/ /;
+			}
+		}
+
 # 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 Acked-by on v3 1/1
#1 lore raw
Quoted 10 lines · Dwaipayan Ray

Commit log lines starting with '#' are dropped by git as comments. Add a check to emit a warning for these lines.

Also add a --fix option to insert a space before the leading '#' in such lines.

Quoted 31 lines

---
Changes in v3:
- Modify commit message for more clarity
- Modify warning message
- Modify --fix option to substitute single space instead of tab

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

 scripts/checkpatch.pl | 9 +++++++++

 1 file changed, 9 insertions(+)
scripts/checkpatch.pl +0 -0
index e8c1ed0b1fad..7940889877ba 100755
@@ -2966,6 +2966,15 @@ sub process {
  			$commit_log_possible_stack_dump = 0;
  		}

scripts/checkpatch.pl +9 -0
+# Check for lines starting with a #
+		if ($in_commit_log && $line =~ /^#/) {
+			if (WARN("COMMIT_COMMENT_SYMBOL",
+				 "Commit log lines starting with '#' are dropped by git as comments\n" . $herecurr) &&
+			    $fix) {
+				$fixed[$fixlinenr] =~ s/^/ /;
+			}
+		}
+
Quoted 3 lines

 # 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 &&

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