blob: 7cb2de4c42cd4d4258954458f14b50015fdd565d [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
Andrew F. Davis58498752015-08-19 16:01:26 -05005CHECKPATCH_IGNORE=$(echo core/lib/lib{fdt,tomcrypt} lib/lib{png,utils,zlib} \
Andrew F. Davis38f23772017-02-21 07:04:19 -06006 core/arch/arm/plat-ti/api_monitor_index_a{9,15}.h)
Igor Opaniuk1c93c2b2016-11-03 13:27:28 +02007_CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done)
8
9function _checkpatch() {
Etienne Carrierec1d47bc2017-05-15 11:41:23 +020010 # Use --typedefsfile if supported by the checkpatch tool
11 typedefs_opt="--typedefsfile typedefs.checkpatch"
12 $CHECKPATCH --help 2>&1 | grep -q -- --typedefsfile || \
13 typedefs_opt="";
14
Igor Opaniuk1c93c2b2016-11-03 13:27:28 +020015 $CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \
Etienne Carrierec1d47bc2017-05-15 11:41:23 +020016 --ignore GERRIT_CHANGE_ID --no-tree \
17 $typedefs_opt \
18 -
Igor Opaniuk1c93c2b2016-11-03 13:27:28 +020019}
20
21function checkpatch() {
22 git show --oneline --no-patch $1
23 git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch
24}
25
26function checkstaging() {
27 git diff --cached -- . $_CP_EXCL | _checkpatch
28}
29
30function checkworking() {
31 git diff -- . $_CP_EXCL | _checkpatch
32}
33
34function checkdiff() {
35 git diff $1...$2 -- . $_CP_EXCL | _checkpatch
36}
37