Skip to content

Commit cfa01e6

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 992bc56 commit cfa01e6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

GIT-VERSION-GEN

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,16 @@ then
5656
GIT_VERSION=$(expr "$VN" : v*'\(.*\)')
5757
fi
5858

59-
GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null)
60-
GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null)
59+
if test -z "$GIT_BUILT_FROM_COMMIT"
60+
then
61+
GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null)
62+
fi
63+
64+
if test -z "$GIT_DATE"
65+
then
66+
GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null)
67+
fi
68+
6169
if test -z "$GIT_USER_AGENT"
6270
then
6371
GIT_USER_AGENT="git/$GIT_VERSION"

shared.mak

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ endef
121121
# absolute path to the root source directory as well as input and output files
122122
# as arguments, in that order.
123123
define version_gen
124+
GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" \
125+
GIT_DATE="$(GIT_DATE)" \
124126
GIT_USER_AGENT="$(GIT_USER_AGENT)" \
125127
GIT_VERSION="$(GIT_VERSION_OVERRIDE)" \
126128
$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)"

0 commit comments

Comments
 (0)