Jim Meyering <j...@meyering.net> writes: >> 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 > > That code uses "grep -v" where the intent must have been to use just "grep". > I've fixed that and cleaned up via this just-pushed change:
Hi Jim. Thanks for review! No the intent is -v. The export-subst logic is backwards. The content of the file can only be used if it does NOT contain the '^$Format' keyword. If the file contained that keyword, it was not substituted by the git attribute export-subst, and the file content cannot be used as a version number since it is just the string '$Format:%(describe)$' which is not a version number. It is git-archive that replaces that keyword with a suitable version number. Meanwhile, I noticed a small problem with my patch: when the version number is taken from the .tarball-version-git file, it is not put through the same post-processing as a version number taken from the git command. This doesn't really matter, but it helps to have things consistent. How about this patch? Not pushed since it is untested. /Simon
From 48c51c7c41c8776136c74e02b8d5b94e569839ce Mon Sep 17 00:00:00 2001 From: Simon Josefsson <si...@josefsson.org> Date: Sat, 28 Dec 2024 18:57:46 +0100 Subject: [PATCH] git-version-gen: fix preceding change * build-aux/git-version-gen: Do use *-git content when keyword is not present. Move post-processing later. Doc fixes. --- ChangeLog | 6 ++++++ build-aux/git-version-gen | 21 +++++++++++---------- top/maint.mk | 11 +++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b99da8b96a..e8a765e108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-12-28 Simon Josefsson <si...@josefsson.org> + + git-version-gen: fix preceding change + * build-aux/git-version-gen: Do use *-git content only when + keyword is not present. Move post-processing later. Doc fixes. + 2024-12-28 Bruno Haible <br...@clisp.org> endian: Fix link error on CentOS 5. diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 6e0f5d327e..efb1675fe6 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -87,7 +87,8 @@ scriptversion=2024-12-28.17; # UTC # # 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." +# git add .tarball-version-git .gitattributes +# git commit -m "Add .tarball-version-git for git-version-gen." me=$0 @@ -202,10 +203,6 @@ then test "$commit_list" = failed && v=UNKNOWN ;; esac - - # Change the penultimate "-" to ".", for version-comparing tools. - # Remove the "g" to save a byte. - v=`echo "$v" | sed 's/-\([^-]*\)-g\([^-]*\)$/.\1-\2/'`; v_from_git=1 elif test "x$fallback" = x || git --version >/dev/null 2>&1; then v=UNKNOWN @@ -213,13 +210,17 @@ else v=$fallback fi -if test "x$v" = xUNKNOWN; then - fmt=$(awk 'NR==1 && /^\$Format/ {print}' \ - "$tarball_version_file-git" 2> /dev/null) \ - && test -n "$fmt" \ - && v=$fmt +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 +# Change the penultimate "-" to ".", for version-comparing tools. +# Remove the "g" to save a byte. +v=`echo "$v" | sed 's/-\([^-]*\)-g\([^-]*\)$/.\1-\2/'`; + v=`echo "$v" |sed "s/^$prefix//"` # Test whether to append the "-dirty" suffix only if the version diff --git a/top/maint.mk b/top/maint.mk index b2baa02edf..2ff1019772 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -1515,8 +1515,15 @@ vc-diff-check: rel-files = $(DIST_ARCHIVES) -gnulib-version = $$(cd $(gnulib_dir) \ - && { git describe 2> /dev/null || git rev-parse --short=10 HEAD; } ) +gnulib-version ?= \ + $$(if test -e $(gnulib_dir)/.git; then \ + git -C $(gnulib_dir) rev-parse HEAD; \ + elif test -f $(srcdir)/bootstrap.conf; then \ + perl -lne '/^\s*GNULIB_REVISION=(\S+)/ and $$d=$$1;' \ + -e 'END{defined $$d and print $$d}' bootstrap.conf; \ + else \ + head -1 $(gnulib_dir)/ChangeLog | sed -e 's/ .*//;q '; \ + fi) bootstrap-tools ?= autoconf,automake,gnulib gpgv = $$(gpgv2 --version >/dev/null && echo gpgv2 || echo gpgv) -- 2.47.1
signature.asc
Description: PGP signature