* [PATCH] checkpatch: Warn on bare 40 byte SHA-1 commit IDs
@ 2015-06-19 17:11 Joe Perches
2015-06-19 20:12 ` [PATCH V2] checkpatch: Warn on bare SHA-1 commit IDs in commit logs Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2015-06-19 17:11 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, LKML
Commit IDs should have commit descriptions too.
Warn when a bare 40 byte SHA-1 is used in commit logs.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 90e1edc..95f4776 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2317,9 +2317,11 @@ sub process {
}
# Check for git id commit length and improperly formed commit descriptions
- if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
- my $init_char = $1;
- my $orig_commit = lc($2);
+ if ($in_commit_log &&
+ ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
+ $line =~ /\b[0-9a-f]{40,40}\b/i)) {
+ my $init_char = "c";
+ my $orig_commit = "";
my $short = 1;
my $long = 0;
my $case = 1;
@@ -2330,6 +2332,13 @@ sub process {
my $orig_desc = "commit description";
my $description = "";
+ if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
+ $init_char = $1;
+ $orig_commit = lc($2);
+ } elsif ($line =~ /\b([0-9a-f]{40,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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH V2] checkpatch: Warn on bare SHA-1 commit IDs in commit logs
2015-06-19 17:11 [PATCH] checkpatch: Warn on bare 40 byte SHA-1 commit IDs Joe Perches
@ 2015-06-19 20:12 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2015-06-19 20:12 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, LKML
Commit IDs should have commit descriptions too.
Warn when a 12 to 40 byte SHA-1 is used in commit logs.
Signed-off-by: Joe Perches <joe@perches.com>
---
It might make more sense to check hex value lengths from
12 to 40 instead. The longest English word length I found
with just a-f was 7. (acceded/defaced/effaced)
scripts/checkpatch.pl | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 90e1edc..f62e6f1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2317,9 +2317,11 @@ sub process {
}
# Check for git id commit length and improperly formed commit descriptions
- if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
- my $init_char = $1;
- my $orig_commit = lc($2);
+ if ($in_commit_log &&
+ ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
+ $line =~ /\b[0-9a-f]{12,40}\b/i)) {
+ my $init_char = "c";
+ my $orig_commit = "";
my $short = 1;
my $long = 0;
my $case = 1;
@@ -2330,6 +2332,13 @@ sub process {
my $orig_desc = "commit description";
my $description = "";
+ if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
+ $init_char = $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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-19 20:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-19 17:11 [PATCH] checkpatch: Warn on bare 40 byte SHA-1 commit IDs Joe Perches
2015-06-19 20:12 ` [PATCH V2] checkpatch: Warn on bare SHA-1 commit IDs in commit logs 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