Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2521411pxa; Mon, 24 Aug 2020 17:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwDP3ranb2Eskr2gqvDDZi2HLg5Wh/hGjrycELwylvr1CtLkJXHGWxXj+PqRKlhanrv2fU X-Received: by 2002:a17:906:4ec3:: with SMTP id i3mr7773449ejv.215.1598314359125; Mon, 24 Aug 2020 17:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598314359; cv=none; d=google.com; s=arc-20160816; b=p2NzLWbGdgBRlbikthMpsmVkoH6WfRtv2qUqEUBKKMkRxKIVHKYIURan8ZzojVeZUZ m9Kmo8KgMQXoVzsczQSYGS7I8PyNdBSOxUmDIj3U6NgyjMSUp65Yfnx2ZJtuj3Uptc8h 6EIuGyV5ihFuZfWaG6qohfMRZqGCjoLfJ2qW99bNC6dLxGnf50z2gFRDMWtZMGD+sNlR PZ84yiiA6BerB0WCEn5blJt9j5GjBXL8rXQ7uGx/F6hT1XTJ/yrQz8U47PuoVfhl8lKn bvaObkHc1df8egJOXeJAwVBzMdtLmUBqV9LEHXBP/ViTF1dLGOTwFW4YFvOe0wQjsntP FIIw== 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:date:cc:to:from:subject:message-id; bh=hB8cUgF1IKfW0GSkclwPnf5Q0GQlsouvCRBMHxhcuj4=; b=n8PW5adw+71NDR4zr25yIgLVL1yGuqkbhfdpByYby6yiwN6P/s4vci9Nlf7F5cIeIC Qr/O3jcMtxph9TPTfYu8cmFa4z2w9xLIM43z5pMFYMjIs1UH37j6yD6krkZ7Fp32pKza ENNXxTRDjKJ0YTiGCgAfIaLgqX2Rxw15XU5tW4u1ezJ2rex2whI4fKLdYbIMr9/Gj/yq +E0KXrAYXwsyjXTTma+SoXrbnrtMWbumfhjoi5HOUeFF5TNJo34R6FlKoNMcNLR2O8kw mQ06izz2kNLe3edYIELJf4IAbjD51fmw57y0+I0WVL0veZUHWkKHIe+FnxGLzrwFctkG l4Ng== 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 i7si7828219ejf.217.2020.08.24.17.12.16; Mon, 24 Aug 2020 17:12:39 -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 S1727823AbgHYAJS (ORCPT + 99 others); Mon, 24 Aug 2020 20:09:18 -0400 Received: from smtprelay0235.hostedemail.com ([216.40.44.235]:52432 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726189AbgHYAJS (ORCPT ); Mon, 24 Aug 2020 20:09:18 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 82CB9100E7B44; Tue, 25 Aug 2020 00:09:17 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3653:3865:3867:3868:3870:3871:3872:4321:5007:6299:7903:8957:9163:10004:10400:10848:11026:11473:11658:11914:12043:12297:12438:12555:12679:12760:13069:13311:13357:13439:14181:14394:14659:14721:21063:21080:21451:21627:21990:30054:30070:30080,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: hen06_14153db27057 X-Filterd-Recvd-Size: 2241 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Tue, 25 Aug 2020 00:09:16 +0000 (UTC) Message-ID: <45b81a48e1568bd0126a96f5046eb7aaae9b83c9.camel@perches.com> Subject: [PATCH] checkpatch: Allow not using -f with files that are in git From: Joe Perches To: Andrew Morton Cc: Andy Whitcroft , LKML Date: Mon, 24 Aug 2020 17:09:15 -0700 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 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. Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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}$}; +} + sub git_commit_info { my ($commit, $id, $desc) = @_; @@ -1049,6 +1059,9 @@ my $vname; $allow_c99_comments = !defined $ignore_type{"C99_COMMENT_TOLERANCE"}; for my $filename (@ARGV) { my $FILE; + my $is_git_file = git_is_single_file($filename); + my $oldfile = $file; + $file = 1 if ($is_git_file); if ($git) { open($FILE, '-|', "git format-patch -M --stdout -1 $filename") || die "$P: $filename: git format-patch failed - $!\n"; @@ -1093,6 +1106,7 @@ for my $filename (@ARGV) { @modifierListFile = (); @typeListFile = (); build_types(); + $file = $oldfile if ($is_git_file); } if (!$quiet) {