diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-12-28 14:08:47 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-12-28 14:08:47 -0800 |
commit | 58d1772c8562c4777414d9b97de127ae5b35ad81 (patch) | |
tree | b51c125a670e839aa63022723420ac7b99034367 | |
parent | Merge branch 'tz/lib-git-svn-svnserve-tests' (diff) | |
parent | version --build-options: report commit, too, if possible (diff) | |
download | tgif-58d1772c8562c4777414d9b97de127ae5b35ad81.tar.xz |
Merge branch 'js/enhanced-version-info'
"git version --build-options" learned to report the host CPU and
the exact commit object name the binary was built from.
* js/enhanced-version-info:
version --build-options: report commit, too, if possible
version --build-options: also report host CPU
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | help.c | 6 | ||||
-rw-r--r-- | version.c | 1 | ||||
-rw-r--r-- | version.h | 1 |
4 files changed, 20 insertions, 1 deletions
@@ -425,6 +425,9 @@ all:: # # to say "export LESS=FRX (and LV=-c) if the environment variable # LESS (and LV) is not set, respectively". +# +# When cross-compiling, define HOST_CPU as the canonical name of the CPU on +# which the built Git will run (for instance "x86_64"). GIT-VERSION-FILE: FORCE @$(SHELL_PATH) ./GIT-VERSION-GEN @@ -1099,6 +1102,12 @@ else BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d' endif +ifeq (,$(HOST_CPU)) + BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(firstword $(subst -, ,$(uname_M)))\"" +else + BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(HOST_CPU)\"" +endif + ifneq (,$(INLINE)) BASIC_CFLAGS += -Dinline=$(INLINE) endif @@ -1897,7 +1906,9 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT version.sp version.s version.o: EXTRA_CPPFLAGS = \ '-DGIT_VERSION="$(GIT_VERSION)"' \ - '-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' + '-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' \ + '-DGIT_BUILT_FROM_COMMIT="$(shell GIT_CEILING_DIRECTORIES=\"$(CURDIR)/..\" \ + git rev-parse -q --verify HEAD || :)"' $(BUILT_INS): git$X $(QUIET_BUILT_IN)$(RM) $@ && \ @@ -412,6 +412,12 @@ int cmd_version(int argc, const char **argv, const char *prefix) printf("git version %s\n", git_version_string); if (build_options) { + printf("cpu: %s\n", GIT_HOST_CPU); + if (git_built_from_commit_string[0]) + printf("built from commit: %s\n", + git_built_from_commit_string); + else + printf("no commit associated with this build\n"); printf("sizeof-long: %d\n", (int)sizeof(long)); /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */ } @@ -3,6 +3,7 @@ #include "strbuf.h" const char git_version_string[] = GIT_VERSION; +const char git_built_from_commit_string[] = GIT_BUILT_FROM_COMMIT; const char *git_user_agent(void) { @@ -2,6 +2,7 @@ #define VERSION_H extern const char git_version_string[]; +extern const char git_built_from_commit_string[]; const char *git_user_agent(void); const char *git_user_agent_sanitized(void); |