All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Efremov <efremov@linux.com>
To: Joe Perches <joe@perches.com>, linux-kselftest@vger.kernel.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: Thu, 19 Aug 2021 22:52:29 +0300	[thread overview]
Message-ID: <c31b2007-26a9-34e0-8c9a-8e11a00ce69f@linux.com> (raw)
In-Reply-To: <23c8ebaa0921d5597df9fc1d6cbbcc4f354f80c5.camel@perches.com>

Hi,

On 8/19/21 12:22 AM, Joe Perches wrote:
> Hey Denis:
> 
> Try this one please and let me know what you think...

Looks good to me. Couple of nitpicks below

> 
> ---
>  scripts/checkpatch.pl | 31 +++++++++++++------------------
>  1 file changed, 13 insertions(+), 18 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 161ce7fe5d1e5..4e2e79eff9b8c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3196,26 +3196,21 @@ sub process {
>  				$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);
> -			$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) {
> -				$orig_desc = $1;
> -				$hasparens = 1;
> -			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
> -				 defined $rawlines[$linenr] &&
> -				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
> -				$orig_desc = $1;
> -				$hasparens = 1;
> -			} 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;
> +			my $input = $line;
> +			for (my $n = 0; $n < 2; $n++) {
> +				$input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n);
> +			}
> +
> +			$short = 0 if ($input =~ /\bcommit\s+[0-9a-f]{12,40}/i);
> +			$long = 1 if ($input =~ /\bcommit\s+[0-9a-f]{41,}/i);
> +			$space = 0 if ($input =~ /\bcommit [0-9a-f]/i);
> +			$case = 0 if ($input =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
> +			if ($input =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i) {
>  				$orig_desc = $1;
> -				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
> -				$orig_desc .= " " . $1;
>  				$hasparens = 1;
> +				# Always strip leading/trailing parens then double quotes if existing
> +				$orig_desc = substr($orig_desc, 1, -1);
> +				$orig_desc = substr($orig_desc, 1, -1) if ($orig_desc =~ /^".*"$/);

Why do you want to add "if ($orig_desc =~ /^".*"$/);" here? and not just substr($orig_desc, 2, -2);?

>  			}
>  
>  			($id, $description) = git_commit_info($orig_commit,
> 

In your previous patch with '.*?' you added a branch to allow also newlines between commit and shas:
```
commit
c3f157259438 (Revert "floppy: reintroduce O_NDELAY fix")
```

Maybe something like this will work (adding a last word from a prevline if line doesn't start from
commit)
+                       my $input = $line;
                        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);
+                               $prevline =~ /(\w+)$/;
+                               $line = $1 . " " . $prevline;
                        }
 
-                       my $input = $line;
                        for (my $n = 0; $n < 2; $n++) {
                                $input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n);
                        }

Thanks,
Denis


  reply	other threads:[~2021-08-19 19:52 UTC|newest]

Thread overview: 21+ 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
2021-08-18 20:35         ` Andrew Morton
2021-08-18 21:22       ` Joe Perches
2021-08-19 19:52         ` Denis Efremov [this message]
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-18 21:47   ` kernel test robot
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=c31b2007-26a9-34e0-8c9a-8e11a00ce69f@linux.com \
    --to=efremov@linux.com \
    --cc=axboe@kernel.dk \
    --cc=jkosina@suse.cz \
    --cc=joe@perches.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=w@1wt.eu \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.