Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1507579

Re: [PATCH 1/1] checkpatch: remove false warning for commit reference

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/1] checkpatch: remove false warning for commit reference
Date 2016-10-24 20:50 +0200
Message-ID <svStP-31f-11@gated-at.bofh.it> (permalink)
References <rIFUl-4Uy-7@gated-at.bofh.it> <svlHz-6sb-11@gated-at.bofh.it> <svxIK-5Gc-19@gated-at.bofh.it> <svRep-2gd-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 2016-10-24 at 19:22 +0200, Heinrich Schuchardt wrote:
> On 10/23/2016 10:37 PM, Joe Perches wrote:
> > On Sun, 2016-10-23 at 09:34 +0200, Heinrich Schuchardt wrote:
> > > Checkpatch warns of an incorrect commit reference style
> > > for any hexadecimal number of 12 digits and more.
> > > 
> > > Numbers of 12 digits are not necessarily commit ids.
> > > 
> > > For an example provoking the problem see
> > > https://patchwork.kernel.org/patch/9170897/
> > > 
> > > Checkpatch should only warn if the number refers to an
> > > existing commit.
> > 
> > That seems sensible.
> > 
> > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > > ---
> > >  scripts/checkpatch.pl | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > 
> > []
> > > @@ -848,6 +848,7 @@ sub git_commit_info {
> > >  #		    echo "commit $(cut -c 1-12,41-)"
> > >  #		done
> > >  	} elsif ($lines[0] =~ /^fatal: ambiguous argument '$commit': unknown revision or path not in the working tree\./) {
> > > +		$id = undef;
> > 
> > OK
> > 
> > >  	} else {
> > >  		$id = substr($lines[0], 0, 12);
> > >  		$desc = substr($lines[0], 41);
> > > @@ -2577,7 +2578,9 @@ sub process {
> > >  			($id, $description) = git_commit_info($orig_commit,
> > >  							      $id, $orig_desc);
> > >  
> > > -			if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
> > > +			if ($id && ($short || $long || $space || $case
> > > +				|| ($orig_desc ne $description)
> > > +				|| !$hasparens)) {
> > 
> > I'd prefer
> > 			if (defined($id) &&
> 
> For $id = 0 or $id = "" this would make a difference.
> Surely I can update the patch like this to make the test more readable.
> 
> > 			   ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
> > 
> > and not wrap the tests.
> 
> Putting defined($id) on a line of its own is fine.
> 
> Not wrapping the tests will produce a line of over 80 characters and
> give a warning in scripts/checkpatch.pl.
> 
> The script should respect the standards it imposes on others.

Nope.

I never bother using checkpatch on checkpatch.
perl is unreadable enough with having to wrap long and
complex regexes on 80 columns.

> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > @@ -829,13 +829,16 @@ sub seed_camelcase_includes {
> >  sub git_commit_info {
> >  	my ($commit, $id, $desc) = @_;
> >  
> > -	return ($id, $desc) if ((which("git") eq "") || !(-e ".git"));
> > +	my $git_id = undef;
> > +	my $git_desc = undef;
> > +
> > +	return ($git_id, $git_desc) if ((which("git") eq "") || !(-e ".git"));
> 
> Why not simply
> return (undef, undef) if ((which("git") eq "") || !(-e ".git"));

shrug.  coding taste or lack thereof.
Maybe mine.  No specific reason one is
better than the other.

> Should we provide a warning: "git not found"?

No. git isn't required.

> > @@ -2577,7 +2580,8 @@ sub process {
> >  			($id, $description) = git_commit_info($orig_commit,
> >  							      $id, $orig_desc);
> >  
> > -			if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
> > +			if (defined($id) &&  
> > +			    ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
> 
> This line is over 80 characters.

And I specifically don't care.

> Which is not accepatble according to checkpatch.pl.

see above

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] checkpatch: remove false warning for commit reference Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-10-23 09:50 +0200
  Re: [PATCH 1/1] checkpatch: remove false warning for commit  reference Joe Perches <joe@perches.com> - 2016-10-23 22:40 +0200
    Re: [PATCH 1/1] checkpatch: remove false warning for commit reference Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-10-24 19:30 +0200
      Re: [PATCH 1/1] checkpatch: remove false warning for commit reference Andy Whitcroft <apw@canonical.com> - 2016-10-24 20:50 +0200
        [PATCH] checkpatch: Don't check .pl files, improve absolute path commit log test Joe Perches <joe@perches.com> - 2016-10-24 22:20 +0200
      Re: [PATCH 1/1] checkpatch: remove false warning for commit  reference Joe Perches <joe@perches.com> - 2016-10-24 20:50 +0200

csiph-web