11c93c2b5SIgor Opaniuk#!/bin/bash 21c93c2b5SIgor Opaniuk 35392ae31SAndrew F. DavisCHECKPATCH="${CHECKPATCH:-checkpatch.pl}" 41c93c2b5SIgor Opaniuk# checkpatch.pl will ignore the following paths 5*b3be2f66SJerome ForissierCHECKPATCH_IGNORE=$(echo core/lib/lib{fdt,tomcrypt} core/lib/zlib \ 6*b3be2f66SJerome Forissier lib/lib{png,utils,zlib} \ 738f23772SAndrew F. Davis core/arch/arm/plat-ti/api_monitor_index_a{9,15}.h) 81c93c2b5SIgor Opaniuk_CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done) 91c93c2b5SIgor Opaniuk 101c93c2b5SIgor Opaniukfunction _checkpatch() { 11c1d47bcfSEtienne Carriere # Use --typedefsfile if supported by the checkpatch tool 12c1d47bcfSEtienne Carriere typedefs_opt="--typedefsfile typedefs.checkpatch" 13c1d47bcfSEtienne Carriere $CHECKPATCH --help 2>&1 | grep -q -- --typedefsfile || \ 14c1d47bcfSEtienne Carriere typedefs_opt=""; 15c1d47bcfSEtienne Carriere 161c93c2b5SIgor Opaniuk $CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \ 17c1d47bcfSEtienne Carriere --ignore GERRIT_CHANGE_ID --no-tree \ 18c1d47bcfSEtienne Carriere $typedefs_opt \ 19c1d47bcfSEtienne Carriere - 201c93c2b5SIgor Opaniuk} 211c93c2b5SIgor Opaniuk 221c93c2b5SIgor Opaniukfunction checkpatch() { 231c93c2b5SIgor Opaniuk git show --oneline --no-patch $1 241c93c2b5SIgor Opaniuk git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch 251c93c2b5SIgor Opaniuk} 261c93c2b5SIgor Opaniuk 271c93c2b5SIgor Opaniukfunction checkstaging() { 281c93c2b5SIgor Opaniuk git diff --cached -- . $_CP_EXCL | _checkpatch 291c93c2b5SIgor Opaniuk} 301c93c2b5SIgor Opaniuk 311c93c2b5SIgor Opaniukfunction checkworking() { 321c93c2b5SIgor Opaniuk git diff -- . $_CP_EXCL | _checkpatch 331c93c2b5SIgor Opaniuk} 341c93c2b5SIgor Opaniuk 351c93c2b5SIgor Opaniukfunction checkdiff() { 361c93c2b5SIgor Opaniuk git diff $1...$2 -- . $_CP_EXCL | _checkpatch 371c93c2b5SIgor Opaniuk} 381c93c2b5SIgor Opaniuk 39