On 01/03/2011 11:37 AM, Jim Meyering wrote: >> I'll probably end up writing yet a third approach, which collects git >> rev-list output into a temporary variable in order to correctly detect >> failures, without refactoring into a helper function. > > Thanks for forwarding that here. > Here's a lightly tested patch to do what you suggest. > I tried to keep it minimal, since what we're doing here > is solely to accommodate very old versions of git.
You beat me to it, but your approach matches my thoughts.
> @@ -122,8 +122,12 @@ then
> # result is the same as if we were using the newer version
> # of git describe.
> vtag=`echo "$v" | sed 's/-.*//'`
> - numcommits=`git rev-list "$vtag"..HEAD | wc -l`
> + commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \
> + || { commit_list=failed;
> + echo "$0: WARNING: git rev-list failed" 1>&2; }
> + numcommits=`echo "$commit_list" | wc -l`
> v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`;
> + test "$commit_list" = failed && v=UNKNOWN
I like it.
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
