if [ -f .dist-version ]; then
# Get the version from the file distributed in the tarball.
version=$(cat .dist-version)
-elif [ -d .git ]; then
+elif [ -e .git ]; then
# Ger the version from the git repository.
version=$(git describe --tags --always --match [0-9]* 2> /dev/null)
# Check if we are on a dirty checkout.
git update-index --refresh -q >/dev/null
- dirty=$(git diff-index --name-only HEAD 2>/dev/null)
+ dirty=$(git diff-index --name-only --ignore-submodules=untracked HEAD 2>/dev/null)
if [ -n "$dirty" ]; then
version="$version-dirty"
fi