summaryrefslogtreecommitdiff
path: root/util/lint
diff options
context:
space:
mode:
Diffstat (limited to 'util/lint')
-rwxr-xr-xutil/lint/lint-008-kconfig4
-rwxr-xr-xutil/lint/lint-014-qualified-types4
-rwxr-xr-xutil/lint/lint-016-non-ascii4
-rwxr-xr-xutil/lint/lint-extended-015-final-newlines4
-rwxr-xr-xutil/lint/lint-extended-020-signed-off-by4
-rwxr-xr-xutil/lint/lint-stable-004-style-labels4
-rwxr-xr-xutil/lint/lint-stable-008-kconfig4
-rwxr-xr-xutil/lint/lint-stable-013-site-local4
-rwxr-xr-xutil/lint/lint-stable-017-configs4
-rwxr-xr-xutil/lint/lint-stable-018-symlinks4
-rwxr-xr-xutil/lint/lint-stable-019-header-files4
-rwxr-xr-xutil/lint/lint-stable-021-coreboot-lowercase4
12 files changed, 36 insertions, 12 deletions
diff --git a/util/lint/lint-008-kconfig b/util/lint/lint-008-kconfig
index d3da17ea5d..8a0042d2da 100755
--- a/util/lint/lint-008-kconfig
+++ b/util/lint/lint-008-kconfig
@@ -23,7 +23,9 @@ fi
# If coreboot is in a git repo, use git grep to check as it will ignore any
# files in the tree that aren't checked into git
-if [ -n "$(command -v git)" ] && [ -e ".git" ]; then
+if [ -n "$(command -v git)" ] && \
+ [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
+then
env perl util/lint/kconfig_lint
else
env perl util/lint/kconfig_lint --no_git_grep
diff --git a/util/lint/lint-014-qualified-types b/util/lint/lint-014-qualified-types
index 58b48b705e..98679ea55e 100755
--- a/util/lint/lint-014-qualified-types
+++ b/util/lint/lint-014-qualified-types
@@ -21,7 +21,9 @@ EXCLUDED_DIRS='^src/vendorcode\|^util/romcc\|cbfstool/lzma\|cbfstool/lz4'
INCLUDED_FILES='\.[ch]:'
# Use git grep if the code is in a git repo, otherwise use grep.
-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
GREP_FILES="git grep -n"
else
GREP_FILES="grep -rn"
diff --git a/util/lint/lint-016-non-ascii b/util/lint/lint-016-non-ascii
index 881eeba69e..beffd83dd6 100755
--- a/util/lint/lint-016-non-ascii
+++ b/util/lint/lint-016-non-ascii
@@ -22,7 +22,9 @@ EXCLUDED_FILES='to-wiki/towiki\.sh$\|vga/vga_font\|video/font\|PDCurses.*x11'
EXCLUDED_PHRASES='Copyright\|Ported to\|Intel®\|°C\|°F\|Athlon™\|Copyright.*©\|A-Za-zÀ-ÿ'
# 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 . "
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 . "
diff --git a/util/lint/lint-extended-020-signed-off-by b/util/lint/lint-extended-020-signed-off-by
index 40b6e9eb42..065b286d34 100755
--- a/util/lint/lint-extended-020-signed-off-by
+++ b/util/lint/lint-extended-020-signed-off-by
@@ -16,7 +16,9 @@
# DESCR: Check for a signed-off-by line on the latest git commit
# This test is mainly for the jenkins server
-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
if [ -z "$(git log -n 1 | grep '[[:space:]]\+Signed-off-by: ')" ]; then
echo "No Signed-off-by line in commit message"
fi
diff --git a/util/lint/lint-stable-004-style-labels b/util/lint/lint-stable-004-style-labels
index 7b68b4ad63..698b22df78 100755
--- a/util/lint/lint-stable-004-style-labels
+++ b/util/lint/lint-stable-004-style-labels
@@ -18,7 +18,9 @@
LC_ALL=C export LC_ALL
# 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 src"
diff --git a/util/lint/lint-stable-008-kconfig b/util/lint/lint-stable-008-kconfig
index 06e41b8570..25d04b6c7c 100755
--- a/util/lint/lint-stable-008-kconfig
+++ b/util/lint/lint-stable-008-kconfig
@@ -23,7 +23,9 @@ fi
# If coreboot is in a git repo, use git grep to check as it will ignore any
# files in the tree that aren't checked into git
-if [ -n "$(command -v git)" ] && [ -e ".git" ]; then
+if [ -n "$(command -v git)" ] && \
+ [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
+then
env perl util/lint/kconfig_lint --warnings_off 2>&1
else
env perl util/lint/kconfig_lint --no_git_grep --warnings_off 2>&1
diff --git a/util/lint/lint-stable-013-site-local b/util/lint/lint-stable-013-site-local
index 43c4542a04..d701ee07b3 100755
--- a/util/lint/lint-stable-013-site-local
+++ b/util/lint/lint-stable-013-site-local
@@ -22,7 +22,9 @@
LC_ALL=C export LC_ALL
-if [ -n "$(command -v git)" ] && [ -e ".git" ]; then
+if [ -n "$(command -v git)" ] && \
+ [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
+then
if [ -n "$(git ls-files site-local/*)" ]; then
echo "Error: site-local must be kept separate from the coreboot repository."
fi
diff --git a/util/lint/lint-stable-017-configs b/util/lint/lint-stable-017-configs
index 782c183c24..6d7393db81 100755
--- a/util/lint/lint-stable-017-configs
+++ b/util/lint/lint-stable-017-configs
@@ -19,7 +19,9 @@ LC_ALL=C export LC_ALL
SYMBOLS='CONFIG_ARCH_\|CONFIG_MAINBOARD_HAS_'
# Use git grep if the code is in a git repo, otherwise use grep.
-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
GREP="git grep -l"
else
GREP="grep -rl"
diff --git a/util/lint/lint-stable-018-symlinks b/util/lint/lint-stable-018-symlinks
index 833507c294..6f58e7ddd0 100755
--- a/util/lint/lint-stable-018-symlinks
+++ b/util/lint/lint-stable-018-symlinks
@@ -19,7 +19,9 @@ LC_ALL=C export LC_ALL
EXCLUDED_DIRS='^3rdparty\|^site-local'
# If the code is in a git repo, only print files that are checked in
-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
git ls-tree -r HEAD | \
grep ^120000 | \
cut -f2 | \
diff --git a/util/lint/lint-stable-019-header-files b/util/lint/lint-stable-019-header-files
index 1ce6cc525f..11bc432679 100755
--- a/util/lint/lint-stable-019-header-files
+++ b/util/lint/lint-stable-019-header-files
@@ -23,7 +23,9 @@ EXCLUDED_FILES='src/include/kconfig.h'
HEADER_FILES="k*config"
# Use git grep if the code is in a git repo, otherwise use grep.
-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
GREP_FILES="git grep -n"
else
GREP_FILES="grep -rn"
diff --git a/util/lint/lint-stable-021-coreboot-lowercase b/util/lint/lint-stable-021-coreboot-lowercase
index 82e2dd4160..a71d2047f3 100755
--- a/util/lint/lint-stable-021-coreboot-lowercase
+++ b/util/lint/lint-stable-021-coreboot-lowercase
@@ -19,7 +19,9 @@ LC_ALL=C export LC_ALL
EXCLUDE='^3rdparty/\|util/crossgcc/xgcc\|Binary file\|coreboot\|COREBOOT\|CorebootPayload\|CorebootModule\|minnowboard.org/Coreboot\|.*\.patch$\|CorebootBdsLib\|^payloads/external'
# Use git grep if the code is in a git repo, otherwise use grep.
-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
GREP_FILES="git grep -in"
# Check last commit message