When doing:
- make
- sudo make install
... it is possible for the `sudo make install` command to generate a new
src/common/version.i file, if the regular user has a custom value for
the `core.abbrev` git configuration variable.
The version.i file generated by `make` contains a version number with a
hash of a certain length. Then `sudo make install` generates an
equivalent version number, but with a hash of a different length. This
then causes some object files that depended on it to be rebuilt, which
is not expected for the install target.
To avoid this, add --abbrev=12 to the git describe command that
genenerates the version string, so that the same hash representation is
generated during both "make" and "sudo make install".
Change-Id: I979d6a9d627f133909dc026e0d2820b52f409d98
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Fixes: https://bugs.lttng.org/issues/1376
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10098
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
# And store it in "version.i.tmp", if the current commit is tagged, the tag
# starts with "v" and the tree is clean, consider this a release version and
# overwrite the git version with an empty string in "version.i.tmp".
+#
+# Use an explicit hash abbreviation length, to avoid local `core.abbrev`
+# 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 || true))"
+ GIT_VERSION_STR="$(cd "$TOP_SRCDIR" && (git describe --tags --dirty --abbrev=12 || true))"
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