Igor Opaniuk | 1c93c2b | 2016-11-03 13:27:28 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Andrew F. Davis | 5392ae3 | 2016-11-15 11:59:35 -0600 | [diff] [blame] | 3 | CHECKPATCH="${CHECKPATCH:-checkpatch.pl}" |
Igor Opaniuk | 1c93c2b | 2016-11-03 13:27:28 +0200 | [diff] [blame] | 4 | # checkpatch.pl will ignore the following paths |
Andrew F. Davis | 5849875 | 2015-08-19 16:01:26 -0500 | [diff] [blame] | 5 | CHECKPATCH_IGNORE=$(echo core/lib/lib{fdt,tomcrypt} lib/lib{png,utils,zlib} \ |
Andrew F. Davis | 38f2377 | 2017-02-21 07:04:19 -0600 | [diff] [blame] | 6 | core/arch/arm/plat-ti/api_monitor_index_a{9,15}.h) |
Igor Opaniuk | 1c93c2b | 2016-11-03 13:27:28 +0200 | [diff] [blame] | 7 | _CP_EXCL=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done) |
| 8 | |
| 9 | function _checkpatch() { |
| 10 | $CHECKPATCH --quiet --ignore FILE_PATH_CHANGES \ |
Jerome Forissier | 1472c99 | 2017-05-10 10:41:48 +0200 | [diff] [blame] | 11 | --ignore GERRIT_CHANGE_ID \ |
| 12 | --typedefsfile typedefs.checkpatch --no-tree - |
Igor Opaniuk | 1c93c2b | 2016-11-03 13:27:28 +0200 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | function checkpatch() { |
| 16 | git show --oneline --no-patch $1 |
| 17 | git format-patch -1 $1 --stdout -- $_CP_EXCL . | _checkpatch |
| 18 | } |
| 19 | |
| 20 | function checkstaging() { |
| 21 | git diff --cached -- . $_CP_EXCL | _checkpatch |
| 22 | } |
| 23 | |
| 24 | function checkworking() { |
| 25 | git diff -- . $_CP_EXCL | _checkpatch |
| 26 | } |
| 27 | |
| 28 | function checkdiff() { |
| 29 | git diff $1...$2 -- . $_CP_EXCL | _checkpatch |
| 30 | } |
| 31 | |