blob: fd4d0e4d12ef9f4e9d81aaa518bfd0c40f3e4ca2 [file] [log] [blame]
Martin Roth0ad5fbd2020-12-24 12:06:38 -07001#!/usr/bin/env sh
Patrick Georgid13e4162012-02-16 20:28:42 +01002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
4
Patrick Georgid13e4162012-02-16 20:28:42 +01005# DESCR: Check for superfluous whitespace in the tree
6
7LC_ALL=C export LC_ALL
Martin Rothee0f2252018-09-01 17:13:38 -06008EXCLUDELIST='^src/vendorcode/|^util/kconfig/|^util/nvidia/cbootimage$|COPYING|LICENSE|README|_shipped$|\.patch$|\.bin$|\.hex$|\.jpg$|\.ttf$|\.woff$|\.png$|\.eot$|\.vbt$|\.ico$'
Jan Dabrosffa58cf2020-07-16 13:38:01 +02009INCLUDELIST="src util payloads Makefile* toolchain.inc tests"
Martin Roth86008932018-09-01 14:54:33 -060010
11# shellcheck disable=SC2086,SC2046
12if uname | grep -qi "linux"; then
Balazs Vinarz28def8b2019-01-18 11:23:29 +010013 grep -n -H "[[:space:]][[:space:]]*$" \
Martin Roth86008932018-09-01 14:54:33 -060014 $(git ls-files $INCLUDELIST | \
15 grep -Ev "($EXCLUDELIST)" ) | \
16 sed -e "s,^.*$,File & has lines ending with whitespace.,"
17else
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.,"
25fi