net: generic code to query the maximum message size
[paraslash.git] / GIT-VERSION-GEN
1 #!/bin/sh
2
3 if test $# -ne 1; then
4         echo >&2 "usage: $0 <version file>"
5         exit 1
6 fi
7
8 GVF="$1"
9 DEF_VER="unnamed_version"
10
11 LF='
12 '
13
14 # First see if there is a version file (included in release tarballs),
15 # then try git-describe, then default.
16 if test -f VERSION
17 then
18         VN=$(cat VERSION) || VN="$DEF_VER"
19 elif test -d .git -o -f .git &&
20         VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
21         case "$VN" in
22         *$LF*) (exit 1) ;;
23         v[0-9]*)
24                 git update-index -q --refresh
25                 test -z "$(git diff-index --name-only HEAD --)" ||
26                 VN="$VN-dirty" ;;
27         esac
28 then
29         VN=$(echo "$VN" | sed -e 's/-/./g');
30 else
31         VN="$DEF_VER"
32 fi
33
34 VN=$(expr "$VN" : v*'\(.*\)')
35
36 if test -r $GVF
37 then
38         VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
39 else
40         VC=unset
41 fi
42 test "$VN" = "$VC" || {
43         echo >&2 "GIT_VERSION = $VN"
44         echo "GIT_VERSION = $VN" >$GVF
45 }