xref: /optee_os/scripts/checkpatch_inc.sh (revision 5392ae31798372025be5b12ea372bc148c0a61dc)
11c93c2b5SIgor Opaniuk#!/bin/bash
21c93c2b5SIgor Opaniuk
3*5392ae31SAndrew F. DavisCHECKPATCH="${CHECKPATCH:-checkpatch.pl}"
41c93c2b5SIgor Opaniuk# checkpatch.pl will ignore the following paths
51c93c2b5SIgor OpaniukCHECKPATCH_IGNORE=$(echo core/lib/lib{fdt,tomcrypt} lib/lib{png,utils,zlib})
61c93c2b5SIgor Opaniuk_CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done)
71c93c2b5SIgor Opaniuk
81c93c2b5SIgor Opaniukfunction _checkpatch() {
91c93c2b5SIgor Opaniuk		$CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \
101c93c2b5SIgor Opaniuk				--ignore GERRIT_CHANGE_ID --no-tree -
111c93c2b5SIgor Opaniuk}
121c93c2b5SIgor Opaniuk
131c93c2b5SIgor Opaniukfunction checkpatch() {
141c93c2b5SIgor Opaniuk		git show --oneline --no-patch $1
151c93c2b5SIgor Opaniuk		git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch
161c93c2b5SIgor Opaniuk}
171c93c2b5SIgor Opaniuk
181c93c2b5SIgor Opaniukfunction checkstaging() {
191c93c2b5SIgor Opaniuk		git diff --cached -- . $_CP_EXCL | _checkpatch
201c93c2b5SIgor Opaniuk}
211c93c2b5SIgor Opaniuk
221c93c2b5SIgor Opaniukfunction checkworking() {
231c93c2b5SIgor Opaniuk		git diff -- . $_CP_EXCL | _checkpatch
241c93c2b5SIgor Opaniuk}
251c93c2b5SIgor Opaniuk
261c93c2b5SIgor Opaniukfunction checkdiff() {
271c93c2b5SIgor Opaniuk		git diff $1...$2 -- . $_CP_EXCL | _checkpatch
281c93c2b5SIgor Opaniuk}
291c93c2b5SIgor Opaniuk
30