scripts, checkpatch.pl, provide a better output message for commit id format [v2]
PATCH 1/1 scripts, checkpatch.pl, provide a better output message for commit id format [v2]
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.
[v2]: Add separate messages for warnings instead of one global format warning.
--- scripts/checkpatch.pl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
scripts/checkpatch.pl +14 -10
@@ -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
Signature · 1 line
1.7.9.3
Joe Perches
maintainerQuoted 2 lines · Prarit Bhargava
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: ..."
Quoted 2 lines
11 chars, SHOULD FAIL
commit1234567890a
[]
Quoted 2 lines
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.
Quoted 16 lines · Joe Perches
Quoted 2 lines · Prarit Bhargava
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: ..."
Quoted 2 lines
11 chars, SHOULD FAIL
commit1234567890a
Quoted 7 lines
[]
Quoted 2 lines
ERROR: Please use 12 or more chars for the git commit ID commit
1234567890aI'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.
Quoted 2 lines
Joe Perches
maintainerQuoted 20 lines · Prarit Bhargava
Quoted 18 lines · Joe Perches
Quoted 2 lines · Prarit Bhargava
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: ..."
Quoted 2 lines
11 chars, SHOULD FAIL
commit1234567890a[]
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
ERROR: Please use 12 or more chars for the git commit ID commit
1234567890aI'd expect these messages to mention something about the missing commit description too.
Hmm ... is that a requirement here?
Yes
Quoted 1 line
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, asdfERROR: Please use 12 or more chars for the git commit ID like: 'commit 01234567890ab ("commit description")' #11:
commit 123457
Quoted 2 lines
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.
Quoted 35 lines · Joe Perches
Quoted 20 lines · Prarit Bhargava
Quoted 18 lines · Joe Perches
Quoted 2 lines · Prarit Bhargava
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: ..."
Quoted 2 lines
11 chars, SHOULD FAIL
commit1234567890a[]
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
ERROR: Please use 12 or more chars for the git commit ID commit
1234567890aI'd expect these messages to mention something about the missing commit description too.
Hmm ... is that a requirement here?
Yes
Quoted 1 line
Currently checkpatch.pl doesn't complain about that.
Yes, it does
Quoted 8 lines
$ ./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, asdfERROR: 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.