xref: /optee_os/scripts/checkpatch_inc.sh (revision 38f2377287f3f6dafde5200d4ad3f4762c530e1c)
11c93c2b5SIgor Opaniuk#!/bin/bash
21c93c2b5SIgor Opaniuk
35392ae31SAndrew F. DavisCHECKPATCH="${CHECKPATCH:-checkpatch.pl}"
41c93c2b5SIgor Opaniuk# checkpatch.pl will ignore the following paths
55849875fSAndrew F. DavisCHECKPATCH_IGNORE=$(echo core/lib/lib{fdt,tomcrypt} lib/lib{png,utils,zlib} \
6*38f23772SAndrew F. Davis		core/arch/arm/plat-ti/api_monitor_index_a{9,15}.h)
71c93c2b5SIgor Opaniuk_CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done)
81c93c2b5SIgor Opaniuk
91c93c2b5SIgor Opaniukfunction _checkpatch() {
101c93c2b5SIgor Opaniuk		$CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \
111c93c2b5SIgor Opaniuk				--ignore GERRIT_CHANGE_ID --no-tree -
121c93c2b5SIgor Opaniuk}
131c93c2b5SIgor Opaniuk
141c93c2b5SIgor Opaniukfunction checkpatch() {
151c93c2b5SIgor Opaniuk		git show --oneline --no-patch $1
161c93c2b5SIgor Opaniuk		git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch
171c93c2b5SIgor Opaniuk}
181c93c2b5SIgor Opaniuk
191c93c2b5SIgor Opaniukfunction checkstaging() {
201c93c2b5SIgor Opaniuk		git diff --cached -- . $_CP_EXCL | _checkpatch
211c93c2b5SIgor Opaniuk}
221c93c2b5SIgor Opaniuk
231c93c2b5SIgor Opaniukfunction checkworking() {
241c93c2b5SIgor Opaniuk		git diff -- . $_CP_EXCL | _checkpatch
251c93c2b5SIgor Opaniuk}
261c93c2b5SIgor Opaniuk
271c93c2b5SIgor Opaniukfunction checkdiff() {
281c93c2b5SIgor Opaniuk		git diff $1...$2 -- . $_CP_EXCL | _checkpatch
291c93c2b5SIgor Opaniuk}
301c93c2b5SIgor Opaniuk
31