From 673dc837e4491819010b788fa758a84710a7a15e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 2 Sep 2007 22:42:45 +0000 Subject: [PATCH] * build-aux/git-version-gen: New file, from coreutils. For details, see http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=bfe49f506 --- ChangeLog | 5 +++ build-aux/git-version-gen | 83 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 build-aux/git-version-gen diff --git a/ChangeLog b/ChangeLog index 36c755d953..5be094cc95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-03 Jim Meyering + + * build-aux/git-version-gen: New file, from coreutils. For details, see + http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=bfe49f506 + 2007-09-02 Bruno Haible Fix mis-recognition of 'mcs' on QNX 6. diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen new file mode 100755 index 0000000000..5701dcf8b8 --- /dev/null +++ b/build-aux/git-version-gen @@ -0,0 +1,83 @@ +#!/bin/sh +# Print a version string. +# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/. +scriptversion=2007-06-30.12 + +# Copyright (C) 2007 Free Software Foundation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +case $# in + 2) ;; + *) echo 1>&2 "Usage: $0 \$VERSION \$srcdir/.version"; exit 1;; +esac + +default_version=$1 +tarball_version_file=$2 +nl=' +' + +# First see if there is a tarball-only version file. +# then try git-describe, then default. +if test -f $tarball_version_file +then + v=`cat $tarball_version_file` || exit 1 + case $v in + *$nl*) v= ;; # reject multi-line output + [0-9]*) ;; + *) v= ;; + esac + test -z "$v" \ + && echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2 +fi + +if test -n "$v" +then + : # use $v +elif test -d .git \ + && v=`git describe --abbrev=4 HEAD 2>/dev/null` \ + && case $v in + v[0-9]*) ;; + *) (exit 1) ;; + esac +then + # Remove the "g" in git-describe's output string; change each - to a '.' + v=`echo "$v" | sed 's/\(.*\)-g/\1-/;s/-/./g'`; +else + v=$default_version +fi + +v=`echo "$v" |sed 's/^v//'` + +dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty= +case "$dirty" in + '') ;; + *) # Append the suffix only if there isn't one already. + case $v in + *-dirty) ;; + *) v="$v-dirty" ;; + esac ;; +esac + +# Omit the trailing newline, so that m4_esyscmd can use the result directly. +echo "$v" | tr -d '\012' + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: -- 2.30.2