All of lore.kernel.org
 help / color / mirror / Atom feed
From: pheragu@codeaurora.org
To: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	apw@canonical.com, linux-kernel@vger.kernel.org,
	tsoni@codeaurora.org, bryanh@codeaurora.org,
	ckadabi@codeaurora.org, David Keitel <dkeitel@codeaurora.org>
Subject: Re: [PATCH] checkpatch: Require commit text and warn on long commit text lines
Date: Wed, 25 Jul 2018 11:49:39 -0700	[thread overview]
Message-ID: <387ec7f1d900b3de28f3bbf82d36bf8a@codeaurora.org> (raw)
In-Reply-To: <59a1b82fd854c9bf8a530bb053b718dc@codeaurora.org>

On 2018-07-16 11:20, pheragu@codeaurora.org wrote:
> On 2018-07-13 17:08, Joe Perches wrote:
>> On Fri, 2018-07-13 at 16:28 -0700, pheragu@codeaurora.org wrote:
>>> On 2018-07-13 14:46, Joe Perches wrote:
>>> > On Fri, 2018-07-13 at 14:40 -0700, Prakruthi Deepak Heragu wrote:
>>> > > Commit text is almost always necessary to explain why a change is
>>> > > needed.
>>> >
>>> > This bit seems sensible, but perhaps it should just count the
>>> > number of lines after the end of email headers and before any
>>> > Signed-off-by:/Signature line
>>> >
>>> 
>>> While committing the changes, one can just write the subject and not
>>> write
>>> the commit text at all. So, if we just count the lines between email
>>> headers
>>> and signed-off, we still do count lines which form the subject, but 
>>> the
>>> commit text is still absent. Also, subject can be longer than one 
>>> line.
>>> So,
>>> just counting lines doesn't really guarantee the presence of commit
>>> text.
>> 
>> Not true.
>> Look at $in_header_lines and $in_commit_log.
>> 
>>> > > Also, warn on commit text lines longer than 75 characters. The commit
>>> > > text
>>> > > are indented and may wrap on a terminal if they are longer than 75
>>> > > characters.
>>> >
>>> > This is already exists via
>>> >
>>> > # Check for line lengths > 75 in commit log, warn once
>>> > 		if ($in_commit_log && !$commit_log_long_line &&
>>> > 		    length($line) > 75 &&
>>> >
>>> 
>>> True, but this patch points out every line of the commit text that is
>>> exceeding the limit.
>> 
>> Which is bad because things like dump_stack() are added in
>> commit logs and those are already allowed to be > 75 chars.
>> 
>> Anyway, something like this probably works.  Please test.
>> ---
>>  scripts/checkpatch.pl | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>> 
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index b5c875d7132b..8b5f3dae31c9 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -2240,6 +2240,7 @@ sub process {
>>  	my $in_header_lines = $file ? 0 : 1;
>>  	my $in_commit_log = 0;		#Scanning lines before patch
>>  	my $has_commit_log = 0;		#Encountered lines before patch
>> +	my $commit_log_lines = 0;	#Number of commit log lines
>>  	my $commit_log_possible_stack_dump = 0;
>>  	my $commit_log_long_line = 0;
>>  	my $commit_log_has_diff = 0;
>> @@ -2497,6 +2498,18 @@ sub process {
>> 
>>  		$cnt_lines++ if ($realcnt != 0);
>> 
>> +# Verify the existence of a commit log if appropriate
>> +# 2 is used because a $signature is counted in $commit_log_lines
>> +		if ($in_commit_log) {
>> +			if ($line !~ /^\s*$/) {
>> +				$commit_log_lines++;	#could be a $signature
>> +			}
>> +		} else if ($has_commit_log && $commit_log_lines < 2) {
>> +			WARN("COMMIT_MESSAGE",
>> +			     "Missing commit description - Add an appropriate one\n");
>> +			$commit_log_lines = 2;	#warn only once
>> +		}
>> +
>>  # Check if the commit log has what seems like a diff which can 
>> confuse patch
>>  		if ($in_commit_log && !$commit_log_has_diff &&
>>  		    (($line =~ m@^\s+diff\b.*a/[\w/]+@ &&
> I checked all the cases that I mentioned before. The change you 
> suggested works
> for every case. Would you take care of merging this fix?
Any updates on this patch? Would you take care of merging this fix?

  reply	other threads:[~2018-07-25 18:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 21:40 [PATCH] checkpatch: Require commit text and warn on long commit text lines Prakruthi Deepak Heragu
2018-07-13 21:46 ` Joe Perches
2018-07-13 23:28   ` pheragu
2018-07-14  0:08     ` Joe Perches
2018-07-16 18:20       ` pheragu
2018-07-25 18:49         ` pheragu [this message]
2018-07-26  2:22     ` [PATCH] checkpatch: Warn when a patch doesn't have a description Joe Perches
2018-07-26 10:08       ` Greg KH
2018-07-26 22:08       ` Andrew Morton
2018-07-27  1:26         ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=387ec7f1d900b3de28f3bbf82d36bf8a@codeaurora.org \
    --to=pheragu@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=bryanh@codeaurora.org \
    --cc=ckadabi@codeaurora.org \
    --cc=dkeitel@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tsoni@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.