~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to build-aux/git-version-gen

  • Committer: Colin Watson
  • Date: 2013-10-30 15:48:33 UTC
  • mfrom: (8.3.5 sid)
  • Revision ID: cjwatson@canonical.com-20131030154833-xdt6e1yfffqom1c4
merge from Debian 8.21-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
# Print a version string.
3
 
scriptversion=2012-03-18.17; # UTC
 
3
scriptversion=2012-12-31.23; # UTC
4
4
 
5
 
# Copyright (C) 2007-2012 Free Software Foundation, Inc.
 
5
# Copyright (C) 2007-2013 Free Software Foundation, Inc.
6
6
#
7
7
# This program is free software: you can redistribute it and/or modify
8
8
# it under the terms of the GNU General Public License as published by
86
86
Options:
87
87
 
88
88
   --prefix           prefix of git tags (default 'v')
 
89
   --fallback         fallback version to use if \"git --version\" fails
89
90
 
90
91
   --help             display this help and exit
91
92
   --version          output version information and exit
93
94
Running without arguments will suffice in most cases."
94
95
 
95
96
prefix=v
 
97
fallback=
96
98
 
97
99
while test $# -gt 0; do
98
100
  case $1 in
99
101
    --help) echo "$usage"; exit 0;;
100
102
    --version) echo "$version"; exit 0;;
101
103
    --prefix) shift; prefix="$1";;
 
104
    --fallback) shift; fallback="$1";;
102
105
    -*)
103
106
      echo "$0: Unknown option '$1'." >&2
104
107
      echo "$0: Try '--help' for more information." >&2
105
108
      exit 1;;
106
109
    *)
107
 
      if test -z "$tarball_version_file"; then
 
110
      if test "x$tarball_version_file" = x; then
108
111
        tarball_version_file="$1"
109
 
      elif test -z "$tag_sed_script"; then
 
112
      elif test "x$tag_sed_script" = x; then
110
113
        tag_sed_script="$1"
111
114
      else
112
115
        echo "$0: extra non-option argument '$1'." >&2
116
119
  shift
117
120
done
118
121
 
119
 
if test -z "$tarball_version_file"; then
 
122
if test "x$tarball_version_file" = x; then
120
123
    echo "$usage"
121
124
    exit 1
122
125
fi
140
143
        [0-9]*) ;;
141
144
        *) v= ;;
142
145
    esac
143
 
    test -z "$v" \
 
146
    test "x$v" = x \
144
147
        && echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2
145
148
fi
146
149
 
147
 
if test -n "$v"
 
150
if test "x$v" != x
148
151
then
149
152
    : # use $v
150
153
# Otherwise, if there is at least one git commit involving the working
184
187
    # Remove the "g" in git describe's output string, to save a byte.
185
188
    v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
186
189
    v_from_git=1
 
190
elif test "x$fallback" = x || git --version >/dev/null 2>&1; then
 
191
    v=UNKNOWN
187
192
else
188
 
    v=UNKNOWN
 
193
    v=$fallback
189
194
fi
190
195
 
191
196
v=`echo "$v" |sed "s/^$prefix//"`
193
198
# Test whether to append the "-dirty" suffix only if the version
194
199
# string we're using came from git.  I.e., skip the test if it's "UNKNOWN"
195
200
# or if it came from .tarball-version.
196
 
if test -n "$v_from_git"; then
 
201
if test "x$v_from_git" != x; then
197
202
  # Don't declare a version "dirty" merely because a time stamp has changed.
198
203
  git update-index --refresh > /dev/null 2>&1
199
204