Skip to content

Commit 816fb46

Browse files
peffgitster
authored andcommitted
move git_version_string into version.c
The global git_version_string currently lives in git.c, but doesn't have anything to do with the git wrapper. Let's move it into its own file, where it will be more appropriate to build more version-related functions. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5498c5f commit 816fb46

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ LIB_OBJS += usage.o
799799
LIB_OBJS += userdiff.o
800800
LIB_OBJS += utf8.o
801801
LIB_OBJS += varint.o
802+
LIB_OBJS += version.o
802803
LIB_OBJS += walker.o
803804
LIB_OBJS += wrapper.o
804805
LIB_OBJS += write_or_die.o
@@ -1962,7 +1963,7 @@ strip: $(PROGRAMS) git$X
19621963
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
19631964

19641965
git.o: common-cmds.h
1965-
git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \
1966+
git.sp git.s git.o: EXTRA_CPPFLAGS = \
19661967
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
19671968
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
19681969
'-DGIT_INFO_PATH="$(infodir_SQ)"'
@@ -1979,6 +1980,9 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
19791980
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
19801981
'-DGIT_INFO_PATH="$(infodir_SQ)"'
19811982

1983+
version.sp version.s version.o: EXTRA_CPPFLAGS = \
1984+
'-DGIT_VERSION="$(GIT_VERSION)"'
1985+
19821986
$(BUILT_INS): git$X
19831987
$(QUIET_BUILT_IN)$(RM) $@ && \
19841988
ln git$X $@ 2>/dev/null || \
@@ -2089,7 +2093,7 @@ configure: configure.ac
20892093
$(RM) $<+
20902094

20912095
# These can record GIT_VERSION
2092-
git.o git.spec http.o \
2096+
version.o git.spec http.o \
20932097
$(patsubst %.sh,%,$(SCRIPT_SH)) \
20942098
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
20952099
: GIT-VERSION-FILE

builtin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#define DEFAULT_MERGE_LOG_LEN 20
1111

12-
extern const char git_version_string[];
1312
extern const char git_usage_string[];
1413
extern const char git_more_info_string[];
1514

builtin/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "parse-options.h"
2222
#include "branch.h"
2323
#include "streaming.h"
24+
#include "version.h"
2425

2526
/* Set a default date-time format for git log ("log.date" config variable) */
2627
static const char *default_date_mode = NULL;

git.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ static int handle_alias(int *argcp, const char ***argv)
256256
return ret;
257257
}
258258

259-
const char git_version_string[] = GIT_VERSION;
260-
261259
#define RUN_SETUP (1<<0)
262260
#define RUN_SETUP_GENTLY (1<<1)
263261
#define USE_PAGER (1<<2)

help.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "common-cmds.h"
77
#include "string-list.h"
88
#include "column.h"
9+
#include "version.h"
910

1011
void add_cmdname(struct cmdnames *cmds, const char *name, int len)
1112
{

version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "git-compat-util.h"
2+
#include "version.h"
3+
4+
const char git_version_string[] = GIT_VERSION;

version.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef VERSION_H
2+
#define VERSION_H
3+
4+
extern const char git_version_string[];
5+
6+
#endif /* VERSION_H */

0 commit comments

Comments
 (0)