Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964958AbcJXSjv (ORCPT ); Mon, 24 Oct 2016 14:39:51 -0400 Received: from smtprelay0179.hostedemail.com ([216.40.44.179]:54330 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752030AbcJXSjt (ORCPT ); Mon, 24 Oct 2016 14:39:49 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:800:960:967:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1543:1593:1594:1605:1711:1730:1747:1777:1792:2198:2199:2393:2525:2560:2563:2682:2685:2693:2828:2859:2895:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3622:3653:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6119:9025:10004:10400:10848:11026:11232:11658:11914:12043:12438:12555:12740:12760:13141:13230:13439:14096:14097:14181:14659:14721:21080:21451:30034:30054:30070:30080:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:19,LUA_SUMMARY:none X-HE-Tag: women56_383863f5e0361 X-Filterd-Recvd-Size: 4519 Message-ID: <1477334385.1984.9.camel@perches.com> Subject: Re: [PATCH 1/1] checkpatch: remove false warning for commit reference From: Joe Perches To: Heinrich Schuchardt , Andy Whitcroft , Andrew Morton Cc: linux-kernel@vger.kernel.org Date: Mon, 24 Oct 2016 11:39:45 -0700 In-Reply-To: References: <1465608362-4677-1-git-send-email-xypron.glpk@gmx.de> <1477208091-4887-1-git-send-email-xypron.glpk@gmx.de> <1477255021.3561.9.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.1-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3446 Lines: 105 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 > > > --- > > > 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