Skip to content

Commit 204d409

Browse files
author
Junio C Hamano
committed
GIT-VERSION-FILE: check ./version first.
When somebody else extracts git tarball inside a larger project, 'git describe' would reported the version number of that upper level project. Sometimes, using the consistent versioning across subdirectories of a larger project is useful, but it may not always be the right thing to do. This changes the script to check ./vertion file first, and then fall back to "git describe". This way, by default, tarball distribution will get our own version. If the upper level wants to use consistent versioning across its subdirectories, its Makefile can overwrite ./version file to force whatever version number they want to give us before descending into us. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 78a28df commit 204d409

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

GIT-VERSION-GEN

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ DEF_VER=v1.5.0.GIT
66
LF='
77
'
88

9-
# First try git-describe, then see if there is a version file
10-
# (included in release tarballs), then default
11-
if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
12-
case "$VN" in
13-
*$LF*) (exit 1) ;;
14-
v[0-9]*) : happy ;;
15-
esac
16-
then
17-
VN=$(echo "$VN" | sed -e 's/-/./g');
18-
elif test -f version
9+
# First see if there is a version file (included in release tarballs),
10+
# then try git-describe, then default.
11+
if test -f version
1912
then
2013
VN=$(cat version) || VN="$DEF_VER"
14+
elif test -d .git &&
15+
VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
16+
case "$VN" in
17+
*$LF*) (exit 1) ;;
18+
v[0-9]*) : happy ;;
19+
esac
20+
then
21+
VN=$(echo "$VN" | sed -e 's/-/./g');
2122
else
2223
VN="$DEF_VER"
2324
fi

0 commit comments

Comments
 (0)