linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Denis Efremov <efremov@linux.com>,
	linux-kselftest@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>, Jiri Kosina <jkosina@suse.cz>,
	Willy Tarreau <w@1wt.eu>
Subject: Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits
Date: Wed, 18 Aug 2021 13:21:16 -0700	[thread overview]
Message-ID: <71535d629266751273c15cc05dd7c987cb9c43b6.camel@perches.com> (raw)
In-Reply-To: <3d347d4b-1576-754f-8633-ba6084cc0661@linux.com>

On Wed, 2021-08-18 at 19:21 +0300, Denis Efremov wrote:
> 
> On 8/18/21 7:00 PM, Joe Perches wrote:
> > On Wed, 2021-08-18 at 18:46 +0300, Denis Efremov wrote:
> > > Properly handle commits like:
> > > commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")
> > 
> > Try this one:
> > 
> > https://lore.kernel.org/lkml/7f55d9d0369f1ea840fab83eeb77f9f3601fee41.camel@perches.com/
> > 
> 
> It works but why not to use .+? then?
> I'm not sure that non-greedy patterns will properly handle commits like:
> $ git log --oneline | fgrep '")'
> 
> e.g. 
> commit ece2619fe8ed ("extcon: arizona: Fix flags parameter to the gpiod_get("wlf,micd-pol") call")

The only way to handle that is to use the $balanced_parens test but
it wouldn't work on Andrew's perl version 5.8

Andrew?  Do you still use perl 5.8?  It's almost 20 years old now.
Does anyone still use perl versions 5.8 or lower?

From checkpatch:

# Using $balanced_parens, $LvalOrFunc, or $FuncArg
# requires at least perl version v5.10.0
# Any use must be runtime checked with $^V

our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
our $LvalOrFunc	= qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};

So maybe:

> > > diff --git 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) {

So that could be:
			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/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*\("(.+)"\)/) {

and

  			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
				"$line $rawlines[$linenr]" =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i

> > >  				$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;

etc...

> > >  				$orig_desc = $1;
> > > -				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
> > > +				$rawlines[$linenr] =~ /^\s*(.+)"\)/;
> > >  				$orig_desc .= " " . $1;
> > >  				$hasparens = 1;
> > >  			}
> > 



  reply	other threads:[~2021-08-18 20:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 15:46 [RFC PATCH 0/5] selftests: floppy: basic tests Denis Efremov
2021-08-18 15:46 ` [RFC PATCH 1/5] checkpatch: improve handling of revert commits Denis Efremov
2021-08-18 16:00   ` Joe Perches
2021-08-18 16:21     ` Denis Efremov
2021-08-18 20:21       ` Joe Perches [this message]
2021-08-18 20:35         ` Andrew Morton
2021-08-18 21:22       ` Joe Perches
2021-08-19 19:52         ` Denis Efremov
2021-08-19 21:44           ` Joe Perches
2021-08-19 22:17           ` Joe Perches
2021-08-21  6:47             ` Denis Efremov
2021-08-21  7:12               ` Joe Perches
2021-08-21  7:35                 ` Denis Efremov
2021-08-18 15:46 ` [RFC PATCH 2/5] gen_initramfs.sh: use absolute path for gen_init_cpio Denis Efremov
2021-08-19  0:24   ` Masahiro Yamada
2021-08-19 20:51     ` Denis Efremov
2021-08-20  2:19       ` Masahiro Yamada
2021-08-18 15:46 ` [RFC PATCH 3/5] selftests: floppy: add basic tests for opening an empty device Denis Efremov
2021-08-18 15:46 ` [RFC PATCH 4/5] selftests: floppy: add basic tests for a readonly disk Denis Efremov
2021-08-18 15:46 ` [RFC PATCH 5/5] selftests: floppy: add basic rdwr tests Denis Efremov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=71535d629266751273c15cc05dd7c987cb9c43b6.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=efremov@linux.com \
    --cc=jkosina@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=w@1wt.eu \
    --subject='Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).