@matheusbsbs / matheus-bagliano / commits / 204d409247
Fork 0

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>

Junio C Hamano committed Feb 14, 2007 at 11:33 UTC 204d409247e7bbc7848569462aa11a87e373c8d6
1 file changed +11 -10
GIT-VERSION-GEN
+11 -10
@@ -6,18 +6,19 @@ DEF_VER=v1.5.0.GIT
6 LF='
7 '
8
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
12 then
13 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');
22 else
23 VN="$DEF_VER"
24 fi