Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6/mini2440.git] / scripts / setlocalversion
blob32c8554f3946dee390b56eda335facd94f0764fa
1 #!/bin/sh
2 # Print additional version information for non-release trees.
4 usage() {
5 echo "Usage: $0 [srctree]" >&2
6 exit 1
9 cd "${1:-.}" || usage
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
17 else
18 printf '%s%s' -g $head
21 # Is this git on svn?
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" \
29 | read dummy; then
30 printf '%s' -dirty
33 # All done with git
34 exit
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.
49 case "$hgid" in
50 *+|*+\ *) printf '%s' -dirty ;;
51 esac
53 # All done with mercurial
54 exit
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"
62 # All done with svn
63 exit