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