diff --git a/doc/ns3_html_theme/get_version.sh b/doc/ns3_html_theme/get_version.sh
index 70c11161b..42fb4259b 100755
--- a/doc/ns3_html_theme/get_version.sh
+++ b/doc/ns3_html_theme/get_version.sh
@@ -137,22 +137,27 @@ fi
outf="doc/ns3_html_theme/static/ns3_version.js"
# Distance from last tag
-# 'git describe HEAD --tags' will return a string such as either
+# 'git describe HEAD --tags --long' will return a string such as either
# 'ns-3.29-159-xxx' (if we are at a distance from the last release tag) or
# 'ns-3.29' if we are at the tag.
-distance=`git describe HEAD --tags | cut -d '-' -f 3- | cut -d '-' -f 1`
+distance=`git describe HEAD --tags --long | cut -d '-' -f 3`
-if [ $distance -eq 1 ]; then
- version=`git describe HEAD --tags | cut -d '-' -f 2`
+if [ $distance -eq 1 ] | [ $distance -eq 0 ]; then
+ version=`git describe HEAD --tags --long | cut -d '-' -f 2`
say "at version $version"
+elif [ $tag -eq 0 ]; then
+ distance=0
+ # version previously set
+ vers_href=
+
elif [ $tag -eq 1 ]; then
distance=1
# version previously set
vers_href=
else
- version=`git describe HEAD --tags | cut -d '-' -f 3- | cut -d '-' -f 2 | cut -c 2-`
+ version=`git describe HEAD --tags --long | cut -d '-' -f 3- | cut -d '-' -f 2 | cut -c 2-`
# Check for uncommitted changes
changes=0
if [ "$(git status --porcelain)" ]; then