# Ensure that we have a repo here.
# If not, just cat the VERSION file; it contains the latest release number.
-[ -d ".git" ] || exec cat VERSION
+{ [ -d ".git" ] && command -v git >/dev/null 2>&1; } \
+|| exec cat VERSION
latesttag="$(git tag --merged=HEAD --list 'mutt-*-rel' | tr - . | sort -Vr | head -n1 | tr . -)"
version="$(echo $latesttag | sed -e s/mutt-// -e s/-rel// -e s/-/./g)"
distance="$(git rev-list --count $latesttag..)"
commitid="$(git rev-parse --short HEAD)"
-if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
- dirty=+
+
+if [ $distance -eq 0 ]; then
+ distance=
else
- dirty=""
+ distance="+$distance"
fi
-echo "${version}+${distance} (g${commitid}${dirty})"
+
+echo "${version}${distance} (${commitid})"