Martin Roth | 0ad5fbd | 2020-12-24 12:06:38 -0700 | [diff] [blame] | 1 | #!/usr/bin/env sh |
Patrick Georgi | d13e416 | 2012-02-16 20:28:42 +0100 | [diff] [blame] | 2 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
Patrick Georgi | d13e416 | 2012-02-16 20:28:42 +0100 | [diff] [blame] | 5 | # DESCR: Check for superfluous whitespace in the tree |
| 6 | |
| 7 | LC_ALL=C export LC_ALL |
Martin Roth | ee0f225 | 2018-09-01 17:13:38 -0600 | [diff] [blame] | 8 | EXCLUDELIST='^src/vendorcode/|^util/kconfig/|^util/nvidia/cbootimage$|COPYING|LICENSE|README|_shipped$|\.patch$|\.bin$|\.hex$|\.jpg$|\.ttf$|\.woff$|\.png$|\.eot$|\.vbt$|\.ico$' |
Jan Dabros | ffa58cf | 2020-07-16 13:38:01 +0200 | [diff] [blame] | 9 | INCLUDELIST="src util payloads Makefile* toolchain.inc tests" |
Martin Roth | 8600893 | 2018-09-01 14:54:33 -0600 | [diff] [blame] | 10 | |
| 11 | # shellcheck disable=SC2086,SC2046 |
| 12 | if uname | grep -qi "linux"; then |
Balazs Vinarz | 28def8b | 2019-01-18 11:23:29 +0100 | [diff] [blame] | 13 | grep -n -H "[[:space:]][[:space:]]*$" \ |
Martin Roth | 8600893 | 2018-09-01 14:54:33 -0600 | [diff] [blame] | 14 | $(git ls-files $INCLUDELIST | \ |
| 15 | grep -Ev "($EXCLUDELIST)" ) | \ |
| 16 | sed -e "s,^.*$,File & has lines ending with whitespace.," |
| 17 | else |
| 18 | # The above form is much (100x) faster, but doesn't work |
| 19 | # on all systems. A for loop also works but takes 30% longer |
| 20 | git ls-files $INCLUDELIST | \ |
| 21 | grep -Ev "($EXCLUDELIST)" | \ |
| 22 | xargs -I % \ |
| 23 | grep -l "[[:space:]][[:space:]]*$" % | \ |
| 24 | sed -e "s,^.*$,File & has lines ending with whitespace.," |
| 25 | fi |