Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1021473pxa; Fri, 28 Aug 2020 01:07:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybWZ6GGZORR8Zuu5YT9HN91kqUUKRjL6bJYyDkuw3XCwdNfYYrLXd6WkYmLSUfp3eZk+Nm X-Received: by 2002:a17:906:2a1a:: with SMTP id j26mr568080eje.456.1598602050830; Fri, 28 Aug 2020 01:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598602050; cv=none; d=google.com; s=arc-20160816; b=s5JCCf9xjiJuEPetGREka12WbB2uupbJJxsDTN1jwq9Z1RmKYKBwHmSHuAgQRNYFJk 9vgOQPOvYsxxvP3Pso5Af5A2hw8VPjE0ZN+ypeE5qEUp60FKSTDH4BducBCNtbi2tIpP xcdH2svhIuz7/yw+6EXMxfiuel6Ovwa36Vv8PuCvmWxImn0B6/8VJiBiV34uztcHlp1B whnPAcZG3BLr6ekVVjLbO7Kd0y7TUTrJNy9dDgKP99nGm0cg7iKfrldqNuYP8aT7ZjDH uokuoOZrhzHb1y6yEFqFt4s33nlVcrmvLmY68crUbvtch4ju0rLgujYAINXE8c6clTqQ OHkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=3+ud1x+ePgEUQydlf8bvYdkdsnIYYJHjFsCE++5i93M=; b=ts1YwsNfNufYxVhhyUIE23eTQR/efVZzAEY61SJFjbUrcJWuZzg+0XhbzCNSG4FF8k oFKohmh5b2L4TtdSbTrouAwpddzIODoUCfIsnejGdcHtkqPK/vYOs9R45URDSx6iYJfc oknULot0qiv8rcw/m5ZDkzyXUGi0JiYtAlbskYNIUuQus9rZBD8n0sfsdJCWrKhR1tVg qbToH4+/mXll8P+LafOkZpdMKthZqMtwoKSofA+uP6ohcz1UbIZ+tW+Os1iwzJ3oTGXP VFIVexPmKPsqRJIA084AmhEThvrqjdm1590v8J1GujE/3CkNevzb5yuCocwmFOys5Chg XM8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr5si155548ejb.549.2020.08.28.01.07.08; Fri, 28 Aug 2020 01:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728269AbgH1IEL (ORCPT + 99 others); Fri, 28 Aug 2020 04:04:11 -0400 Received: from smtprelay0210.hostedemail.com ([216.40.44.210]:39466 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727911AbgH1IEA (ORCPT ); Fri, 28 Aug 2020 04:04:00 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id C0F65100E7B43; Fri, 28 Aug 2020 08:03:57 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3622:3653:3865:3867:3868:3870:3871:3872:3873:3874:4321:5007:6119:6248:8531:10004:10400:10848:11026:11232:11658:11914:12297:12438:12555:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:14777:21063:21080:21433:21611:21627:21819:21939:21990:30022:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: sheep46_3417ebf27074 X-Filterd-Recvd-Size: 2491 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf19.hostedemail.com (Postfix) with ESMTPA; Fri, 28 Aug 2020 08:03:56 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: Allow not using -f with files that are in git From: Joe Perches To: Rasmus Villemoes , Andrew Morton Cc: Andy Whitcroft , LKML Date: Fri, 28 Aug 2020 01:03:55 -0700 In-Reply-To: <234290e5-b8dc-22c7-d26f-60a02844ce0a@rasmusvillemoes.dk> References: <45b81a48e1568bd0126a96f5046eb7aaae9b83c9.camel@perches.com> <234290e5-b8dc-22c7-d26f-60a02844ce0a@rasmusvillemoes.dk> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-08-25 at 14:23 +0200, Rasmus Villemoes wrote: > On 25/08/2020 02.09, Joe Perches wrote: > > If a file exists in git and checkpatch is used without the -f > > flag for scanning a file, then checkpatch will scan the file > > assuming it's a patch and emit: > > > > ERROR: Does not appear to be a unified-diff format patch > > > > Change the behavior to assume the -f flag if the file exists > > in git. > > Heh, I read the patch subject to mean you introduced a way for subsystem > maintainers to prevent running checkpatch -f on their files, which I > think some would like ;) > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > index 79fc357b18cd..cdee7cfadc11 100755 > > --- a/scripts/checkpatch.pl > > +++ b/scripts/checkpatch.pl > > @@ -976,6 +976,16 @@ sub seed_camelcase_includes { > > } > > } > > > > +sub git_is_single_file { > > + my ($filename) = @_; > > + > > + return 0 if ((which("git") eq "") || !(-e "$gitroot")); > > + > > + my $output = `${git_command} ls-files -- $filename`; > > + my $count = $output =~ tr/\n//; > > + return $count eq 1 && $output =~ m{^${filename}$}; > > +} > > Isn't that somewhat expensive to do for each file? Why not postpone that > check till we're about to complain that the file is not a diff (haven't > looked at how such a refactoring would look). It's necessary because you need the --file option set _before_ analyzing the file content. Oddly, I didn't receive this email directly so I couldn't reply to it earlier.