qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2] checkpatch: add a little script to run checkpatc


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH v2] checkpatch: add a little script to run checkpatch against a git refspec
Date: Mon, 21 Jan 2013 13:20:02 -0600

This makes it easier to use checkpatch with a git hook or via patches.

Signed-off-by: Anthony Liguori <address@hidden>
---
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 <address@hidden>
+#
+# 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
-- 
1.8.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]