With a shallow git clone (a clone done with `--depth=1`),
gen-version-i.sh fails with:
$ TOP_SRCDIR=$PWD ./src/common/gen-version-i.sh
fatal: No names found, cannot describe anything.
The underlying git command that fails is:
$ git describe --tags --dirty --abbrev=12
fatal: No names found, cannot describe anything.
git-describe fails because no tags are available in the shallow clone.
Work around that by using `--always`, which makes git-describe
generate string with only the commit hash as a fallback. In my
non-shallow clone:
$ git describe --tags --dirty --abbrev=12 --always
v1.2.0-3854-g0b538efadd88
And in my shallow clone:
$ git describe --tags --dirty --abbrev=12 --always
0b538efadd88
Change-Id: Ie1c15239497bda248c9742e74a12a14af6e32928
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Thomas Applencourt <tapplencourt@anl.gov>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11073
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
# configurations leading to different results.
if test -r "$TOP_SRCDIR/bootstrap" && test -r "$TOP_SRCDIR/.git" &&
(command -v git > /dev/null 2>&1); then
# configurations leading to different results.
if test -r "$TOP_SRCDIR/bootstrap" && test -r "$TOP_SRCDIR/.git" &&
(command -v git > /dev/null 2>&1); then
- GIT_VERSION_STR="$(cd "$TOP_SRCDIR" && git describe --tags --dirty --abbrev=12)"
+ GIT_VERSION_STR="$(cd "$TOP_SRCDIR" && git describe --always --tags --dirty --abbrev=12)"
GIT_CURRENT_TAG="$(cd "$TOP_SRCDIR" && (git describe --tags --exact-match --match="v[0-9]*" HEAD || true) 2> /dev/null)"
echo "#define BT_VERSION_GIT \"$GIT_VERSION_STR\"" > version.i.tmp
GIT_CURRENT_TAG="$(cd "$TOP_SRCDIR" && (git describe --tags --exact-match --match="v[0-9]*" HEAD || true) 2> /dev/null)"
echo "#define BT_VERSION_GIT \"$GIT_VERSION_STR\"" > version.i.tmp