* [PATCH] checkpatch: warn on bad commit description in 'Fixes' tag
@ 2019-02-19 6:36 Changbin Du
2019-02-19 9:22 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Changbin Du @ 2019-02-19 6:36 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches
Cc: linux-kernel, Changbin Du, Stephen Rothwell, Linus Torvalds,
Steven Rostedt
There are some complaints about bad commit description in 'Fixes' tag.
Most cases are SHA1 should be at least 12 digits long. Let's extend
the existing check in checkpatch.pl to include commit description of
'Fixes' tag.
Reference: https://lkml.org/lkml/2019/2/18/1477
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
scripts/checkpatch.pl | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b737ca9d7204..6f0156778a07 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2726,11 +2726,11 @@ sub process {
if ($in_commit_log && !$commit_log_possible_stack_dump &&
$line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
$line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
- ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
+ ($line =~ /\b(?:commit|fixes:)\s+[0-9a-f]{5,}\b/i ||
($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
$line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
$line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
- my $init_char = "c";
+ my $init_str = "commit";
my $orig_commit = "";
my $short = 1;
my $long = 0;
@@ -2742,29 +2742,29 @@ sub process {
my $orig_desc = "commit description";
my $description = "";
- if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
- $init_char = $1;
+ if ($line =~ /\b(commit|fixes:)\s+([0-9a-f]{5,})\b/i) {
+ $init_str = $1;
$orig_commit = lc($2);
} elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
$orig_commit = lc($1);
}
- $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
- $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
- $space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
- $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
- if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+ $short = 0 if ($orig_commit =~ /\b[0-9a-f]{12,40}/i);
+ $long = 1 if ($orig_commit =~ /\b[0-9a-f]{41,}/i);
+ $space = 0 if ($line =~ /\b(?:commit|fixes:) [0-9a-f]/i);
+ $case = 0 if ($line =~ /\b(?:Commit|commit|Fixes:)\s+[0-9a-f]{5,40}[^A-F]/);
+ if ($line =~ /\b(?:commit|fixes:)\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
$orig_desc = $1;
$hasparens = 1;
- } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
+ } elsif ($line =~ /\b(?:commit|fixes:)\s+[0-9a-f]{5,}\s*$/i &&
defined $rawlines[$linenr] &&
$rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
$orig_desc = $1;
$hasparens = 1;
- } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+ } elsif ($line =~ /\b(?:commit|fixes:)\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
defined $rawlines[$linenr] &&
$rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
- $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+ $line =~ /\b(?:commit|fixes:)\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
$orig_desc = $1;
$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
$orig_desc .= " " . $1;
@@ -2776,8 +2776,16 @@ sub process {
if (defined($id) &&
($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
+ if (lc $init_str eq lc "commit") {
+ my @chars = split("", $init_str);
+ $init_str = "$chars[0]ommit";
+ } else {
+ $init_str = "Fixes:"
+ }
+
ERROR("GIT_COMMIT_ID",
- "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
+ "Please use git commit description style 'commit/Fixes: <12+ chars of sha1> (\"<title line>\")' - ie: '${init_str} $id (\"$description\")'\n" .
+ $herecurr . "\nThis can be fixed by 'git config --global core.abbrev 12'.\n");
}
}
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] checkpatch: warn on bad commit description in 'Fixes' tag
2019-02-19 6:36 [PATCH] checkpatch: warn on bad commit description in 'Fixes' tag Changbin Du
@ 2019-02-19 9:22 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2019-02-19 9:22 UTC (permalink / raw)
To: Changbin Du, Andy Whitcroft
Cc: linux-kernel, Stephen Rothwell, Linus Torvalds, Steven Rostedt
On Tue, 2019-02-19 at 06:36 +0000, Changbin Du wrote:
> There are some complaints about bad commit description in 'Fixes' tag.
> Most cases are SHA1 should be at least 12 digits long. Let's extend
> the existing check in checkpatch.pl to include commit description of
> 'Fixes' tag.
I sent a suggested patch a bit ago
https://lore.kernel.org/lkml/40bfc40958fca6e2cc9b86101153aa0715fac4f7.camel@perches.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-19 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 6:36 [PATCH] checkpatch: warn on bad commit description in 'Fixes' tag Changbin Du
2019-02-19 9:22 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome