summaryrefslogtreecommitdiff
path: root/util/lint/lint-extended-015-final-newlines
diff options
context:
space:
mode:
authorAlex Thiessen <alex.thiessen.de+coreboot@gmail.com>2018-01-16 23:05:48 +0000
committerMartin Roth <martinroth@google.com>2018-01-23 05:42:51 +0000
commit73f19dca386d775a880bdc945efaa6b9c77d9e94 (patch)
treeb7814be8453de7044ad8078fc048aae2514ec5d4 /util/lint/lint-extended-015-final-newlines
parent583e0522f14fde040f48d2444099e4dededfa185 (diff)
util/lint: Unify checks for git worktree
Linters try to determine whether they are running in a git worktree so that `git grep` can be used instead of `grep`. These checks are done in different not truly correct ways and thus the linters don't use `git grep` when running from a worktree subdirectory, e.g. in a git subtree environment. Unify checks using `git rev-parse --is-inside-work-tree`. Change-Id: I3f54afc99ad0f0e3052cffdd32bdd9649cf3d720 Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com> Reviewed-on: https://review.coreboot.org/23297 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/lint/lint-extended-015-final-newlines')
-rwxr-xr-xutil/lint/lint-extended-015-final-newlines4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/lint/lint-extended-015-final-newlines b/util/lint/lint-extended-015-final-newlines
index bfaa817e1f..1315dbdee5 100755
--- a/util/lint/lint-extended-015-final-newlines
+++ b/util/lint/lint-extended-015-final-newlines
@@ -20,7 +20,9 @@ EXCLUDED_DIRS='src/vendorcode/\|util/romcc/\|cbfstool/lzma/\|cbfstool/lz4/\|Docu
EXCLUDED_FILES='\.jpg$\|\.cksum$\|\.bin$\|\.hex$\|\.ico$\|\.o$\|\.bz2$\|\.xz$\|^.tmpconfig\|\.pyc$\|_shipped$\|sha256$\|\.png$\|\.patch$'
# Use git ls-files if the code is in a git repo, otherwise use find.
-if [ -n "$(command -v git)" ] && [ -d .git ]; then
+if [ -n "$(command -v git)" ] && \
+ [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
+then
FIND_FILES="git ls-files"
else
FIND_FILES="find . "