[{"id":1767259,"web_url":"http://patchwork.ozlabs.org/comment/1767259/","msgid":"<1a39aeeb-1362-4fdb-4bee-b11a258954f5@redhat.com>","list_archive_url":null,"date":"2017-09-12T17:11:34","subject":"Re: [Qemu-devel] [PATCH v2] scripts: let checkpatch.pl process an\n\tentire GIT branch","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"content":"On 12/09/2017 18:51, Daniel P. Berrange wrote:\n> Currently before submitting a series, devs should run checkpatch.pl\n> across each patch to be submitted. This can be automated using a\n> command such as:\n> \n>   git rebase -i master -x 'git show | ./scripts/checkpatch.pl -'\n> \n> This is rather long winded to type, so this patch introduces a way\n> to tell checkpatch.pl to validate a series of GIT revisions.\n> \n> If checkpatch.pl is given a single argument that contains a literal\n> '..', this is interpreted as a GIT revision list.\n> \n> For example:\n> \n>     $ ./scripts/checkpatch.pl master..\n>     total: 0 errors, 0 warnings, 297 lines checked\n> \n>     b886d352a2bf58f0996471fb3991a138373a2957 has no obvious style problems and is ready for submission.\n>     total: 0 errors, 0 warnings, 182 lines checked\n> \n>     2a731f9a9ce145e0e0df6d42dd2a3ce4dfc543fa has no obvious style problems and is ready for submission.\n>     total: 0 errors, 0 warnings, 102 lines checked\n> \n>     11844169bcc0c8ed4449eb3744a69877ed329dd7 has no obvious style problems and is ready for submission.\n> \n> If a genuine patch filename contains the characters '..' it is\n> possible to force interpretation of the arg as a patch\n> \n>   $ ./scripts/checkpatch.pl --patch master..\n> \n> will force it to load a patch file called \"master..\"\n\nLooks good, but why no --branch anymore? :)  (I can also try adding it\nback on top).\n\nPaolo\n\n> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>\n> ---\n>  scripts/checkpatch.pl | 102 +++++++++++++++++++++++++++++++++++++-------------\n>  1 file changed, 77 insertions(+), 25 deletions(-)\n> \n> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl\n> index fa478074b8..213777d488 100755\n> --- a/scripts/checkpatch.pl\n> +++ b/scripts/checkpatch.pl\n> @@ -18,7 +18,8 @@ use Getopt::Long qw(:config no_auto_abbrev);\n>  my $quiet = 0;\n>  my $tree = 1;\n>  my $chk_signoff = 1;\n> -my $chk_patch = 1;\n> +my $chk_patch = undef;\n> +my $chk_branch = undef;\n>  my $tst_only;\n>  my $emacs = 0;\n>  my $terse = 0;\n> @@ -35,7 +36,11 @@ sub help {\n>  \tmy ($exitcode) = @_;\n>  \n>  \tprint << \"EOM\";\n> -Usage: $P [OPTION]... [FILE]...\n> +Usage:\n> +\n> +    $P [OPTION]... [FILE]...\n> +    $P [OPTION]... [GIT-REV-LIST]\n> +\n>  Version: $V\n>  \n>  Options:\n> @@ -88,6 +93,19 @@ help(0) if ($help);\n>  \n>  my $exit = 0;\n>  \n> +if (!defined $chk_patch) {\n> +    if (!$file) {\n> +\tif ($#ARGV == 0 && $ARGV[0] =~ /\\.\\./) {\n> +\t    $chk_branch = $ARGV[0];\n> +\t    $chk_patch = 0;\n> +\t} else {\n> +\t    $chk_patch = 1;\n> +\t}\n> +    } else {\n> +\t$chk_patch = 0;\n> +    }\n> +}\n> +\n>  if ($#ARGV < 0) {\n>  \tprint \"$P: no input files\\n\";\n>  \texit(1);\n> @@ -251,32 +269,66 @@ $chk_signoff = 0 if ($file);\n>  my @rawlines = ();\n>  my @lines = ();\n>  my $vname;\n> -for my $filename (@ARGV) {\n> -\tmy $FILE;\n> -\tif ($file) {\n> -\t\topen($FILE, '-|', \"diff -u /dev/null $filename\") ||\n> -\t\t\tdie \"$P: $filename: diff failed - $!\\n\";\n> -\t} elsif ($filename eq '-') {\n> -\t\topen($FILE, '<&STDIN');\n> -\t} else {\n> -\t\topen($FILE, '<', \"$filename\") ||\n> -\t\t\tdie \"$P: $filename: open failed - $!\\n\";\n> -\t}\n> -\tif ($filename eq '-') {\n> -\t\t$vname = 'Your patch';\n> -\t} else {\n> -\t\t$vname = $filename;\n> -\t}\n> -\twhile (<$FILE>) {\n> +if ($chk_branch) {\n> +\tmy @patches;\n> +\tmy $HASH;\n> +\topen($HASH, \"-|\", \"git\", \"log\", \"--format=%H\", $chk_branch) ||\n> +\t\tdie \"$P: git log --format=%H $chk_branch failed - $!\\n\";\n> +\n> +\twhile (<$HASH>) {\n>  \t\tchomp;\n> -\t\tpush(@rawlines, $_);\n> +\t\tpush @patches, $_;\n>  \t}\n> -\tclose($FILE);\n> -\tif (!process($filename)) {\n> -\t\t$exit = 1;\n> +\n> +\tclose $HASH;\n> +\n> +\tdie \"$P: no revisions returned for revlist '$chk_branch'\\n\"\n> +\t    unless @patches;\n> +\n> +\tfor my $hash (@patches) {\n> +\t\tmy $FILE;\n> +\t\topen($FILE, '-|', \"git\", \"show\", $hash) ||\n> +\t\t\tdie \"$P: git show $hash - $!\\n\";\n> +\t\t$vname = $hash;\n> +\t\twhile (<$FILE>) {\n> +\t\t\tchomp;\n> +\t\t\tpush(@rawlines, $_);\n> +\t\t}\n> +\t\tclose($FILE);\n> +\t\tif (!process($hash)) {\n> +\t\t\t$exit = 1;\n> +\t\t}\n> +\t\t@rawlines = ();\n> +\t\t@lines = ();\n> +\t}\n> +} else {\n> +\tfor my $filename (@ARGV) {\n> +\t\tmy $FILE;\n> +\t\tif ($file) {\n> +\t\t\topen($FILE, '-|', \"diff -u /dev/null $filename\") ||\n> +\t\t\t\tdie \"$P: $filename: diff failed - $!\\n\";\n> +\t\t} elsif ($filename eq '-') {\n> +\t\t\topen($FILE, '<&STDIN');\n> +\t\t} else {\n> +\t\t\topen($FILE, '<', \"$filename\") ||\n> +\t\t\t\tdie \"$P: $filename: open failed - $!\\n\";\n> +\t\t}\n> +\t\tif ($filename eq '-') {\n> +\t\t\t$vname = 'Your patch';\n> +\t\t} else {\n> +\t\t\t$vname = $filename;\n> +\t\t}\n> +\t\twhile (<$FILE>) {\n> +\t\t\tchomp;\n> +\t\t\tpush(@rawlines, $_);\n> +\t\t}\n> +\t\tclose($FILE);\n> +\t\tif (!process($filename)) {\n> +\t\t\t$exit = 1;\n> +\t\t}\n> +\t\t@rawlines = ();\n> +\t\t@lines = ();\n>  \t}\n> -\t@rawlines = ();\n> -\t@lines = ();\n>  }\n>  \n>  exit($exit);\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=pbonzini@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xsBDm04k8z9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 03:12:23 +1000 (AEST)","from localhost ([::1]:37712 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drojU-0007N7-Jk\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 13:12:20 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:45858)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1droj2-0007MZ-Uc\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 13:11:54 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbonzini@redhat.com>) id 1droiz-0005t9-O3\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 13:11:52 -0400","from mx1.redhat.com ([209.132.183.28]:40304)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pbonzini@redhat.com>) id 1droiz-0005sU-Ef\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 13:11:49 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 4BD4381DED\n\tfor <qemu-devel@nongnu.org>; Tue, 12 Sep 2017 17:11:48 +0000 (UTC)","from [10.36.117.43] (ovpn-117-43.ams2.redhat.com [10.36.117.43])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 12E815D6A6;\n\tTue, 12 Sep 2017 17:11:39 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 4BD4381DED","To":"\"Daniel P. Berrange\" <berrange@redhat.com>, qemu-devel@nongnu.org","References":"<20170912165139.16212-1-berrange@redhat.com>","From":"Paolo Bonzini <pbonzini@redhat.com>","Message-ID":"<1a39aeeb-1362-4fdb-4bee-b11a258954f5@redhat.com>","Date":"Tue, 12 Sep 2017 19:11:34 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170912165139.16212-1-berrange@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tTue, 12 Sep 2017 17:11:48 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2] scripts: let checkpatch.pl process an\n\tentire GIT branch","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Markus Armbruster <armbru@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1767661,"web_url":"http://patchwork.ozlabs.org/comment/1767661/","msgid":"<20170913080547.GA3067@redhat.com>","list_archive_url":null,"date":"2017-09-13T08:05:47","subject":"Re: [Qemu-devel] [PATCH v2] scripts: let checkpatch.pl process an\n\tentire GIT branch","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/people/2694/","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"content":"On Tue, Sep 12, 2017 at 07:11:34PM +0200, Paolo Bonzini wrote:\n> On 12/09/2017 18:51, Daniel P. Berrange wrote:\n> > Currently before submitting a series, devs should run checkpatch.pl\n> > across each patch to be submitted. This can be automated using a\n> > command such as:\n> > \n> >   git rebase -i master -x 'git show | ./scripts/checkpatch.pl -'\n> > \n> > This is rather long winded to type, so this patch introduces a way\n> > to tell checkpatch.pl to validate a series of GIT revisions.\n> > \n> > If checkpatch.pl is given a single argument that contains a literal\n> > '..', this is interpreted as a GIT revision list.\n> > \n> > For example:\n> > \n> >     $ ./scripts/checkpatch.pl master..\n> >     total: 0 errors, 0 warnings, 297 lines checked\n> > \n> >     b886d352a2bf58f0996471fb3991a138373a2957 has no obvious style problems and is ready for submission.\n> >     total: 0 errors, 0 warnings, 182 lines checked\n> > \n> >     2a731f9a9ce145e0e0df6d42dd2a3ce4dfc543fa has no obvious style problems and is ready for submission.\n> >     total: 0 errors, 0 warnings, 102 lines checked\n> > \n> >     11844169bcc0c8ed4449eb3744a69877ed329dd7 has no obvious style problems and is ready for submission.\n> > \n> > If a genuine patch filename contains the characters '..' it is\n> > possible to force interpretation of the arg as a patch\n> > \n> >   $ ./scripts/checkpatch.pl --patch master..\n> > \n> > will force it to load a patch file called \"master..\"\n> \n> Looks good, but why no --branch anymore? :)  (I can also try adding it\n> back on top).\n\nIt felt redundant to me. I guess it could be used to force interpretation\nof the arg as a git revlist, even if it lacks '..' ?\n\n\nRegards,\nDaniel","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=berrange@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xsZ4D0lyqz9sPs\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 18:06:18 +1000 (AEST)","from localhost ([::1]:40778 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1ds2gZ-0007Xd-MS\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 04:06:15 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:53020)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1ds2gF-0007XT-Qt\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 04:05:56 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1ds2gC-0006wE-D7\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 04:05:55 -0400","from mx1.redhat.com ([209.132.183.28]:35042)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <berrange@redhat.com>) id 1ds2gC-0006vU-32\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 04:05:52 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 0844F356CD\n\tfor <qemu-devel@nongnu.org>; Wed, 13 Sep 2017 08:05:51 +0000 (UTC)","from redhat.com (unknown [10.33.36.24])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id EF7215F935;\n\tWed, 13 Sep 2017 08:05:49 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 0844F356CD","Date":"Wed, 13 Sep 2017 09:05:47 +0100","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"Paolo Bonzini <pbonzini@redhat.com>","Message-ID":"<20170913080547.GA3067@redhat.com>","References":"<20170912165139.16212-1-berrange@redhat.com>\n\t<1a39aeeb-1362-4fdb-4bee-b11a258954f5@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<1a39aeeb-1362-4fdb-4bee-b11a258954f5@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tWed, 13 Sep 2017 08:05:51 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2] scripts: let checkpatch.pl process an\n\tentire GIT branch","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Reply-To":"\"Daniel P. Berrange\" <berrange@redhat.com>","Cc":"qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]