Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2906701pxa; Tue, 25 Aug 2020 06:40:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSZx3RXCWHeWkfhCCCaYyrZXr+69UQTFDfmD9ctW0sgjeGnwolxe0WiyuTnFrgrTbHZe6d X-Received: by 2002:a50:c8ca:: with SMTP id k10mr9907338edh.255.1598362809793; Tue, 25 Aug 2020 06:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598362809; cv=none; d=google.com; s=arc-20160816; b=oJQnEIphrYj6O3tz1J/ICwik6IPc91ko0iztJ975ee5toSQ5fixYRJgOM/GEEO+Tsl XWOl4rpH2Ilk4MVaZnKKeWm/inp+XAk6ODPMTulBv49wIA/2R4U+S9o1fissw4zt3uKY SvZcE8oUZtY2CZgghuPryxa+m3W1dvJaLOmM8nXIJcMCvYXifxn+MuN9/DtX7WYF3T/U 7nXVHyw0t47SoRSkRYUS2JJeDapWaToJ35eZrLGVzYpYSr0N/ec5OGyk+NxKPMJ+i/zU z9TXFZZjdrU1Qa5PYqqZTPTdh9+6pWFdAyP5kJQSS4+53f4U2/R33U8pSCzyMVLItM3I O69Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=npQSbmA+gXwC9a6IjiIfcuykqKuVSdMx81JKlqg6LVc=; b=QRVVzfwn++/PjdUhOObiwf8shVI1/Ckbyg8HDdQX1BbXwxJ1y+RNmKFbzjrMFqP0Y1 uJnBgxTL2W6NVDJbxecPOBzqFhM0oARR7kmxV8SzgilEE8wVHteZzclGTYgecLajcS2Z sq6vwAUZZE/yHyn5YAYtHNgBYnOhzpINSmOQoAvkkt/9px6wsarz3BnhWjvLJ11T06XP vSek3jlF8ZVSy9zhZWq7Hcju3/+B3OILvzB5sAendwKLqO3CTJFeFi75hS+dnaldJMdE PMaH1zN+4gVQ0GYn+VWOAimfA6c+V5g0ef3pi9FMT+0vTA+2YQ0/52Wg4pNMXASQohZh 9JDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=faCKmLSO; 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 rn4si9099536ejb.490.2020.08.25.06.39.46; Tue, 25 Aug 2020 06:40:09 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=faCKmLSO; 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 S1729843AbgHYMXM (ORCPT + 99 others); Tue, 25 Aug 2020 08:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728622AbgHYMXL (ORCPT ); Tue, 25 Aug 2020 08:23:11 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0565C061574 for ; Tue, 25 Aug 2020 05:23:10 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id y2so13574829ljc.1 for ; Tue, 25 Aug 2020 05:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=npQSbmA+gXwC9a6IjiIfcuykqKuVSdMx81JKlqg6LVc=; b=faCKmLSOHN+SDX9nwhCKULE+3ckPn/FX17L731HHYj1kzOtAgwPlIDGKrVcCuoibq+ Rpw4cT1mfRdK+vX/oFb23cmelGx0wHu0WU9m7zWCm/+TT++PB7PqQtSRPq3smaV3sRUq UFmuyxPxmRiLI5aT6bnjyu0wRwGcNWoiBlIKo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=npQSbmA+gXwC9a6IjiIfcuykqKuVSdMx81JKlqg6LVc=; b=JBjHYsUWvV96afR062o9VeAf/f7UQi4k6Al/VPmMesPv+byWaeObI+iGeFJ9iMNGzF Rho3ibbn7rPPZUY0uH5PVFz4seRvWWiO3FeFPZxFB7jfbrRK+Sya9l8Bf3zKgS7POSxl /jcnqHqSgc4P6MG4/JZxCM4pceixVdoVSRvxk9QyiS6qVr53U9YF4UzigxeVr6gIiuQT AZK1uqCkoqifnAxtYzTfysR2k6YSXzsuRuwVCnwYTAFnVbVBPQKt17OUYZP0jVy0ODEQ WJUMUEGWXm4U9N6q+/F92ZGvGMXEETiYHwL23s0rFfzYO0PAVGBo6x3r6xBjTIbBRj76 0hlw== X-Gm-Message-State: AOAM530vZclZJinCOjpRkpT6gRZiHE89ri5i4TmWqSga0JRXy3g2lF23 aMKczxdoheVE7Q/nW9Mi7VLKZJEe9Y7Vq08eDYA= X-Received: by 2002:a2e:99d5:: with SMTP id l21mr4452887ljj.320.1598358187525; Tue, 25 Aug 2020 05:23:07 -0700 (PDT) Received: from [172.16.11.132] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id 133sm2420706lfa.70.2020.08.25.05.23.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Aug 2020 05:23:07 -0700 (PDT) Subject: Re: [PATCH] checkpatch: Allow not using -f with files that are in git To: Joe Perches , Andrew Morton Cc: Andy Whitcroft , LKML References: <45b81a48e1568bd0126a96f5046eb7aaae9b83c9.camel@perches.com> From: Rasmus Villemoes Message-ID: <234290e5-b8dc-22c7-d26f-60a02844ce0a@rasmusvillemoes.dk> Date: Tue, 25 Aug 2020 14:23:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <45b81a48e1568bd0126a96f5046eb7aaae9b83c9.camel@perches.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Rasmus