Btrfs-progs: make smatch checker happy (trivial fixes)
[btrfs-progs-unstable/devel.git] / version.sh
blobaa750fa8124e69058da4989d9a88ba4069b50cce
1 #!/bin/bash
3 # determine-version -- report a useful version for releases
5 # Copyright 2008, Aron Griffis <agriffis@n01se.net>
6 # Copyright 2008, Oracle
7 # Released under the GNU GPLv2
9 v="v3.14.1"
11 which git &> /dev/null
12 if [ $? == 0 -a -d .git ]; then
13 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
14 if tag=`git describe --tags 2>/dev/null`; then
15 v="$tag"
18 # Are there uncommitted changes?
19 git update-index --refresh --unmerged > /dev/null
20 if git diff-index --name-only HEAD | grep -v "^scripts/package" \
21 | read dummy; then
22 v="$v"-dirty
27 echo "#ifndef __BUILD_VERSION" > .build-version.h
28 echo "#define __BUILD_VERSION" >> .build-version.h
29 echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
30 echo "#endif" >> .build-version.h
32 diff -q version.h .build-version.h >& /dev/null
34 if [ $? == 0 ]; then
35 rm .build-version.h
36 exit 0
39 mv .build-version.h version.h