From 0f94f1f2a454aa399f02129155918701b3b7e62e Mon Sep 17 00:00:00 2001 From: Guilherme Janczak Date: Mon, 30 Dec 2024 18:39:38 +0000 Subject: [PATCH] tools/version.sh: fix compilation of shallow clones (#220) version.sh assumed that commit 16cd907fe7482cb54a7374cd28b8501f138116be existed, this isn't true when the source tree is a shallow clone. Tested on OpenBSD 7.6 with a few uncommitted patches to fix unrelated compilation issues. --- tools/version.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/version.sh b/tools/version.sh index 8df33e1755..2916e1feab 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -24,8 +24,12 @@ osx_bundle_sed_path="${builddir}/osx-bundle.sed" last_svn_revision=6962 last_svn_hash="16cd907fe7482cb54a7374cd28b8501f138116be" - -git_revision=$(expr $last_svn_revision + $(git rev-list --count $last_svn_hash..HEAD)) +# Check if the commit exists first, it doesn't exist in shallow clones. +if [ "$(git cat-file -t $last_svn_hash 2> /dev/null)" = "commit" ]; then + git_revision=$(expr $last_svn_revision + $(git rev-list --count $last_svn_hash..HEAD)) +else + git_revision=0 +fi git_version_str=$(git describe --exact-match 2> /dev/null) installer_version='0.0.0' resource_version='0, 0, 0'