1
0
mirror of https://github.com/git/git.git synced 2025-02-06 09:44:30 +00:00

GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE

Same as with the preceding commit, neither GIT_BUILT_FROM_COMMIT nor
GIT_DATE can be overridden via the environment. Especially the latter is
of importance given that we set it in our own "Documentation/doc-diff"
script.

Make the values of both variables overridable. Luckily we don't pull in
these values via any included Makefiles, so the fix is trivial compared
to the fix for GIT_VERSON.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2024-12-20 20:44:25 +01:00 committed by Junio C Hamano
parent 992bc5618f
commit cfa01e6da5
2 changed files with 12 additions and 2 deletions

View File

@ -56,8 +56,16 @@ then
GIT_VERSION=$(expr "$VN" : v*'\(.*\)')
fi
GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null)
GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null)
if test -z "$GIT_BUILT_FROM_COMMIT"
then
GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null)
fi
if test -z "$GIT_DATE"
then
GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null)
fi
if test -z "$GIT_USER_AGENT"
then
GIT_USER_AGENT="git/$GIT_VERSION"

View File

@ -121,6 +121,8 @@ endef
# absolute path to the root source directory as well as input and output files
# as arguments, in that order.
define version_gen
GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" \
GIT_DATE="$(GIT_DATE)" \
GIT_USER_AGENT="$(GIT_USER_AGENT)" \
GIT_VERSION="$(GIT_VERSION_OVERRIDE)" \
$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)"