Eric Blake <ebl...@redhat.com> writes: > On 11/12/2011 11:53 AM, Simon Josefsson wrote: >> For inetutils (which uses git tags looking like 'inetutils-1_8') we >> noticed that git-version-gen hardcodes an expression when searching for >> particular tags: >> >> && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \ >> >> I guess there are at least two questions: >> >> 1) Is it really required? > > What did you mean by "it"? The use of "--match=pattern"?
Yes. > Yes, since that allows you the freedom to have more tags than just > official releases. (I frequently have local tags to intermediate > points, but only push official v1.0 style tags upstream, but since the > command runs locally, git describe tries to use my local tags unless I > use --match). Ok. But what is the harm if the --match is not done? You would get a version string based on your own tags, but how does that matter? Presumably when you are ready to do an official release, 'git describe' will return a "proper" version and not a local tag and all will be fine. (I'm just trying to understand, having the code there is fine.) >> >> 2) Any reason against making the expression 'v*' configurable? > > No problem by me - I'd welcome a patch that adds a --label-pattern > option that defaults to 'v*' but can be overridden by a cfg.mk variable. We noticed there were other problems with the tags in InetUtils, so I have not finished this aspect since it wouldn't solve the entire problem. I finished one step in that direction though, and I pushed a patch to add sane command line parsing and --help and --version outputs. I'm hoping the patch is non-controversial so I pushed it directly but I'm happy to modify it or even revert if you think it is going in the wrong direction. Thanks for quick response, /Simon >From d67fde90c62c94987893824ae2e5315c21a7a796 Mon Sep 17 00:00:00 2001 From: Simon Josefsson <si...@josefsson.org> Date: Sun, 13 Nov 2011 11:07:41 +0100 Subject: [PATCH] git-version: Improve command line handling. * build-aux/git-version-gen: Add --help and --version. --- ChangeLog | 4 +++ build-aux/git-version-gen | 58 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2794c4d..13248fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-13 Simon Josefsson <si...@josefsson.org> + + * build-aux/git-version-gen: Add --help and --version. + 2011-11-12 Jim Meyering <meyer...@redhat.com> revamp the other test-exclude?.sh scripts to use init.sh, too diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 168d81a..3234bdd 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,6 +1,6 @@ #!/bin/sh # Print a version string. -scriptversion=2011-08-11.12; # UTC +scriptversion=2011-11-13.10; # UTC # Copyright (C) 2007-2011 Free Software Foundation, Inc. # @@ -69,15 +69,55 @@ scriptversion=2011-08-11.12; # UTC # dist-hook: # echo $(VERSION) > $(distdir)/.tarball-version -case $# in - 1|2) ;; - *) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version" \ - '[TAG-NORMALIZATION-SED-SCRIPT]' - exit 1;; -esac -tarball_version_file=$1 -tag_sed_script="${2:-s/x/x/}" +me=$0 + +version="git-version-gen $scriptversion + +Copyright 2011 Free Software Foundation, Inc. +There is NO warranty. You may redistribute this software +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING." + +usage="\ +Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] +Print a version string. + +Options: + + --help display this help and exit + --version output version information and exit + +Running without arguments will suffice in most cases." + +while test $# -gt 0; do + case $1 in + --help) echo "$usage"; exit 0;; + --version) echo "$version"; exit 0;; + -*) + echo "$0: Unknown option \`$1'." >&2 + echo "$0: Try \`--help' for more information." >&2 + exit 1;; + *) + if test -z "$tarball_version_file"; then + tarball_version_file="$1" + elif test -z "$tag_sed_script"; then + tag_sed_script="$1" + else + echo "$0: extra non-option argument \`$1'." >&2 + exit 1 + fi;; + esac + shift +done + +if test -z "$tarball_version_file"; then + echo "$usage" + exit 1 +fi + +tag_sed_script="${tag_sed_script:-s/x/x/}" + nl=' ' -- 1.7.2.5