mirror of
https://github.com/git/git.git
synced 2024-11-02 07:17:58 +01:00
a7659747c2
The default version name for a Git binary is computed by running "git describe" on the commit the binary is made out of, basing on a tag whose name matches "v[0-9]*", e.g. v2.11.0-rc2-2-g7f1dc9. In the very early days, with9b88fcef7d
("Makefile: use git-describe to mark the git version.", 2005-12-27), we used "--abbrev=4" to get absolute minimum number of abbreviated commit object name. This was later changed to match the default minimum of 7 withbf505158d0
("Git 1.7.10.1", 2012-05-01). These days, the "default minimum" scales automatically depending on the size of the repository, and there is no point in specifying a particular abbreviation length; all we wanted since Git 1.7.10.1 days was to get "something reasonable we would use by default". Just drop "--abbrev=<number>" from the invocation of "git describe" and let the command pick what it thinks is appropriate, taking the end user's configuration and the repository contents into account. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
40 lines
754 B
Bash
Executable file
40 lines
754 B
Bash
Executable file
#!/bin/sh
|
|
|
|
GVF=GIT-VERSION-FILE
|
|
DEF_VER=v2.11.GIT
|
|
|
|
LF='
|
|
'
|
|
|
|
# First see if there is a version file (included in release tarballs),
|
|
# then try git-describe, then default.
|
|
if test -f version
|
|
then
|
|
VN=$(cat version) || VN="$DEF_VER"
|
|
elif test -d ${GIT_DIR:-.git} -o -f .git &&
|
|
VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
|
|
case "$VN" in
|
|
*$LF*) (exit 1) ;;
|
|
v[0-9]*)
|
|
git update-index -q --refresh
|
|
test -z "$(git diff-index --name-only HEAD --)" ||
|
|
VN="$VN-dirty" ;;
|
|
esac
|
|
then
|
|
VN=$(echo "$VN" | sed -e 's/-/./g');
|
|
else
|
|
VN="$DEF_VER"
|
|
fi
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
|
|
|
if test -r $GVF
|
|
then
|
|
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
|
|
else
|
|
VC=unset
|
|
fi
|
|
test "$VN" = "$VC" || {
|
|
echo >&2 "GIT_VERSION = $VN"
|
|
echo "GIT_VERSION = $VN" >$GVF
|
|
}
|