{"id":812767,"url":"http://patchwork.ozlabs.org/api/1.2/patches/812767/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170912104626.8386-1-berrange@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170912104626.8386-1-berrange@redhat.com>","list_archive_url":null,"date":"2017-09-12T10:46:26","name":"scripts: let checkpatch.pl process an entire GIT branch","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7fd0521fa5e68397c4669e6527e479bf7845262f","submitter":{"id":2694,"url":"http://patchwork.ozlabs.org/api/1.2/people/2694/?format=json","name":"Daniel P. Berrangé","email":"berrange@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170912104626.8386-1-berrange@redhat.com/mbox/","series":[{"id":2661,"url":"http://patchwork.ozlabs.org/api/1.2/series/2661/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2661","date":"2017-09-12T10:46:26","name":"scripts: let checkpatch.pl process an entire GIT branch","version":1,"mbox":"http://patchwork.ozlabs.org/series/2661/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812767/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812767/checks/","tags":{},"related":[],"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-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.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 3xs1jL09qrz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 20:48:04 +1000 (AEST)","from localhost ([::1]:34853 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 1drija-0005KC-Km\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 06:48:02 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:41619)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1driiD-0004tr-Hq\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 06:46:38 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <berrange@redhat.com>) id 1drii7-0006G9-EC\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 06:46:37 -0400","from mx1.redhat.com ([209.132.183.28]:41024)\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 1drii7-0006Fk-6f\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 06:46:31 -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 391AB5F73A\n\tfor <qemu-devel@nongnu.org>; Tue, 12 Sep 2017 10:46:30 +0000 (UTC)","from localhost.localdomain.com (unknown [10.42.22.189])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 653086C930;\n\tTue, 12 Sep 2017 10:46:29 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 391AB5F73A","From":"\"Daniel P. Berrange\" <berrange@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Tue, 12 Sep 2017 11:46:26 +0100","Message-Id":"<20170912104626.8386-1-berrange@redhat.com>","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.39]);\n\tTue, 12 Sep 2017 10:46:30 +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":"[Qemu-devel] [PATCH] scripts: let checkpatch.pl process an entire\n\tGIT 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":"Paolo Bonzini <pbonzini@redhat.com>,\n\tMarkus 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>"},"content":"Currently before submitting a series, devs should run checkpatch.pl\nacross each patch to be submitted. This can be automated using a\ncommand such as:\n\n  git rebase -i master -x 'git show | ./scripts/checkpatch.pl -'\n\nThis is rather long winded to type, so this patch introduces a new\nflag '--branch' to checkpatch.pl which instructs it to check every\npatch on the current GIT branch.\n\nFor example:\n\n    $ ./scripts/checkpatch.pl --branch\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\nBy default it checks every patch identified by 'master..', however,\nan alternative origin can be given if desired, if the current branch\nis rebased to another non-master branch:\n\n    $ ./scripts/checkpatch.pl --branch somebranch..\n\nSigned-off-by: Daniel P. Berrange <berrange@redhat.com>\n---\n scripts/checkpatch.pl | 97 +++++++++++++++++++++++++++++++++++++--------------\n 1 file changed, 71 insertions(+), 26 deletions(-)","diff":"diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl\nindex fa478074b8..f8d080441f 100755\n--- a/scripts/checkpatch.pl\n+++ b/scripts/checkpatch.pl\n@@ -19,6 +19,8 @@ my $quiet = 0;\n my $tree = 1;\n my $chk_signoff = 1;\n my $chk_patch = 1;\n+my $chk_branch = 0;\n+my $revlist = \"master..\";\n my $tst_only;\n my $emacs = 0;\n my $terse = 0;\n@@ -43,6 +45,7 @@ Options:\n   --no-tree                  run without a kernel tree\n   --no-signoff               do not check for 'Signed-off-by' line\n   --patch                    treat FILE as patchfile (default)\n+  --branch                   check all patches on branch since master\n   --emacs                    emacs compile window format\n   --terse                    one line per report\n   -f, --file                 treat FILE as regular source file\n@@ -69,6 +72,7 @@ GetOptions(\n \t'tree!'\t\t=> \\$tree,\n \t'signoff!'\t=> \\$chk_signoff,\n \t'patch!'\t=> \\$chk_patch,\n+\t'branch'\t=> \\$chk_branch,\n \t'emacs!'\t=> \\$emacs,\n \t'terse!'\t=> \\$terse,\n \t'f|file!'\t=> \\$file,\n@@ -88,9 +92,19 @@ help(0) if ($help);\n \n my $exit = 0;\n \n-if ($#ARGV < 0) {\n-\tprint \"$P: no input files\\n\";\n-\texit(1);\n+if ($chk_branch) {\n+\tif ($#ARGV > 0) {\n+\t\tprint \"$P: expected zero or one origni revisions\\n\";\n+\t\texit(1);\n+\t}\n+\tif ($#ARGV == 0) {\n+\t\t$revlist = shift @ARGV;\n+\t}\n+} else {\n+\tif ($#ARGV < 0) {\n+\t\tprint \"$P: no input files\\n\";\n+\t\texit(1);\n+\t}\n }\n \n my $dbg_values = 0;\n@@ -251,32 +265,63 @@ $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\", $revlist) ||\n+\t\tdie \"$P: git log --format=%H $revlist 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+\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","prefixes":[]}