Skip to contentSkip to conversation

checkpatch: add new cases to commit handling

RFC PATCH In review Dwaipayan Ray 2 participants 5 messages Nov 12, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 checkpatch: add new cases to commit handling

Commit extraction in checkpatch fails in some cases. One of the most common false positives is a split line between "commit" and the git SHA of the commit.

Improve commit handling to reduce false positives.

Improvements:
- handle split line between commit and git SHA of commit.
- fix handling of split commit description.

---
 scripts/checkpatch.pl | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +13 -1
index 024514946bed..f5ba2beac008 100755
@@ -2990,6 +2990,16 @@ sub process {
 			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
 				$orig_desc = $1;
 				$hasparens = 1;
+			} elsif ($line =~ /^\s*[0-9a-f]{5,}\s+\("([^"]+)"\)/i &&
+				 defined $rawlines[$linenr-2] &&
+				 $rawlines[$linenr-2] =~ /\bcommit\s*$/i) {
+				$line =~ /^\s*[0-9a-f]{5,}\s+\("([^"]+)"\)/i;
+				$orig_desc = $1;
+				$hasparens = 1;
+				$space = 0;
+				$short = 0 if ($line =~ /\b[0-9a-f]{12,40}/i);
+				$long = 1 if ($line =~ /\b[0-9a-f]{41,}/i);
+				$case = 0 if ($line =~ /\b[0-9a-f]{5,40}[^A-F]/ && $rawlines[$linenr-2] =~ /\b[Cc]ommit\s*$/);
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
 				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
@@ -3001,7 +3011,9 @@ sub process {
 				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
 				$orig_desc = $1;
 				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
-				$orig_desc .= " " . $1;
+				my $split_desc = $1;
+				$split_desc = " $split_desc" if ($line =~ /[\w\,\.]$/);
+				$orig_desc .= $split_desc;
 				$hasparens = 1;
 			}
 
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 11 lines · Dwaipayan Ray

Commit extraction in checkpatch fails in some cases. One of the most common false positives is a split line between "commit" and the git SHA of the commit.

Improve commit handling to reduce false positives.

Improvements:
- handle split line between commit and git SHA of commit.
- fix handling of split commit description.

Looks good. Do we have a quick evaluation on that?

Lukas

Quoted 38 lines
---
 scripts/checkpatch.pl | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +13 -2
index 024514946bed..f5ba2beac008 100755
@@ -2990,6 +2990,16 @@ sub process {
                        if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
                                $orig_desc = $1;
                                $hasparens = 1;
+                       } elsif ($line =~ /^\s*[0-9a-f]{5,}\s+\("([^"]+)"\)/i &&
+                                defined $rawlines[$linenr-2] &&
+                                $rawlines[$linenr-2] =~ /\bcommit\s*$/i) {
+                               $line =~ /^\s*[0-9a-f]{5,}\s+\("([^"]+)"\)/i;
+                               $orig_desc = $1;
+                               $hasparens = 1;
+                               $space = 0;
+                               $short = 0 if ($line =~ /\b[0-9a-f]{12,40}/i);
+                               $long = 1 if ($line =~ /\b[0-9a-f]{41,}/i);
+                               $case = 0 if ($line =~ /\b[0-9a-f]{5,40}[^A-F]/ && $rawlines[$linenr-2] =~ /\b[Cc]ommit\s*$/);
                        } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
                                 defined $rawlines[$linenr] &&
                                 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
@@ -3001,7 +3011,9 @@ sub process {
                                $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
                                $orig_desc = $1;
                                $rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
-                               $orig_desc .= " " . $1;
+                               my $split_desc = $1;
+                               $split_desc = " $split_desc" if ($line =~ /[\w\,\.]$/);
+                               $orig_desc .= $split_desc;
                                $hasparens = 1;
                        }
 
--
Quoted 2 lines

2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#2 lore raw
Quoted 7 lines · Lukas Bulwahn
Quoted 5 lines · Dwaipayan Ray

Commit extraction in checkpatch fails in some cases. One of the most common false positives is a split line between "commit" and the git SHA of the commit.

Quoted 9 lines
Quoted 6 lines

Improve commit handling to reduce false positives.

Improvements:
- handle split line between commit and git SHA of commit.
- fix handling of split commit description.

Looks good. Do we have a quick evaluation on that?

Yes, I had a previous warning dump for 50k commits from v5.4.

Earlier, no. of GIT_COMMIT ID errors was: 1032.
After the patch it is: 897.

I haven't checked which ones exactly were fixed though. I think I could extract those commit references just to be sure.

Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#3 lore raw
Quoted 16 lines · Dwaipayan Ray
Quoted 14 lines · Lukas Bulwahn
Quoted 11 lines · Dwaipayan Ray

Commit extraction in checkpatch fails in some cases. One of the most common false positives is a split line between "commit" and the git SHA of the commit.

Improve commit handling to reduce false positives.

Improvements:
- handle split line between commit and git SHA of commit.
- fix handling of split commit description.

Quoted 9 lines
Quoted 2 lines

Looks good. Do we have a quick evaluation on that?

Yes, I had a previous warning dump for 50k commits from v5.4.

Earlier, no. of GIT_COMMIT ID errors was: 1032.
After the patch it is: 897.

Impact-wise that sounds like a good contribution to checkpatch.

Quoted 4 lines

I haven't checked which ones exactly were fixed though. I think I could extract those commit references just to be sure.

Let us create a quick list of those; it will probably just take a few minutes to check them. And Joe is probably going to ask for an independent check anyway :)

Add the summary of the evaluation to the commit message and then let us send this patch to Joe and lkml.

Lukas
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#4 lore raw
Quoted 13 lines
Quoted 6 lines

Yes, I had a previous warning dump for 50k commits from v5.4.

Earlier, no. of GIT_COMMIT ID errors was: 1032.
After the patch it is: 897.

Impact-wise that sounds like a good contribution to checkpatch.

Quoted 4 lines

I haven't checked which ones exactly were fixed though. I think I could extract those commit references just to be sure.

Quoted 8 lines

Let us create a quick list of those; it will probably just take a few minutes to check them. And Joe is probably going to ask for an independent check anyway :)

Add the summary of the evaluation to the commit message and then let us send this patch to Joe and lkml.

Lukas

Sure okay, I will prepare the list and send it off :)

Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees