linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: fix an issue regarding the git commit description style test
@ 2021-07-14  8:26 Hamza Mahfooz
  2021-08-13 11:36 ` Hamza Mahfooz
  2021-08-14  8:43 ` Lukas Bulwahn
  0 siblings, 2 replies; 4+ messages in thread
From: Hamza Mahfooz @ 2021-07-14  8:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Hamza Mahfooz, Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn

If we consider the output of the following command:

$ git shortlog | grep '"' | wc -l
14185

It becomes apparent that quite a number of commits have titles that,
contain at least one quotation mark and if you attempt to refer to those
commits in a new patch, checkpatch throws a false positive. This is
because, checkpatch disallows the use of quotation marks in commit titles,
only when referring to those commits in commit descriptions.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
---
 scripts/checkpatch.pl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 461d4221e4a4..cf31e8c994d3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3200,20 +3200,20 @@ sub process {
 			$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) {
+			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)"\)/i) {
 				$orig_desc = $1;
 				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) {
 				$orig_desc = $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+$/i &&
 				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				 $rawlines[$linenr] =~ /^\s*.+"\)/) {
+				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i;
 				$orig_desc = $1;
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+				$rawlines[$linenr] =~ /^\s*(.+)"\)/;
 				$orig_desc .= " " . $1;
 				$hasparens = 1;
 			}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: fix an issue regarding the git commit description style test
  2021-07-14  8:26 [PATCH] checkpatch: fix an issue regarding the git commit description style test Hamza Mahfooz
@ 2021-08-13 11:36 ` Hamza Mahfooz
  2021-08-14  8:43 ` Lukas Bulwahn
  1 sibling, 0 replies; 4+ messages in thread
From: Hamza Mahfooz @ 2021-08-13 11:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn

ping

On Wed, Jul 14 2021 at 04:26:07 AM -0400, Hamza Mahfooz 
<someguy@effective-light.com> wrote:
> If we consider the output of the following command:
> 
> $ git shortlog | grep '"' | wc -l
> 14185
> 
> It becomes apparent that quite a number of commits have titles that,
> contain at least one quotation mark and if you attempt to refer to 
> those
> commits in a new patch, checkpatch throws a false positive. This is
> because, checkpatch disallows the use of quotation marks in commit 
> titles,
> only when referring to those commits in commit descriptions.
> 
> Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
> ---
>  scripts/checkpatch.pl | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 461d4221e4a4..cf31e8c994d3 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3200,20 +3200,20 @@ sub process {
>  			$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) {
> +			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)"\)/i) {
>  				$orig_desc = $1;
>  				$hasparens = 1;
>  			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
>  				 defined $rawlines[$linenr] &&
> -				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
> +				 $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) {
>  				$orig_desc = $1;
>  				$hasparens = 1;
> -			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
> +			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+$/i &&
>  				 defined $rawlines[$linenr] &&
> -				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
> -				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
> +				 $rawlines[$linenr] =~ /^\s*.+"\)/) {
> +				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i;
>  				$orig_desc = $1;
> -				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
> +				$rawlines[$linenr] =~ /^\s*(.+)"\)/;
>  				$orig_desc .= " " . $1;
>  				$hasparens = 1;
>  			}
> --
> 2.32.0
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: fix an issue regarding the git commit description style test
  2021-07-14  8:26 [PATCH] checkpatch: fix an issue regarding the git commit description style test Hamza Mahfooz
  2021-08-13 11:36 ` Hamza Mahfooz
@ 2021-08-14  8:43 ` Lukas Bulwahn
  2021-08-15  0:47   ` Joe Perches
  1 sibling, 1 reply; 4+ messages in thread
From: Lukas Bulwahn @ 2021-08-14  8:43 UTC (permalink / raw)
  To: Hamza Mahfooz
  Cc: Linux Kernel Mailing List, Andy Whitcroft, Joe Perches, Dwaipayan Ray

On Wed, Jul 14, 2021 at 10:26 AM Hamza Mahfooz
<someguy@effective-light.com> wrote:
>
> If we consider the output of the following command:
>
> $ git shortlog | grep '"' | wc -l
> 14185
>
> It becomes apparent that quite a number of commits have titles that,
> contain at least one quotation mark and if you attempt to refer to those
> commits in a new patch, checkpatch throws a false positive. This is
> because, checkpatch disallows the use of quotation marks in commit titles,
> only when referring to those commits in commit descriptions.
>

Joe will certainly have the final say on this.

But just some remarks and hints from my side that might help all of us
judge this change:

14185 commits with at least one quotation mark might sound a lot, but
given that we have surpassed the one million commits, 14 thousand
commits is basically 1,4% so really a small fraction. Checkpatch is a
really large set of heuristics, many rules are much more fuzzy and
'wrong' for much larger classes than 1,4% of potential cases. So, we
are improving the heuristics here of a rule that is already very good,
compared to other checkpatch rules.

For all changes to checkpatch, that Dwaipayan (see CC), my former
mentee, contributed, we always ran a checkpatch evaluation on the
latest ~100,000 commits and checked the difference of before and after
the change to check if the change had some unexpected negative effect
besides its intended positive effect.

I would suggest that you do that too and share the results of that
evaluation with us. If you need some assistance or guidance on how to
create such a quick checkpatch evaluation, please just let Dwaipayan
and me know and we might give some further hints.

I hope this helps.

Lukas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: fix an issue regarding the git commit description style test
  2021-08-14  8:43 ` Lukas Bulwahn
@ 2021-08-15  0:47   ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2021-08-15  0:47 UTC (permalink / raw)
  To: Lukas Bulwahn, Hamza Mahfooz
  Cc: Linux Kernel Mailing List, Andy Whitcroft, Dwaipayan Ray

On Sat, 2021-08-14 at 10:43 +0200, Lukas Bulwahn wrote:
> On Wed, Jul 14, 2021 at 10:26 AM Hamza Mahfooz
> <someguy@effective-light.com> wrote:
> > 
> > If we consider the output of the following command:
> > 
> > $ git shortlog | grep '"' | wc -l
> > 14185
> > 
> > It becomes apparent that quite a number of commits have titles that,
> > contain at least one quotation mark and if you attempt to refer to those
> > commits in a new patch, checkpatch throws a false positive. This is
> > because, checkpatch disallows the use of quotation marks in commit titles,
> > only when referring to those commits in commit descriptions.
> > 
> 
> Joe will certainly have the final say on this.

I did suggest a patch.

https://lore.kernel.org/lkml/7f55d9d0369f1ea840fab83eeb77f9f3601fee41.camel@perches.com/



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-15  0:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  8:26 [PATCH] checkpatch: fix an issue regarding the git commit description style test Hamza Mahfooz
2021-08-13 11:36 ` Hamza Mahfooz
2021-08-14  8:43 ` Lukas Bulwahn
2021-08-15  0:47   ` 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).