Browse Source

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
maint
Junio C Hamano 7 years ago
parent
commit
58d1772c85
  1. 13
      Makefile
  2. 6
      help.c
  3. 1
      version.c
  4. 1
      version.h

13
Makefile

@ -425,6 +425,9 @@ all:: @@ -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 @@ -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 = \ @@ -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

@ -412,6 +412,12 @@ int cmd_version(int argc, const char **argv, const char *prefix) @@ -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? */
}

1
version.c

@ -3,6 +3,7 @@ @@ -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)
{

1
version.h

@ -2,6 +2,7 @@ @@ -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);

Loading…
Cancel
Save