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