Re: [PATCH v2] checkpatch: add warning for lines starting with a '#' in commit log

From: Joe Perches
Date: Wed Dec 02 2020 - 15:37:57 EST


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/^/ /;