From 93490363caf5a2ed919926e02e1ac5289357d372 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 28 Dec 2024 09:35:08 -0800 Subject: [PATCH] git-version-gen: fix preceding change * build-aux/git-version-gen: Use the contents of the -git file when its first line has the proper form (fixing a reversed test). Also, reference the file only once, rather than three times. Also, double quote $tarball_version_file in preexisting code. --- build-aux/git-version-gen | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 8076685df4..6e0f5d327e 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-27.09; # UTC +scriptversion=2024-12-28.17; # UTC # Copyright (C) 2007-2024 Free Software Foundation, Inc. # @@ -156,9 +156,9 @@ v_from_git= # First see if there is a tarball-only version file. # then try "git describe", then default. -if test -f $tarball_version_file +if test -f "$tarball_version_file" then - v=`cat $tarball_version_file` || v= + v=`cat "$tarball_version_file"` || v= case $v in *$nl*) v= ;; # reject multi-line output esac @@ -213,11 +213,11 @@ 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) +if test "x$v" = xUNKNOWN; then + fmt=$(awk 'NR==1 && /^\$Format/ {print}' \ + "$tarball_version_file-git" 2> /dev/null) \ + && test -n "$fmt" \ + && v=$fmt fi v=`echo "$v" |sed "s/^$prefix//"` -- 2.39.5