git-gui: Change base version to 0.6.
[git/git.git] / GIT-VERSION-GEN
CommitLineData
f1cee4e6
SP
1#!/bin/sh
2
3GVF=GIT-VERSION-FILE
fdf6cfc4 4DEF_VER=0.6.GITGUI
f1cee4e6
SP
5
6LF='
7'
8
07d082bf
SP
9tree_search ()
10{
11 head=$1
12 tree=$2
13 for p in $(git rev-list --parents --max-count=1 $head 2>/devnull)
14 do
15 test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
16 vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
17 case "$vn" in
18 gitgui-[0-9]*) echo $vn; break;;
19 esac
20 done
21}
22
23# We may be a subproject, so try looking for the merge
24# commit that supplied this directory content if we are
25# not at the toplevel. We probably will always be the
26# second parent in the commit, but we shouldn't rely on
27# that fact.
28#
29# If we are at the toplevel or the merge assumption fails
30# try looking for a gitgui-* tag, or fallback onto the
31# distributed version file.
32
33if prefix="$(git rev-parse --show-prefix 2>/dev/null)"
34 test -n "$prefix" &&
35 head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
36 tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
37 VN=$(tree_search $head $tree)
38 case "$VN" in
39 gitgui-[0-9]*) : happy ;;
40 *) (exit 1) ;;
41 esac
42then
43 VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
44elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
f1cee4e6 45 case "$VN" in
6a6459bc 46 gitgui-[0-9]*) : happy ;;
07d082bf 47 *) (exit 1) ;;
f1cee4e6
SP
48 esac
49then
6a6459bc 50 VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
f1cee4e6
SP
51elif test -f version
52then
53 VN=$(cat version) || VN="$DEF_VER"
54else
55 VN="$DEF_VER"
56fi
57
f1cee4e6
SP
58dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
59case "$dirty" in
60'')
61 ;;
62*)
63 VN="$VN-dirty" ;;
64esac
65
66if test -r $GVF
67then
7e81d4ee 68 VC=$(sed -e 's/^GITGUI_VERSION = //' <$GVF)
f1cee4e6
SP
69else
70 VC=unset
71fi
72test "$VN" = "$VC" || {
7e81d4ee
SP
73 echo >&2 "GITGUI_VERSION = $VN"
74 echo "GITGUI_VERSION = $VN" >$GVF
f1cee4e6
SP
75}
76
77