summaryrefslogtreecommitdiff
path: root/tools/setlocalversion
diff options
context:
space:
mode:
Diffstat (limited to 'tools/setlocalversion')
-rwxr-xr-xtools/setlocalversion9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/setlocalversion b/tools/setlocalversion
index 9a23825..9bbdafd 100755
--- a/tools/setlocalversion
+++ b/tools/setlocalversion
@@ -11,12 +11,15 @@ cd "${1:-.}" || usage
# Check for git and a git repo.
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
# Do we have an untagged version?
- if [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
- printf '%s%s' -g `echo "$head" | cut -c1-8`
+ if git name-rev --tags HEAD | \
+ grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
+ git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
fi
# Are there uncommitted changes?
- if git diff-files | read dummy; then
+ git update-index --refresh --unmerged > /dev/null
+ if git diff-index --name-only HEAD | grep -v "^scripts/package" \
+ | read dummy; then
printf '%s' -dirty
fi
fi