From 1677379a3c3608374b9a8e70ff12afdfa63b4c76 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 15 Mar 2023 11:11:45 +0100 Subject: make version info robust w.r.t. sparse git checkouts --- contrib/get_version.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/get_version.sh b/contrib/get_version.sh index 6e3ab5141..00f418f3c 100755 --- a/contrib/get_version.sh +++ b/contrib/get_version.sh @@ -1,18 +1,18 @@ #!/bin/sh # Gets the version number from git, or from the contents of .version VERSION= -if test -f ".version" -then +if test -f ".version"; then VERSION=$(cat .version) fi -if [ -e ./.git ] -then - VERSION=$(git describe --tags) - VERSION=${VERSION#v} - echo $VERSION > .version +if [ -e ./.git ]; then + # With sparse checkouts, we have a .git dir but possibly no tags + gitver=$(git describe --tags 2>/dev/null || echo no-git-version) + if test "$gitver" != "no-git-version"; then + VERSION=${gitver#v} + echo "$VERSION" > .version + fi fi -if test "x$VERSION" = "x" -then +if test "x$VERSION" = "x"; then VERSION="unknown" fi case $1 in -- cgit v1.2.3