Markus Armbruster wrote:
Should we replace /-([^-]+)-g([^-]*)$/ by /.\1-\2/?  Extended regexp
for clarity.  Tighter matching would be possible, say
/-([0-9]+)-g[0-9a-f]{4,}$/.


Sounds good, I installed the attached.
>From 45a1331864ed37db2cd058a99eb9934648d4c342 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 6 Aug 2017 23:24:10 -0700
Subject: [PATCH] git-version-gen: another fix for tags with "-"

* build-aux/git-version-gen: Improve fix for tags containing "-".
Suggested by Markus Armbruster in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00034.html
---
 ChangeLog                 | 7 +++++++
 build-aux/git-version-gen | 8 ++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8282f2e..37daf4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-08-06  Paul Eggert  <egg...@cs.ucla.edu>
+
+	git-version-gen: another fix for tags with "-"
+	* build-aux/git-version-gen: Improve fix for tags containing "-".
+	Suggested by Markus Armbruster in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00034.html
+
 2017-08-06  Bruno Haible  <br...@clisp.org>
 
 	warnings, manywarnings: Add support for multiple languages, not just C.
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index e6c329d..a8818b2 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2017-08-06.16; # UTC
+scriptversion=2017-08-07.06; # UTC
 
 # Copyright (C) 2007-2017 Free Software Foundation, Inc.
 #
@@ -184,9 +184,9 @@ then
             ;;
     esac
 
-    # Change the first '-' to a '.', so version-comparing tools work properly.
-    # Remove the "g" in git describe's output string, to save a byte.
-    v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
+    # 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
-- 
2.7.4

Reply via email to