3 # SPDX-License-Identifier: GPL-2.0-only
5 # This file is sourced by the linters so that each one doesn't have to
6 # specify these routines individually
10 if [ -z "$GIT" ]; then
11 GIT
="$(command -v git)"
13 # If git is specified, Do a basic check that it runs and seems like
15 if ! "${GIT}" --version |
grep -q git
; then
16 echo "Error: ${GIT} does not seem to be valid."
21 if [ "$(${GIT} rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
27 if [ "${IN_GIT_TREE}" -eq 1 ] && [ -z "${GIT}" ]; then
28 echo "This test needs git to run. Please install it, then run this test again."
32 # Use git ls-files if the code is in a git repo, otherwise use find.
33 if [ "${IN_GIT_TREE}" -eq 1 ]; then
34 FIND_FILES
="${GIT} ls-files"
40 # Use git grep if the code is in a git repo, otherwise use grep.
41 if [ "${IN_GIT_TREE}" -eq 1 ]; then
42 GREP_FILES
="${GIT} grep"