Mercurial > gnulib
annotate build-aux/git-version-gen @ 16234:f9b906545e2f
Use ', not `, for quoting output.
* build-aux/announce-gen (usage, sizes, print_news_deltas)
(print_changelog_deltas, get_tool_versions, main program):
* build-aux/git-version-gen:
* build-aux/gitlog-to-changelog (usage, parse_amend_file):
* build-aux/move-if-change (help):
* build-aux/useless-if-before-free (usage, main program):
* check-module (parse_module_file, usage)
(find_included_lib_files, check_module):
* lib/argmatch.c (main) [TEST]:
* lib/argp-help.c (_help):
* lib/getopt1.c (main) [TEST]:
* lib/git-merge-changelog.c (usage):
* lib/xstrtol-error.c (xstrtol_error):
* m4/alloca.m4 (_AC_LIBOBJ_ALLOCA):
* m4/argz.m4 (gl_FUNC_ARGZ):
* m4/bison.m4 (gl_BISON):
* m4/calloc.m4 (gl_FUNC_CALLOC_GNU):
* m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS):
* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER):
* m4/fpending.m4 (gl_PREREQ_FPENDING):
* m4/gc-random.m4 (gl_GC_RANDOM):
* m4/intl.m4 (gt_CHECK_DECL):
* m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK):
* m4/longlong.m4 (AC_TYPE_LONG_LONG_INT)
(AC_TYPE_UNSIGNED_LONG_LONG_INT):
* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS):
* m4/lstat.m4 (gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK):
* m4/onceonly.m4 (AC_CHECK_FUNCS_ONCE):
* m4/posixver.m4 (gl_DEFAULT_POSIX2_VERSION):
* tests/test-dirname.c (main):
* tests/test-getpass.c (main):
* tests/test-iconvme.c (main):
* tests/test-parse-datetime.c (LOG):
* tests/test-xstrtoimax.sh:
* tests/test-xstrtol.sh:
* tests/test-xstrtoll.sh:
* tests/test-xstrtoumax.sh:
* tests/unigbrk/test-uc-is-grapheme-break.c (main):
* top/GNUmakefile (abort-due-to-no-makefile):
Quote 'like this', not `like this', as per the recent change to
the GNU coding standards.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 05 Jan 2012 23:44:15 -0800 |
parents | 8250f2777afc |
children | bd179cf2c9ea |
rev | line source |
---|---|
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
1 #!/bin/sh |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
2 # Print a version string. |
16234
f9b906545e2f
Use ', not `, for quoting output.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
3 scriptversion=2012-01-06.07; # UTC |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
4 |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
16084
diff
changeset
|
5 # Copyright (C) 2007-2012 Free Software Foundation, Inc. |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
6 # |
11986
ff87a690cd47
Fix copyright header in build-aux scripts.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents:
9877
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
8 # it under the terms of the GNU General Public License as published by |
11986
ff87a690cd47
Fix copyright header in build-aux scripts.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents:
9877
diff
changeset
|
9 # the Free Software Foundation; either version 3 of the License, or |
ff87a690cd47
Fix copyright header in build-aux scripts.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents:
9877
diff
changeset
|
10 # (at your option) any later version. |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
11 # |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
15 # GNU General Public License for more details. |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
16 # |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU General Public License |
11986
ff87a690cd47
Fix copyright header in build-aux scripts.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
parents:
9877
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
19 |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
20 # This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/. |
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
21 # It may be run two ways: |
9677
54e86898dd7d
* build-aux/git-version-gen: Use "git status", not "git-status".
Jim Meyering <meyering@redhat.com>
parents:
9452
diff
changeset
|
22 # - from a git repository in which the "git describe" command below |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
23 # produces useful output (thus requiring at least one signed tag) |
9748
c0c8409cb7a2
* build-aux/git-version-gen: Adjust a comment and the Usage string.
Jim Meyering <meyering@redhat.com>
parents:
9719
diff
changeset
|
24 # - from a non-git-repo directory containing a .tarball-version file, which |
9677
54e86898dd7d
* build-aux/git-version-gen: Use "git status", not "git-status".
Jim Meyering <meyering@redhat.com>
parents:
9452
diff
changeset
|
25 # presumes this script is invoked like "./git-version-gen .tarball-version". |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
26 |
9869 | 27 # In order to use intra-version strings in your project, you will need two |
28 # separate generated version string files: | |
29 # | |
30 # .tarball-version - present only in a distribution tarball, and not in | |
31 # a checked-out repository. Created with contents that were learned at | |
32 # the last time autoconf was run, and used by git-version-gen. Must not | |
33 # be present in either $(srcdir) or $(builddir) for git-version-gen to | |
34 # give accurate answers during normal development with a checked out tree, | |
35 # but must be present in a tarball when there is no version control system. | |
36 # Therefore, it cannot be used in any dependencies. GNUmakefile has | |
37 # hooks to force a reconfigure at distribution time to get the value | |
38 # correct, without penalizing normal development with extra reconfigures. | |
39 # | |
40 # .version - present in a checked-out repository and in a distribution | |
41 # tarball. Usable in dependencies, particularly for files that don't | |
42 # want to depend on config.h but do want to track version changes. | |
43 # Delete this file prior to any autoconf run where you want to rebuild | |
44 # files to pick up a version string change; and leave it stale to | |
45 # minimize rebuild time after unrelated changes to configure sources. | |
46 # | |
15511
52b887a92a8c
git-version-gen: correct the advice in a comment
Jim Meyering <meyering@redhat.com>
parents:
15492
diff
changeset
|
47 # As with any generated file in a VC'd directory, you should add |
52b887a92a8c
git-version-gen: correct the advice in a comment
Jim Meyering <meyering@redhat.com>
parents:
15492
diff
changeset
|
48 # /.version to .gitignore, so that you don't accidentally commit it. |
52b887a92a8c
git-version-gen: correct the advice in a comment
Jim Meyering <meyering@redhat.com>
parents:
15492
diff
changeset
|
49 # .tarball-version is never generated in a VC'd directory, so needn't |
52b887a92a8c
git-version-gen: correct the advice in a comment
Jim Meyering <meyering@redhat.com>
parents:
15492
diff
changeset
|
50 # be listed there. |
9869 | 51 # |
52 # Use the following line in your configure.ac, so that $(VERSION) will | |
53 # automatically be up-to-date each time configure is run (and note that | |
54 # since configure.ac no longer includes a version string, Makefile rules | |
55 # should not depend on configure.ac for version updates). | |
56 # | |
57 # AC_INIT([GNU project], | |
58 # m4_esyscmd([build-aux/git-version-gen .tarball-version]), | |
59 # [bug-project@example]) | |
60 # | |
61 # Then use the following lines in your Makefile.am, so that .version | |
15492
b54bff314db1
git-version-gen: document that EXTRA_DIST must include .version
Iain Nicol <iain@iainnicol.com>
parents:
14372
diff
changeset
|
62 # will be present for dependencies, and so that .version and |
b54bff314db1
git-version-gen: document that EXTRA_DIST must include .version
Iain Nicol <iain@iainnicol.com>
parents:
14372
diff
changeset
|
63 # .tarball-version will exist in distribution tarballs. |
9869 | 64 # |
15492
b54bff314db1
git-version-gen: document that EXTRA_DIST must include .version
Iain Nicol <iain@iainnicol.com>
parents:
14372
diff
changeset
|
65 # EXTRA_DIST = $(top_srcdir)/.version |
9869 | 66 # BUILT_SOURCES = $(top_srcdir)/.version |
67 # $(top_srcdir)/.version: | |
68 # echo $(VERSION) > $@-t && mv $@-t $@ | |
69 # dist-hook: | |
70 # echo $(VERSION) > $(distdir)/.tarball-version | |
71 | |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
72 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
73 me=$0 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
74 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
75 version="git-version-gen $scriptversion |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
76 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
77 Copyright 2011 Free Software Foundation, Inc. |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
78 There is NO warranty. You may redistribute this software |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
79 under the terms of the GNU General Public License. |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
80 For more information about these matters, see the files named COPYING." |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
81 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
82 usage="\ |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
83 Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
84 Print a version string. |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
85 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
86 Options: |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
87 |
16083
1b52ba2f7e83
git-version-gen: Add --prefix.
Simon Josefsson <simon@josefsson.org>
parents:
16082
diff
changeset
|
88 --prefix prefix of git tags (default 'v') |
1b52ba2f7e83
git-version-gen: Add --prefix.
Simon Josefsson <simon@josefsson.org>
parents:
16082
diff
changeset
|
89 |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
90 --help display this help and exit |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
91 --version output version information and exit |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
92 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
93 Running without arguments will suffice in most cases." |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
94 |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
95 while test $# -gt 0; do |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
96 case $1 in |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
97 --help) echo "$usage"; exit 0;; |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
98 --version) echo "$version"; exit 0;; |
16083
1b52ba2f7e83
git-version-gen: Add --prefix.
Simon Josefsson <simon@josefsson.org>
parents:
16082
diff
changeset
|
99 --prefix) shift; prefix="$1";; |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
100 -*) |
16234
f9b906545e2f
Use ', not `, for quoting output.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
101 echo "$0: Unknown option '$1'." >&2 |
f9b906545e2f
Use ', not `, for quoting output.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
102 echo "$0: Try '--help' for more information." >&2 |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
103 exit 1;; |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
104 *) |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
105 if test -z "$tarball_version_file"; then |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
106 tarball_version_file="$1" |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
107 elif test -z "$tag_sed_script"; then |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
108 tag_sed_script="$1" |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
109 else |
16234
f9b906545e2f
Use ', not `, for quoting output.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
110 echo "$0: extra non-option argument '$1'." >&2 |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
111 exit 1 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
112 fi;; |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
113 esac |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
114 shift |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
115 done |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
116 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
117 if test -z "$tarball_version_file"; then |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
118 echo "$usage" |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
119 exit 1 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
120 fi |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
121 |
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
122 tag_sed_script="${tag_sed_script:-s/x/x/}" |
16083
1b52ba2f7e83
git-version-gen: Add --prefix.
Simon Josefsson <simon@josefsson.org>
parents:
16082
diff
changeset
|
123 prefix="${prefix:-v}" |
16082
0da13ca4fc80
git-version: Improve command line handling.
Simon Josefsson <simon@josefsson.org>
parents:
15511
diff
changeset
|
124 |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
125 nl=' |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
126 ' |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
127 |
13423
ba0385f65ed2
git-version-gen: init shell var to avoid env var influence
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
13379
diff
changeset
|
128 # Avoid meddling by environment variable of the same name. |
ba0385f65ed2
git-version-gen: init shell var to avoid env var influence
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
13379
diff
changeset
|
129 v= |
14372
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
130 v_from_git= |
13423
ba0385f65ed2
git-version-gen: init shell var to avoid env var influence
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
13379
diff
changeset
|
131 |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
132 # First see if there is a tarball-only version file. |
9677
54e86898dd7d
* build-aux/git-version-gen: Use "git status", not "git-status".
Jim Meyering <meyering@redhat.com>
parents:
9452
diff
changeset
|
133 # then try "git describe", then default. |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
134 if test -f $tarball_version_file |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
135 then |
14093
bae3b310c970
git-version-gen: include command name in one more diagnostic
Jim Meyering <meyering@redhat.com>
parents:
14079
diff
changeset
|
136 v=`cat $tarball_version_file` || v= |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
137 case $v in |
14095
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
138 *$nl*) v= ;; # reject multi-line output |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
139 [0-9]*) ;; |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
140 *) v= ;; |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
141 esac |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
142 test -z "$v" \ |
14095
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
143 && echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2 |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
144 fi |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
145 |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
146 if test -n "$v" |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
147 then |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
148 : # use $v |
13803
112326beb7c3
git-version-gen: do require git-VC'd files in cwd
Jim Meyering <meyering@redhat.com>
parents:
13800
diff
changeset
|
149 # Otherwise, if there is at least one git commit involving the working |
112326beb7c3
git-version-gen: do require git-VC'd files in cwd
Jim Meyering <meyering@redhat.com>
parents:
13800
diff
changeset
|
150 # directory, and "git describe" output looks sensible, use that to |
112326beb7c3
git-version-gen: do require git-VC'd files in cwd
Jim Meyering <meyering@redhat.com>
parents:
13800
diff
changeset
|
151 # derive a version string. |
112326beb7c3
git-version-gen: do require git-VC'd files in cwd
Jim Meyering <meyering@redhat.com>
parents:
13800
diff
changeset
|
152 elif test "`git log -1 --pretty=format:x . 2>&1`" = x \ |
16083
1b52ba2f7e83
git-version-gen: Add --prefix.
Simon Josefsson <simon@josefsson.org>
parents:
16082
diff
changeset
|
153 && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \ |
14095
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
154 || git describe --abbrev=4 HEAD 2>/dev/null` \ |
13379
d62002e5d9f4
git-version-gen: take a sed script to transform the git tag
Ludovic Courtès <ludo@gnu.org>
parents:
13273
diff
changeset
|
155 && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \ |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
156 && case $v in |
16084
8c88dd7eb4fb
Fix for last commit.
Simon Josefsson <simon@josefsson.org>
parents:
16083
diff
changeset
|
157 $prefix[0-9]*) ;; |
14095
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
158 *) (exit 1) ;; |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
159 esac |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
160 then |
9719
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
161 # Is this a new git that lists number of commits since the last |
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
162 # tag or the previous older version that did not? |
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
163 # Newer: v6.10-77-g0f8faeb |
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
164 # Older: v6.10-g0f8faeb |
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
165 case $v in |
14095
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
166 *-*-*) : git describe is okay three part flavor ;; |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
167 *-*) |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
168 : git describe is older two part flavor |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
169 # Recreate the number of commits and rewrite such that the |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
170 # result is the same as if we were using the newer version |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
171 # of git describe. |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
172 vtag=`echo "$v" | sed 's/-.*//'` |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
173 commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \ |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
174 || { commit_list=failed; |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
175 echo "$0: WARNING: git rev-list failed" 1>&2; } |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
176 numcommits=`echo "$commit_list" | wc -l` |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
177 v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`; |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
178 test "$commit_list" = failed && v=UNKNOWN |
a6c3d8a0de24
git-version-gen: convert leading TABs to spaces
Jim Meyering <meyering@redhat.com>
parents:
14094
diff
changeset
|
179 ;; |
9719
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
180 esac |
ec87f62b97b8
Enable use of older two part flavor 'git describe'.
Bob Proulx <bob@proulx.com>
parents:
9677
diff
changeset
|
181 |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
182 # Change the first '-' to a '.', so version-comparing tools work properly. |
9677
54e86898dd7d
* build-aux/git-version-gen: Use "git status", not "git-status".
Jim Meyering <meyering@redhat.com>
parents:
9452
diff
changeset
|
183 # Remove the "g" in git describe's output string, to save a byte. |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
184 v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`; |
14372
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
185 v_from_git=1 |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
186 else |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
187 v=UNKNOWN |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
188 fi |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
189 |
16083
1b52ba2f7e83
git-version-gen: Add --prefix.
Simon Josefsson <simon@josefsson.org>
parents:
16082
diff
changeset
|
190 v=`echo "$v" |sed "s/^$prefix//"` |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
191 |
14372
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
192 # Test whether to append the "-dirty" suffix only if the version |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
193 # string we're using came from git. I.e., skip the test if it's "UNKNOWN" |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
194 # or if it came from .tarball-version. |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
195 if test -n "$v_from_git"; then |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
196 # Don't declare a version "dirty" merely because a time stamp has changed. |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
197 git update-index --refresh > /dev/null 2>&1 |
9452
595a77da32de
git-version-gen: sync from coreutils.
Jim Meyering <meyering@redhat.com>
parents:
9175
diff
changeset
|
198 |
14372
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
199 dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty= |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
200 case "$dirty" in |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
201 '') ;; |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
202 *) # Append the suffix only if there isn't one already. |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
203 case $v in |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
204 *-dirty) ;; |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
205 *) v="$v-dirty" ;; |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
206 esac ;; |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
207 esac |
b894b1646164
git-version-gen: skip "-dirty" check when appropriate
Jim Meyering <meyering@redhat.com>
parents:
14133
diff
changeset
|
208 fi |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
209 |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
210 # Omit the trailing newline, so that m4_esyscmd can use the result directly. |
13273
27dad1e1ab9b
git-version-gen: aesthetic tweak
Jim Meyering <meyering@redhat.com>
parents:
13272
diff
changeset
|
211 echo "$v" | tr -d "$nl" |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
212 |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
213 # Local variables: |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
214 # eval: (add-hook 'write-file-hooks 'time-stamp) |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
215 # time-stamp-start: "scriptversion=" |
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
216 # time-stamp-format: "%:y-%02m-%02d.%02H" |
12902
74f6f4021fe0
bootstrap, git-version-gen: use timestamp
Eric Blake <eblake@redhat.com>
parents:
12825
diff
changeset
|
217 # time-stamp-time-zone: "UTC" |
74f6f4021fe0
bootstrap, git-version-gen: use timestamp
Eric Blake <eblake@redhat.com>
parents:
12825
diff
changeset
|
218 # time-stamp-end: "; # UTC" |
9175
c7f825e034ad
* build-aux/git-version-gen: New file, from coreutils. For details, see
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
219 # End: |