btrfs-progs: check: introduce function to check shared data backref
[platform/upstream/btrfs-progs.git] / version.sh
1 #!/bin/bash
2 #
3 # determine-version -- report a useful version for releases
4 #
5 # Copyright 2008, Aron Griffis <agriffis@n01se.net>
6 # Copyright 2008, Oracle
7 # Released under the GNU GPLv2
8
9 v="v4.7"
10
11 opt=$1
12
13 which git &> /dev/null
14 if [ $? == 0 -a -d .git ]; then
15     if head=`git rev-parse --verify HEAD 2>/dev/null`; then
16         if tag=`git describe --tags 2>/dev/null`; then
17             v="$tag"
18         fi
19
20         # Are there uncommitted changes?
21         git update-index --refresh --unmerged > /dev/null
22         if git diff-index --name-only HEAD | grep -v "^scripts/package" \
23             | read dummy; then
24             v="$v"-dirty
25         fi
26     fi
27 fi
28
29 if [ "$opt" = "--configure" ]; then
30         # Omit the trailing newline, so that m4_esyscmd can use the result directly.
31         echo -n "$v"
32 else
33         echo "$v"
34 fi
35
36 exit 0
37