Skip to content

Commit f71510f

Browse files
author
Git for Windows Build Agent
committed
Merge pull request #866 from landstander668/add_platform
Add reporting of build platform
2 parents 63e8583 + 6e40360 commit f71510f

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,9 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
18891889
version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
18901890
version.sp version.s version.o: EXTRA_CPPFLAGS = \
18911891
'-DGIT_VERSION="$(GIT_VERSION)"' \
1892-
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
1892+
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' \
1893+
'-DGIT_BUILT_FROM_COMMIT="$(shell git rev-parse -q --verify HEAD || \
1894+
echo "(unknown)")"'
18931895

18941896
$(BUILT_INS): git$X
18951897
$(QUIET_BUILT_IN)$(RM) $@ && \

help.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ const char *help_unknown_cmd(const char *cmd)
390390

391391
int cmd_version(int argc, const char **argv, const char *prefix)
392392
{
393+
static char build_platform[] = GIT_BUILD_PLATFORM;
393394
int build_options = 0;
394395
const char * const usage[] = {
395396
N_("git version [<options>]"),
@@ -412,7 +413,10 @@ int cmd_version(int argc, const char **argv, const char *prefix)
412413
printf("git version %s\n", git_version_string);
413414

414415
if (build_options) {
416+
printf("built from commit: %s\n",
417+
git_built_from_commit_string);
415418
printf("sizeof-long: %d\n", (int)sizeof(long));
419+
printf("machine: %s\n", build_platform);
416420
/* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
417421
}
418422
return 0;

help.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, stru
3333
*/
3434
extern void help_unknown_ref(const char *ref, const char *cmd, const char *error);
3535
#endif /* HELP_H */
36+
37+
/*
38+
* identify build platform
39+
*/
40+
#ifndef GIT_BUILD_PLATFORM
41+
#if defined __x86__ || defined __i386__ || defined __i586__ || defined __i686__
42+
#define GIT_BUILD_PLATFORM "x86"
43+
#elif defined __x86_64__
44+
#define GIT_BUILD_PLATFORM "x86_64"
45+
#else
46+
#define GIT_BUILD_PLATFORM "unknown"
47+
#endif
48+
#endif

version.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "strbuf.h"
44

55
const char git_version_string[] = GIT_VERSION;
6+
const char git_built_from_commit_string[] = GIT_BUILT_FROM_COMMIT;
67

78
const char *git_user_agent(void)
89
{

version.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define VERSION_H
33

44
extern const char git_version_string[];
5+
extern const char git_built_from_commit_string[];
56

67
const char *git_user_agent(void);
78
const char *git_user_agent_sanitized(void);

0 commit comments

Comments
 (0)