blob: 487b60eb4d8a48b4c379fb10d9ae56af217364f2 [file] [log] [blame]
Igor Opaniuk1c93c2b2016-11-03 13:27:28 +02001#!/bin/bash
2
Andrew F. Davis5392ae32016-11-15 11:59:35 -06003CHECKPATCH="${CHECKPATCH:-checkpatch.pl}"
Igor Opaniuk1c93c2b2016-11-03 13:27:28 +02004# checkpatch.pl will ignore the following paths
5CHECKPATCH_IGNORE=$(echo core/lib/lib{fdt,tomcrypt} lib/lib{png,utils,zlib})
6_CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done)
7
8function _checkpatch() {
9 $CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \
10 --ignore GERRIT_CHANGE_ID --no-tree -
11}
12
13function checkpatch() {
14 git show --oneline --no-patch $1
15 git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch
16}
17
18function checkstaging() {
19 git diff --cached -- . $_CP_EXCL | _checkpatch
20}
21
22function checkworking() {
23 git diff -- . $_CP_EXCL | _checkpatch
24}
25
26function checkdiff() {
27 git diff $1...$2 -- . $_CP_EXCL | _checkpatch
28}
29