aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-12-20 20:44:25 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-20 12:36:45 -0800
commitcfa01e6da515e409fdeaf39e50e8c3b7a70405b9 (patch)
tree38d1d643ff7c3000753ecfacb33f347cbb061873
parent992bc5618f2879a8d7f00a60489e78c48e661820 (diff)
downloadgit-cfa01e6da515e409fdeaf39e50e8c3b7a70405b9.tar.gz
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>
-rwxr-xr-xGIT-VERSION-GEN12
-rw-r--r--shared.mak2
2 files changed, 12 insertions, 2 deletions
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 2fee5e7e80..8dc54f6378 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -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"
diff --git a/shared.mak b/shared.mak
index a66f46969e..1a99848a95 100644
--- a/shared.mak
+++ b/shared.mak
@@ -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)"