public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2]
@ 2014-10-20 22:49 Prarit Bhargava
  2014-10-20 23:11 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Prarit Bhargava @ 2014-10-20 22:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Prarit Bhargava, Andy Whitcroft, Joe Perches

I tested this using both lower and upper case 'c' with the following commit
text:

Derp, derpy derp.   Derps derpy derpy derp derp derp derp.
Some other text besides derp.
Stuff.

11 chars, SHOULD FAIL
commit 1234567890a

12 chars
commit 1234567890ab

13 chars
commit 1234567890abc

14 chars
commit 1234567890abcd

commit 1234567890f
("11 chars, separated into two lines SHOULD FAIL")

commit 1234567890af
("12 chars, separated into two lines")

commit 1234567890abf
("13 chars, separated into two lines")

commit 1234567890abcf
("14 chars, separated into two lines")

commit 1234567890f ("11 chars, one line SHOULD FAIL")

commit 1234567890af ("12 chars, one line")

commit 1234567890abf ("13 chars, one line")

commit 1234567890abcf ("14 chars, one line")

The output, as expected is 6 errors:

ERROR: Please use 12 or more chars for the git commit ID
commit 1234567890a

ERROR: Please use 12 or more chars for the git commit ID
commit 1234567890f

ERROR: Please format the git commit ID like: 'commit 01234567890ab ("commit description")'
commit 1234567890af

ERROR: Please format the git commit ID like: 'commit 01234567890ab ("commit description")'
commit 1234567890abf

ERROR: Please format the git commit ID like: 'commit 01234567890ab ("commit description")'
commit 1234567890abcf

ERROR: Please use 12 or more chars for the git commit ID
commit 1234567890f ("11 chars, one line SHOULD FAIL")

P.
----8<----

I put together a patch with an incorrect format and the following error
was returned by checkpatch.pl:

ERROR: Please use 12 or more chars for the git commit ID like: 'Commit
09ec54429c6d ("clocksource: Move cycle_last validation to core code")'
Commit 09ec54429c6d10f87d1f084de53ae2c1c3a81108, clocksource: Move

As can be seen by the output the commit ID length is accurate, and it is the
formatting that is generating an error.  The message is confusing and should
be separated into two warnings, one for the git commit ID length, and the other
for the format.

Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>

[v2]: Add separate messages for warnings instead of one global format
warning.
---
 scripts/checkpatch.pl |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 374abf4..f81d7a8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2160,21 +2160,25 @@ sub process {
 			      "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
 		}
 
-# Check for improperly formed commit descriptions
+# Check for git id commit length and improperly formed commit descriptions
 		if ($in_commit_log &&
-		    $line =~ /\bcommit\s+[0-9a-f]{5,}/i &&
-		    !($line =~ /\b[Cc]ommit [0-9a-f]{12,40} \("/ ||
-		      ($line =~ /\b[Cc]ommit [0-9a-f]{12,40}\s*$/ &&
-		       defined $rawlines[$linenr] &&
-		       $rawlines[$linenr] =~ /^\s*\("/))) {
-			$line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i;
+		    $line =~ /\b[Cc]ommit\s+[0-9a-f]{5,}/i &&
+		    !($line =~ /\b[Cc]ommit [0-9a-f]{12,40}/ )) {
+			ERROR("GIT_COMMIT_ID_12_CHARS",
+			      "Please use 12 or more chars for the git commit ID\n" . $herecurr);
+		} elsif ($in_commit_log &&
+			 $line =~ /\b[Cc]ommit [0-9a-f]{12,40}\s*$/ &&
+			 defined $rawlines[$linenr] &&
+			 $rawlines[$linenr] =~ /^\s*\("/) {
+			$line =~ /\b(c)ommit\s+([0-9a-f]{12,40})/i;
 			my $init_char = $1;
 			my $orig_commit = lc($2);
 			my $id = '01234567890ab';
 			my $desc = 'commit description';
-		        ($id, $desc) = git_commit_info($orig_commit, $id, $desc);
-			ERROR("GIT_COMMIT_ID",
-			      "Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr);
+			($id, $desc) = git_commit_info($orig_commit,
+						       $id, $desc);
+			ERROR("GIT_COMMIT_ID_DESCRIPTION",
+			      "Please format the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr);
 		}
 
 # Check for added, moved or deleted files
-- 
1.7.9.3


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

* Re: [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2]
  2014-10-20 22:49 [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2] Prarit Bhargava
@ 2014-10-20 23:11 ` Joe Perches
  2014-10-21  0:46   ` Prarit Bhargava
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2014-10-20 23:11 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-kernel, Andy Whitcroft

On Mon, 2014-10-20 at 18:49 -0400, Prarit Bhargava wrote:
> I tested this using both lower and upper case 'c' with the following commit
> text:
[]

I think the patch subject be something like:

"[PATCH] checkpatch: improve commit id/desc style checking in commit message"

The [v2] goes in the subject like this:

"[PATCH V2] checkpatch: ..."

> 11 chars, SHOULD FAIL
> commit 1234567890a

[]

> ERROR: Please use 12 or more chars for the git commit ID
> commit 1234567890a

I'd expect these messages to mention something about the
missing commit description too.



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

* Re: [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2]
  2014-10-20 23:11 ` Joe Perches
@ 2014-10-21  0:46   ` Prarit Bhargava
  2014-10-21  2:11     ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Prarit Bhargava @ 2014-10-21  0:46 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, Andy Whitcroft



On 10/20/2014 07:11 PM, Joe Perches wrote:
> On Mon, 2014-10-20 at 18:49 -0400, Prarit Bhargava wrote:
>> I tested this using both lower and upper case 'c' with the following commit
>> text:
> []
> 
> I think the patch subject be something like:
> 
> "[PATCH] checkpatch: improve commit id/desc style checking in commit message"
> 
> The [v2] goes in the subject like this:
> 
> "[PATCH V2] checkpatch: ..."
> 
>> 11 chars, SHOULD FAIL
>> commit 1234567890a
> 
> []
> 
>> ERROR: Please use 12 or more chars for the git commit ID
>> commit 1234567890a
> 
> I'd expect these messages to mention something about the
> missing commit description too.

Hmm ... is that a requirement here?  Currently checkpatch.pl doesn't complain
about that.  I can do it but I'd hate to find out that I'm ERRORing on something
that is considered okay to do.

P.

> 
> 

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

* Re: [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2]
  2014-10-21  0:46   ` Prarit Bhargava
@ 2014-10-21  2:11     ` Joe Perches
  2014-10-21 12:03       ` Prarit Bhargava
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2014-10-21  2:11 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-kernel, Andy Whitcroft

On Mon, 2014-10-20 at 20:46 -0400, Prarit Bhargava wrote:
> 
> On 10/20/2014 07:11 PM, Joe Perches wrote:
> > On Mon, 2014-10-20 at 18:49 -0400, Prarit Bhargava wrote:
> >> I tested this using both lower and upper case 'c' with the following commit
> >> text:
> > []
> > 
> > I think the patch subject be something like:
> > 
> > "[PATCH] checkpatch: improve commit id/desc style checking in commit message"
> > 
> > The [v2] goes in the subject like this:
> > 
> > "[PATCH V2] checkpatch: ..."
> > 
> >> 11 chars, SHOULD FAIL
> >> commit 1234567890a
> > 
> > []
> > 
> >> ERROR: Please use 12 or more chars for the git commit ID
> >> commit 1234567890a
> > 
> > I'd expect these messages to mention something about the
> > missing commit description too.
> 
> Hmm ... is that a requirement here?

Yes

> Currently checkpatch.pl doesn't complain about that.

Yes, it does

$ ./scripts/checkpatch.pl 0001-part-1.patch
ERROR: Please use 12 or more chars for the git commit ID like: 'commit 01234567890ab ("commit description")'
#9: 
commit 1234567, asdf

ERROR: Please use 12 or more chars for the git commit ID like: 'commit 01234567890ab ("commit description")'
#11: 
commit 123457

> I can do it but I'd hate to find out that I'm ERRORing on something
> that is considered okay to do.

It's not, you've changed output.



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

* Re: [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2]
  2014-10-21  2:11     ` Joe Perches
@ 2014-10-21 12:03       ` Prarit Bhargava
  0 siblings, 0 replies; 5+ messages in thread
From: Prarit Bhargava @ 2014-10-21 12:03 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, Andy Whitcroft



On 10/20/2014 10:11 PM, Joe Perches wrote:
> On Mon, 2014-10-20 at 20:46 -0400, Prarit Bhargava wrote:
>>
>> On 10/20/2014 07:11 PM, Joe Perches wrote:
>>> On Mon, 2014-10-20 at 18:49 -0400, Prarit Bhargava wrote:
>>>> I tested this using both lower and upper case 'c' with the following commit
>>>> text:
>>> []
>>>
>>> I think the patch subject be something like:
>>>
>>> "[PATCH] checkpatch: improve commit id/desc style checking in commit message"
>>>
>>> The [v2] goes in the subject like this:
>>>
>>> "[PATCH V2] checkpatch: ..."
>>>
>>>> 11 chars, SHOULD FAIL
>>>> commit 1234567890a
>>>
>>> []
>>>
>>>> ERROR: Please use 12 or more chars for the git commit ID
>>>> commit 1234567890a
>>>
>>> I'd expect these messages to mention something about the
>>> missing commit description too.
>>
>> Hmm ... is that a requirement here?
> 
> Yes
> 
>> Currently checkpatch.pl doesn't complain about that.
> 
> Yes, it does
> 
> $ ./scripts/checkpatch.pl 0001-part-1.patch
> ERROR: Please use 12 or more chars for the git commit ID like: 'commit 01234567890ab ("commit description")'
> #9: 
> commit 1234567, asdf
> 
> ERROR: Please use 12 or more chars for the git commit ID like: 'commit 01234567890ab ("commit description")'
> #11: 
> commit 123457

Oh I see.  I was completely confused by the message.  This is a better example FWIW:

ERROR: Please use 12 or more chars for the git commit ID like: 'commit
01234567890ab ("commit description")'
#13:
commit 1234567890abc

ie) the commit ID is 13 chars, but is missing a description ...

P.

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

end of thread, other threads:[~2014-10-21 12:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-20 22:49 [PATCH] scripts, checkpatch.pl, provide a better output message for commit id format [v2] Prarit Bhargava
2014-10-20 23:11 ` Joe Perches
2014-10-21  0:46   ` Prarit Bhargava
2014-10-21  2:11     ` Joe Perches
2014-10-21 12:03       ` Prarit Bhargava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox