提交 75280bdf 编写于 作者: M Masahiro Yamada

setlocalversion: make indentation shallower

Return earlier if we are not in the correct git repository. This makes
the code more readable.
Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
上级 992ebfab
...@@ -34,12 +34,16 @@ scm_version() ...@@ -34,12 +34,16 @@ scm_version()
short=true short=true
fi fi
# Check for git and a git repo. if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && return
head=$(git rev-parse --verify HEAD 2>/dev/null); then fi
if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then
return
fi
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it
# it, because this version is defined in the top level Makefile. # because this version is defined in the top level Makefile.
if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then
# If only the short version is requested, don't bother # If only the short version is requested, don't bother
...@@ -59,22 +63,21 @@ scm_version() ...@@ -59,22 +63,21 @@ scm_version()
fi fi
# Check for uncommitted changes. # Check for uncommitted changes.
# This script must avoid any write attempt to the source tree, # This script must avoid any write attempt to the source tree, which
# which might be read-only. # might be read-only.
# You cannot use 'git describe --dirty' because it tries to # You cannot use 'git describe --dirty' because it tries to create
# create .git/index.lock . # .git/index.lock .
# First, with git-status, but --no-optional-locks is only # First, with git-status, but --no-optional-locks is only supported in
# supported in git >= 2.14, so fall back to git-diff-index if # git >= 2.14, so fall back to git-diff-index if it fails. Note that
# it fails. Note that git-diff-index does not refresh the # git-diff-index does not refresh the index, so it may give misleading
# index, so it may give misleading results. See # results.
# git-update-index(1), git-diff-index(1), and git-status(1). # See git-update-index(1), git-diff-index(1), and git-status(1).
if { if {
git --no-optional-locks status -uno --porcelain 2>/dev/null || git --no-optional-locks status -uno --porcelain 2>/dev/null ||
git diff-index --name-only HEAD git diff-index --name-only HEAD
} | read dummy; then } | read dummy; then
printf '%s' -dirty printf '%s' -dirty
fi fi
fi
} }
collect_files() collect_files()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册