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