From patchwork Mon Jan 21 19:20:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 214244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2E7D2C007C for ; Tue, 22 Jan 2013 06:20:27 +1100 (EST) Received: from localhost ([::1]:37274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxMus-0005kR-TX for incoming@patchwork.ozlabs.org; Mon, 21 Jan 2013 14:20:22 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxMul-0005kH-BC for qemu-devel@nongnu.org; Mon, 21 Jan 2013 14:20:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxMuk-0003aV-3F for qemu-devel@nongnu.org; Mon, 21 Jan 2013 14:20:15 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:60766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxMuj-0003Yd-Vy for qemu-devel@nongnu.org; Mon, 21 Jan 2013 14:20:14 -0500 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Jan 2013 14:20:11 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 21 Jan 2013 14:20:08 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 357346E803A for ; Mon, 21 Jan 2013 14:20:06 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0LJK7TS338074 for ; Mon, 21 Jan 2013 14:20:07 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0LJK5K3021009 for ; Mon, 21 Jan 2013 14:20:06 -0500 Received: from titi.austin.rr.com (sig-9-65-136-57.mts.ibm.com [9.65.136.57]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0LJK23Z020842; Mon, 21 Jan 2013 14:20:03 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 21 Jan 2013 13:20:02 -0600 Message-Id: <1358796002-22995-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13012119-9360-0000-0000-00000F812550 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.138 Cc: Blue Swirl , Peter Maydell , Anthony Liguori Subject: [Qemu-devel] [PATCH v2] checkpatch: add a little script to run checkpatch against a git refspec X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This makes it easier to use checkpatch with a git hook or via patches. Signed-off-by: Anthony Liguori --- v1 -> v2 - Add the subject to the output to indicate which patch failed - Only display output for patches that fail the check --- scripts/check-patches.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/check-patches.sh diff --git a/scripts/check-patches.sh b/scripts/check-patches.sh new file mode 100755 index 0000000..14b1ff8 --- /dev/null +++ b/scripts/check-patches.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# checkpatch helper - run checkpatch against each commit given a refspec +# +# Copyright IBM, Corp. 2013 +# +# Authors: +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPLv2 or later. +# See the COPYING file in the top-level directory. + +if test -z "$1"; then + echo "Usage: $0 REFSPEC" + exit 1 +fi + +TMPFILE=/tmp/check-patches.out.$$ + +ret=0 +git log --format="%H %s" "$@" | while read LINE; do + commit="`echo $LINE | cut -f1 -d' '`" + subject="`echo $LINE | cut -f2- -d' '`" + echo "Subject: $subject" + git show --format=email $commit | scripts/checkpatch.pl - > $TMPFILE + + rc=$? + if test $rc -ne 0; then + ret=rc + cat $TMPFILE + echo + fi +done + +rm -f $TMPFILE