]> Savannah Git Hosting - gnulib.git/commitdiff
git-version-gen: fix preceding change
authorSimon Josefsson <simon@josefsson.org>
Sat, 28 Dec 2024 17:57:46 +0000 (18:57 +0100)
committerSimon Josefsson <simon@josefsson.org>
Sat, 28 Dec 2024 19:24:09 +0000 (20:24 +0100)
* build-aux/git-version-gen: Do use *-git content when keyword
is not present.  Move post-processing later.  Doc fixes.

ChangeLog
build-aux/git-version-gen

index fa0b16ed5745a2f3d0b9b6a98b5fb5a0339ce7ab..f8557f9ebc29e4125c5ce0a61001dcc791e860d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-28  Simon Josefsson  <simon@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  <bruno@clisp.org>
 
        doc: Omit deprecated modules from the "Undocumented modules" index.
index 6e0f5d327ee2b7921536388b68fdc40007715712..6d2b62ca3a147d47d83279c3c6644a0150d5a8b5 100755 (executable)
@@ -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