1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-09 11:46:11 +02:00

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
This commit is contained in:
Junio C Hamano 2017-12-28 14:08:47 -08:00
commit 58d1772c85
4 changed files with 20 additions and 1 deletions

View File

@ -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) $@ && \

6
help.c
View File

@ -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? */
}

View File

@ -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)
{

View File

@ -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);