xref: /optee_os/scripts/checkpatch_inc.sh (revision e39aae81e1a40ba495893f1c4e04b23401eca3a3)
1#!/bin/bash
2
3CHECKPATCH="${CHECKPATCH:-checkpatch.pl}"
4# checkpatch.pl will ignore the following paths
5CHECKPATCH_IGNORE=$(echo \
6		core/include/gen-asm-defines.h \
7		core/lib/lib{fdt,tomcrypt} core/lib/zlib \
8		lib/lib{png,utils,zlib} \
9		core/arch/arm/include/arm{32,64}.h \
10		core/arch/arm/plat-ti/api_monitor_index_a{9,15}.h)
11_CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done)
12
13function _checkpatch() {
14		# Use --typedefsfile if supported by the checkpatch tool
15		typedefs_opt="--typedefsfile typedefs.checkpatch"
16		$CHECKPATCH --help 2>&1 | grep -q -- --typedefsfile || \
17				typedefs_opt="";
18
19		$CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \
20				--ignore GERRIT_CHANGE_ID --no-tree \
21				$typedefs_opt \
22				-
23}
24
25function checkpatch() {
26		git show --oneline --no-patch $1
27		git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch
28}
29
30function checkstaging() {
31		git diff --cached -- . $_CP_EXCL | _checkpatch
32}
33
34function checkworking() {
35		git diff -- . $_CP_EXCL | _checkpatch
36}
37
38function checkdiff() {
39		git diff $1...$2 -- . $_CP_EXCL | _checkpatch
40}
41
42