From 0c8d33951400f7d7175e1dad51e970fb70849f2b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 6 Dec 2024 14:24:39 +0100 Subject: Makefile: propagate Git version via generated header We set up a couple of preprocessor macros when compiling Git that propagate the version that Git was built from to `git version` et al. The way this is set up makes it harder than necessary to reuse the infrastructure across the different build systems. Refactor this such that we generate a "version-def.h" header via `GIT-VERSION-GEN` instead. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- GIT-VERSION-GEN | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'GIT-VERSION-GEN') diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 7afc7aad14..c18f24e515 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -52,6 +52,11 @@ else fi GIT_VERSION=$(expr "$VN" : v*'\(.*\)') +GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) +if test -z "$GIT_USER_AGENT" +then + GIT_USER_AGENT="git/$GIT_VERSION" +fi read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION trailing <"$OUTPUT"+ if ! test -f "$OUTPUT" || ! cmp "$OUTPUT"+ "$OUTPUT" >/dev/null -- cgit v1.2.3