From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzmLM-0003KA-6H for qemu-devel@nongnu.org; Wed, 04 Oct 2017 12:16:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzmLG-00033e-B3 for qemu-devel@nongnu.org; Wed, 04 Oct 2017 12:16:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzmLG-00032B-1r for qemu-devel@nongnu.org; Wed, 04 Oct 2017 12:16:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9749859FA for ; Wed, 4 Oct 2017 16:16:12 +0000 (UTC) Date: Wed, 4 Oct 2017 10:16:11 -0600 From: Alex Williamson Message-ID: <20171004101611.7c06009c@t450s.home> In-Reply-To: <4141ed57-05be-b60e-d66f-dd5fe08a2ac2@redhat.com> References: <1505824179-21541-1-git-send-email-pbonzini@redhat.com> <1505824179-21541-45-git-send-email-pbonzini@redhat.com> <20171003160706.2671a6ea@t450s.home> <20171004083329.GB17517@redhat.com> <20171004071735.66f20b86@t450s.home> <4141ed57-05be-b60e-d66f-dd5fe08a2ac2@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 44/50] scripts: let checkpatch.pl process an entire GIT branch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: "Daniel P. Berrange" , qemu-devel@nongnu.org On Wed, 4 Oct 2017 16:11:07 +0200 Paolo Bonzini wrote: > On 04/10/2017 15:17, Alex Williamson wrote: > > Yes, it works with the new --patch option. I use stgit which does > > not add a filename extension to the patch name on export, nor have I > > ever known patch files to have any accepted standard file extension. > > checkpatch.pl has always assumed it's operating on a patch file, as > > implied by the name of the script, with an option to check regular > > files. I'd suggest maintaining behavior consistent with the script name > > using more comprehensive heuristics than a non-standard file extension. > > Thanks, > > We are already limiting source files to only a handful of extensions, > perhaps we can reuse that in the DWIM mode selection code. While at it, > do not match "../foo" as a branch name: > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 3c0a28e644..9eca0f8458 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -11,6 +11,8 @@ use warnings; > my $P = $0; > $P =~ s@.*/@@g; > > +our $SrcFile = qr{\.(?:h|c|cpp|s|S|pl|py|sh)$}; > + > my $V = '0.31'; > > use Getopt::Long qw(:config no_auto_abbrev); > @@ -101,30 +103,29 @@ if ($#ARGV < 0) { > } > > if (!defined $chk_branch && !defined $chk_patch && !defined $file) { > - $chk_branch = $ARGV[0] =~ /\.\./ ? 1 : 0; > - $chk_patch = $chk_branch ? 0 : > - $ARGV[0] =~ /\.patch$/ || $ARGV[0] eq "-" ? 1 : 0; > - $file = $chk_branch || $chk_patch ? 0 : 1; > + $chk_branch = $ARGV[0] =~ /.\.\./ ? 1 : 0; > + $file = $ARGV[0] =~ /$SrcFile/ ? 1 : 0; > + $chk_patch = $chk_branch || $file ? 0 : 1; > } elsif (!defined $chk_branch && !defined $chk_patch) { > if ($file) { > $chk_branch = $chk_patch = 0; > } else { > - $chk_branch = $ARGV[0] =~ /\.\./ ? 1 : 0; > + $chk_branch = $ARGV[0] =~ /.\.\./ ? 1 : 0; > $chk_patch = $chk_branch ? 0 : 1; > } > } elsif (!defined $chk_branch && !defined $file) { > if ($chk_patch) { > $chk_branch = $file = 0; > } else { > - $chk_branch = $ARGV[0] =~ /\.\./ ? 1 : 0; > + $chk_branch = $ARGV[0] =~ /.\.\./ ? 1 : 0; > $file = $chk_branch ? 0 : 1; > } > } elsif (!defined $chk_patch && !defined $file) { > if ($chk_branch) { > $chk_patch = $file = 0; > } else { > - $chk_patch = $ARGV[0] =~ /\.patch$/ || $ARGV[0] eq "-" ? 1 : 0; > - $file = $chk_patch ? 0 : 1; > + $file = $ARGV[0] =~ /$SrcFile/ ? 1 : 0; > + $chk_patch = $file ? 0 : 1; > } > } elsif (!defined $chk_branch) { > $chk_branch = $chk_patch || $file ? 0 : 1; > @@ -1442,7 +1443,7 @@ sub process { > } > > # check we are in a valid source file if not then ignore this hunk > - next if ($realfile !~ /\.(h|c|cpp|s|S|pl|py|sh)$/); > + next if ($realfile !~ /$SrcFile/); > > #90 column limit > if ($line =~ /^\+/ && Thanks Paolo Tested-by: Alex Williamson