From: Jim Meyering Date: Wed, 13 Oct 2010 14:08:36 +0000 (+0200) Subject: git-version-gen: don't require that .git/ be in the current dir X-Git-Tag: v0.1~3687 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=932cfeb12ac1a06cd8abdad7ed6eb65e6aeb602d;p=gnulib.git git-version-gen: don't require that .git/ be in the current dir * build-aux/git-version-gen: Adjust this script so that it works when run from any working directory beneath the top-level .git/- containing directory. Inspired by a patch from Giusseppe Scrivano, http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/21843/focus=21847 --- diff --git a/ChangeLog b/ChangeLog index e7838e110..9a4ed578f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-10-13 Jim Meyering + git-version-gen: don't require that .git/ be in the current dir + * build-aux/git-version-gen: Adjust this script so that it works + when run from any working directory beneath the top-level .git/- + containing directory. Inspired by a patch from Giusseppe Scrivano, + http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/21843/focus=21847 + test-select: avoid warn_unused_result warnings * tests/test-select.c: Include "macros.h". ASSERT that each call to read, write, and pipe succeeds. diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 5617eb8d4..626277587 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,6 +1,6 @@ #!/bin/sh # Print a version string. -scriptversion=2010-06-14.19; # UTC +scriptversion=2010-10-13.14; # UTC # Copyright (C) 2007-2010 Free Software Foundation, Inc. # @@ -98,7 +98,9 @@ fi if test -n "$v" then : # use $v -elif test -d .git \ +# Otherwise, if we're anywhere beneath a .git directory, and "git describe" +# output looks sensible, use that to derive a version string. +elif git rev-parse --verify HEAD > /dev/null 2>&1 \ && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \ || git describe --abbrev=4 HEAD 2>/dev/null` \ && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \