From 496033868c1ed8c8c204bc3bc306ac114d441f93 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Fri, 27 Dec 2024 10:44:16 +0100 Subject: [PATCH] git-version-gen: Support git-archive tarballs. * build-aux/git-version-gen: Use .tarball-version-git as final guess. --- build-aux/git-version-gen | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 780b7e99f7..8076685df4 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,6 +1,6 @@ #!/bin/sh # Print a version string. -scriptversion=2024-07-04.10; # UTC +scriptversion=2024-12-27.09; # UTC # Copyright (C) 2007-2024 Free Software Foundation, Inc. # @@ -18,13 +18,20 @@ scriptversion=2024-07-04.10; # UTC # along with this program. If not, see . # This script is derived from GIT-VERSION-GEN from GIT: https://git-scm.com/. -# It may be run two ways: + +# It may be run in the following ways, presuming the script is invoked +# like "./git-version-gen .tarball-version": +# # - from a git repository in which the "git describe" command below # produces useful output (thus requiring at least one signed tag) -# - from a non-git-repo directory containing a .tarball-version file, which -# presumes this script is invoked like "./git-version-gen .tarball-version". +# +# - from a "make dist" non-git-repo directory containing a +# .tarball-version file +# +# - from a "git archive" non-git-repo directory containing a +# .tarball-version-git file -# In order to use intra-version strings in your project, you will need two +# In order to use intra-version strings in your project, you will need some # separate generated version string files: # # .tarball-version - present only in a distribution tarball, and not in @@ -37,6 +44,12 @@ scriptversion=2024-07-04.10; # UTC # hooks to force a reconfigure at distribution time to get the value # correct, without penalizing normal development with extra reconfigures. # +# .tarball-version-git - a file committed to git containing a single +# line with the string $Format:%(describe)$ and that the file is +# marked in .gitattributes with ".tarball-version-git export-subst". +# If the file doesn't exist or the export-subst keyword wasn't +# effective, the file is ignored. +# # .version - present in a checked-out repository and in a distribution # tarball. Usable in dependencies, particularly for files that don't # want to depend on config.h but do want to track version changes. @@ -69,7 +82,12 @@ scriptversion=2024-07-04.10; # UTC # mv $@-t $@ # dist-hook: # echo '$(VERSION)' > $(distdir)/.tarball-version - +# +# To setup support for "git archive" tarballs, use the following: +# +# echo '$Format:%(describe)$' > .tarball-version-git +# echo '.tarball-version-git export-subst' >> .gitattributes +# git commit -a -m "Add .tarball-version-git for git-version-gen." me=$0 @@ -195,6 +213,13 @@ else v=$fallback fi +if test "x$v" = xUNKNOWN \ + && test -f ${tarball_version_file}-git \ + && head -1 ${tarball_version_file}-git \ + | grep -v '^$Format' > /dev/null 2>&1; then + v=$(head -1 ${tarball_version_file}-git) +fi + v=`echo "$v" |sed "s/^$prefix//"` # Test whether to append the "-dirty" suffix only if the version -- 2.39.5