]> Savannah Git Hosting - gnulib.git/commitdiff
git-version-gen: fix preceding change
authorJim Meyering <meyering@meta.com>
Sat, 28 Dec 2024 17:35:08 +0000 (09:35 -0800)
committerJim Meyering <meyering@meta.com>
Sat, 28 Dec 2024 17:35:44 +0000 (09:35 -0800)
* 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

index 8076685df493a705a9c3f4cbd600c3189bf2d8cf..6e0f5d327ee2b7921536388b68fdc40007715712 100755 (executable)
@@ -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//"`