2 # Print additional version information for non-release trees.
5 echo "Usage: $0 [srctree]" >&2
11 # Check for git and a git repo.
12 if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
13 # Do we have an untagged tag?
14 if atag=`git describe 2>/dev/null`; then
15 echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
16 # add -g${head}, if there is no usable tag
18 printf '%s%s' -g $head
22 if git config --get svn-remote.svn.url >/dev/null; then
23 printf -- '-svn%s' "`git svn find-rev $head`"
26 # Are there uncommitted changes?
27 git update-index --refresh --unmerged > /dev/null
28 if git diff-index --name-only HEAD | grep -v "^scripts/package" \
37 # Check for mercurial and a mercurial repo.
38 if hgid=`hg id 2>/dev/null`; then
39 tag=`printf '%s' "$hgid" | cut -d' ' -f2`
41 # Do we have an untagged version?
42 if [ -z "$tag" -o "$tag" = tip ]; then
43 id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
44 printf '%s%s' -hg "$id"
47 # Are there uncommitted changes?
48 # These are represented by + after the changeset id.
50 *+|*+\ *) printf '%s' -dirty ;;
53 # All done with mercurial
57 # Check for svn and a svn repo.
58 if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
59 rev=`echo $rev | awk '{print $NF}'`
60 printf -- '-svn%s' "$rev"