* [PATCH] checkpatch: fix can't check for too long invalid commit id
@ 2020-05-02 18:50 Wang YanQing
2020-05-02 19:07 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Wang YanQing @ 2020-05-02 18:50 UTC (permalink / raw)
To: joe
Cc: Andy Whitcroft, linux-kernel, Alexei Starovoitov, Matteo Croce,
Markus.Elfring, kernel-janitors
The current UNKNOWN_COMMIT_ID doesn't check for 41+ length commit id,
and although GIT_COMMIT_ID will check for 41+ length commit id, but
it willn't warn anything about it due to 41+ length commit will never
be defined.
This patch moves the unknown commit id check for normal commit description
to GIT_COMMIT_ID, and uses ERROR instead of WARN, because unknown commit
id is total useless to track change history in changelog, it deserves the
ERROR.
Signed-off-by: Wang YanQing <udknight@gmail.com>
---
After this patch, in another patch 'checkpatch: add support to check 'Fixes:' tag format',
I will delete UNKNOWN_COMMIT_ID, because we don't need it anymore after GIT_COMMIT_ID could
do the same check as UNKNOWN_COMMIT_ID for 'Fixes:' tag.
scripts/checkpatch.pl | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 23a001a..143bb43 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2865,8 +2865,18 @@ sub process {
($id, $description) = git_commit_info($orig_commit,
$id, $orig_desc);
+ if (!defined($id)) {
+ if ($long) {
+ ERROR("GIT_COMMIT_ID",
+ "Unknown commit id '$orig_commit' is too long, maybe misspelled?\n" . $herecurr);
+ } else {
+ ERROR("GIT_COMMIT_ID",
+ "Unknown commit id '$orig_commit', maybe rebased or not pulled?\n" . $herecurr);
+ }
+ }
+
if (defined($id) &&
- ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
+ ($short || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
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);
}
@@ -2969,7 +2979,7 @@ sub process {
}
# check for invalid commit id
- if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
+ if ($in_commit_log && $line =~ /(^fixes:)\s+([0-9a-f]{6,40})\b/i) {
my $id;
my $description;
($id, $description) = git_commit_info($2, undef, undef);
--
1.8.5.6.2.g3d8a54e.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] checkpatch: fix can't check for too long invalid commit id
2020-05-02 18:50 [PATCH] checkpatch: fix can't check for too long invalid commit id Wang YanQing
@ 2020-05-02 19:07 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2020-05-02 19:07 UTC (permalink / raw)
To: Wang YanQing
Cc: Andy Whitcroft, linux-kernel, Alexei Starovoitov, Matteo Croce,
Markus.Elfring, kernel-janitors
On Sun, 2020-05-03 at 02:50 +0800, Wang YanQing wrote:
> The current UNKNOWN_COMMIT_ID doesn't check for 41+ length commit id,
> and although GIT_COMMIT_ID will check for 41+ length commit id, but
> it willn't warn anything about it due to 41+ length commit will never
> be defined.
>
> This patch moves the unknown commit id check for normal commit description
> to GIT_COMMIT_ID, and uses ERROR instead of WARN, because unknown commit
> id is total useless to track change history in changelog, it deserves the
> ERROR.
>
> Signed-off-by: Wang YanQing <udknight@gmail.com>
Hi again. Trivial notes:
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2865,8 +2865,18 @@ sub process {
> ($id, $description) = git_commit_info($orig_commit,
> $id, $orig_desc);
>
> + if (!defined($id)) {
> + if ($long) {
> + ERROR("GIT_COMMIT_ID",
> + "Unknown commit id '$orig_commit' is too long, maybe misspelled?\n" . $herecurr);
checkpatch always uses tab indentation.
Please convert from 4 spaces to 1
tab and reindent the rest.
"misspelled" word choice may not be the best here as a
SHA-1 isn't really something that is spelled.
Perhaps something like:
"Invalid commit id '$orig_commit' length '" . length($orig_commit) . "' exceeds allowed maximum of 40\n",
Though maybe a recommended maximum of some constant should be used.
my $recommended_sha_length = 12;
> @@ -2969,7 +2979,7 @@ sub process {
> }
>
> # check for invalid commit id
> - if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
> + if ($in_commit_log && $line =~ /(^fixes:)\s+([0-9a-f]{6,40})\b/i) {
Likely this capture group around Fixes: isn't necessary any more.
> my $id;
> my $description;
> ($id, $description) = git_commit_info($2, undef, undef);
$1 ?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-02 19:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 18:50 [PATCH] checkpatch: fix can't check for too long invalid commit id Wang YanQing
2020-05-02 19:07 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).