From nobody Tue Nov 4 00:09:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505235579053879.327973440653; Tue, 12 Sep 2017 09:59:39 -0700 (PDT) Received: from localhost ([::1]:37652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1droXC-0001VQ-29 for importer@patchew.org; Tue, 12 Sep 2017 12:59:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1droPb-0002nt-EL for qemu-devel@nongnu.org; Tue, 12 Sep 2017 12:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1droPY-0007qc-56 for qemu-devel@nongnu.org; Tue, 12 Sep 2017 12:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1droPX-0007q6-TX for qemu-devel@nongnu.org; Tue, 12 Sep 2017 12:51:44 -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 E748C5F7A9 for ; Tue, 12 Sep 2017 16:51:42 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CB9E77DE3; Tue, 12 Sep 2017 16:51:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E748C5F7A9 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Tue, 12 Sep 2017 17:51:39 +0100 Message-Id: <20170912165139.16212-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 12 Sep 2017 16:51:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2] scripts: let checkpatch.pl process an entire GIT branch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently before submitting a series, devs should run checkpatch.pl across each patch to be submitted. This can be automated using a command such as: git rebase -i master -x 'git show | ./scripts/checkpatch.pl -' This is rather long winded to type, so this patch introduces a way to tell checkpatch.pl to validate a series of GIT revisions. If checkpatch.pl is given a single argument that contains a literal '..', this is interpreted as a GIT revision list. For example: $ ./scripts/checkpatch.pl master.. total: 0 errors, 0 warnings, 297 lines checked b886d352a2bf58f0996471fb3991a138373a2957 has no obvious style problems = and is ready for submission. total: 0 errors, 0 warnings, 182 lines checked 2a731f9a9ce145e0e0df6d42dd2a3ce4dfc543fa has no obvious style problems = and is ready for submission. total: 0 errors, 0 warnings, 102 lines checked 11844169bcc0c8ed4449eb3744a69877ed329dd7 has no obvious style problems = and is ready for submission. If a genuine patch filename contains the characters '..' it is possible to force interpretation of the arg as a patch $ ./scripts/checkpatch.pl --patch master.. will force it to load a patch file called "master.." Signed-off-by: Daniel P. Berrange --- scripts/checkpatch.pl | 102 +++++++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 77 insertions(+), 25 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index fa478074b8..213777d488 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -18,7 +18,8 @@ use Getopt::Long qw(:config no_auto_abbrev); my $quiet =3D 0; my $tree =3D 1; my $chk_signoff =3D 1; -my $chk_patch =3D 1; +my $chk_patch =3D undef; +my $chk_branch =3D undef; my $tst_only; my $emacs =3D 0; my $terse =3D 0; @@ -35,7 +36,11 @@ sub help { my ($exitcode) =3D @_; =20 print << "EOM"; -Usage: $P [OPTION]... [FILE]... +Usage: + + $P [OPTION]... [FILE]... + $P [OPTION]... [GIT-REV-LIST] + Version: $V =20 Options: @@ -88,6 +93,19 @@ help(0) if ($help); =20 my $exit =3D 0; =20 +if (!defined $chk_patch) { + if (!$file) { + if ($#ARGV =3D=3D 0 && $ARGV[0] =3D~ /\.\./) { + $chk_branch =3D $ARGV[0]; + $chk_patch =3D 0; + } else { + $chk_patch =3D 1; + } + } else { + $chk_patch =3D 0; + } +} + if ($#ARGV < 0) { print "$P: no input files\n"; exit(1); @@ -251,32 +269,66 @@ $chk_signoff =3D 0 if ($file); my @rawlines =3D (); my @lines =3D (); my $vname; -for my $filename (@ARGV) { - my $FILE; - if ($file) { - open($FILE, '-|', "diff -u /dev/null $filename") || - die "$P: $filename: diff failed - $!\n"; - } elsif ($filename eq '-') { - open($FILE, '<&STDIN'); - } else { - open($FILE, '<', "$filename") || - die "$P: $filename: open failed - $!\n"; - } - if ($filename eq '-') { - $vname =3D 'Your patch'; - } else { - $vname =3D $filename; - } - while (<$FILE>) { +if ($chk_branch) { + my @patches; + my $HASH; + open($HASH, "-|", "git", "log", "--format=3D%H", $chk_branch) || + die "$P: git log --format=3D%H $chk_branch failed - $!\n"; + + while (<$HASH>) { chomp; - push(@rawlines, $_); + push @patches, $_; } - close($FILE); - if (!process($filename)) { - $exit =3D 1; + + close $HASH; + + die "$P: no revisions returned for revlist '$chk_branch'\n" + unless @patches; + + for my $hash (@patches) { + my $FILE; + open($FILE, '-|', "git", "show", $hash) || + die "$P: git show $hash - $!\n"; + $vname =3D $hash; + while (<$FILE>) { + chomp; + push(@rawlines, $_); + } + close($FILE); + if (!process($hash)) { + $exit =3D 1; + } + @rawlines =3D (); + @lines =3D (); + } +} else { + for my $filename (@ARGV) { + my $FILE; + if ($file) { + open($FILE, '-|', "diff -u /dev/null $filename") || + die "$P: $filename: diff failed - $!\n"; + } elsif ($filename eq '-') { + open($FILE, '<&STDIN'); + } else { + open($FILE, '<', "$filename") || + die "$P: $filename: open failed - $!\n"; + } + if ($filename eq '-') { + $vname =3D 'Your patch'; + } else { + $vname =3D $filename; + } + while (<$FILE>) { + chomp; + push(@rawlines, $_); + } + close($FILE); + if (!process($filename)) { + $exit =3D 1; + } + @rawlines =3D (); + @lines =3D (); } - @rawlines =3D (); - @lines =3D (); } =20 exit($exit); --=20 2.13.5