Skip to content

Commit dae859d

Browse files
committed
releng/version.sh: fix git-based version detection
1. Correct typo: --abbrev-rev -> --abbrev-ref 2. Limit repository search to the current directory Fixes: #588.
1 parent c83f534 commit dae859d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

releng/version.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ usage() {
1818
EOF
1919
}
2020

21-
detect_version() {
21+
# This should always run in a subshell because it manipulates the environment
22+
detect_version() (
23+
# Do not allow git to walk past the ZFSBootMenu tree to find a repository
24+
export GIT_CEILING_DIRECTORIES="${PWD}/.."
25+
2226
# If git-describe does the job, the job is done
2327
version="$(git describe --tags HEAD 2>/dev/null)" || version=""
2428

@@ -32,7 +36,7 @@ detect_version() {
3236
fi
3337

3438
# Otherwise, use git-rev-parse if possible
35-
if branch="$(git rev-parse --abbrev-rev HEAD 2>/dev/null)"; then
39+
if branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"; then
3640
case "${branch}" in
3741
v[0-9]*) branch="${branch#v}"
3842
esac
@@ -75,7 +79,7 @@ detect_version() {
7579
# There is apparently no version
7680
echo "UNKNOWN"
7781
return 1
78-
}
82+
)
7983

8084
update_version() {
8185
version="${1?a version is required}"

0 commit comments

Comments
 (0)