linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] checkpatch: add warning for lines starting with a '#' in commit log
@ 2020-12-02 20:22 Dwaipayan Ray
  2020-12-02 20:36 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Dwaipayan Ray @ 2020-12-02 20:22 UTC (permalink / raw)
  To: joe
  Cc: linux-kernel-mentees, dwaipayanray1, linux-kernel, lukas.bulwahn,
	Peilin Ye

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.

Suggested-by: Peilin Ye <yepeilin.cs@gmail.com>
Tested-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
Changes in v2:
- Modify warning message and type
- Style fixes

 scripts/checkpatch.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e8c1ed0b1fad..eb8b13cf3f40 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 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 &&
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] checkpatch: add warning for lines starting with a '#' in commit log
  2020-12-02 20:22 [PATCH v2] checkpatch: add warning for lines starting with a '#' in commit log Dwaipayan Ray
@ 2020-12-02 20:36 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2020-12-02 20:36 UTC (permalink / raw)
  To: Dwaipayan Ray
  Cc: linux-kernel-mentees, linux-kernel, lukas.bulwahn, Peilin Ye

On Thu, 2020-12-03 at 01:52 +0530, Dwaipayan Ray wrote:
> 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

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

> +			    $fix) {
> +				$fixed[$fixlinenr] =~ s/^#/\t#/;

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

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-02 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 20:22 [PATCH v2] checkpatch: add warning for lines starting with a '#' in commit log Dwaipayan Ray
2020-12-02 20:36 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).