Jim Meyering <j...@meyering.net> writes: > On Sat, Dec 28, 2024 at 10:01 AM Simon Josefsson <si...@josefsson.org> wrote: >> 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, > > Sorry. I should have known. > How about this tiny adjustment, then? > > - fmt=$(awk 'NR==1 && /^\$Format/ {print}' \ > + fmt=$(awk 'NR==1 && ! /^\$Format/ {print}' \
That's fine with me, but now I did some testing... and on some platforms I got this because of awk vs gawk confusion: sh: awk: command not found This is used early in the ./configure loop, so using $AWK or adding some code to guess which awk to use seems a bit annoying. Thoughts? >> 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. > > Yes, I like that part. I pushed the attached patch to restore behaviour a bit while we discuss use of awk instead. /Simon
From 55073ac71ccdcb98c8941bbfac53a71848653188 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 | 23 ++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa0b16ed57..f8557f9ebc 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> doc: Omit deprecated modules from the "Undocumented modules" index. diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 6e0f5d327e..6d2b62ca3a 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-12-28.17; # UTC +scriptversion=2024-12-28.19; # UTC # Copyright (C) 2007-2024 Free Software Foundation, Inc. # @@ -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 -- 2.47.1
signature.asc
Description: PGP signature