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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 2, 2012 at 14:51 UTC 816fb46be665c8b63647f0096845fef363736b20
7 files changed +18 -5
Makefile
+6 -2
@@ -799,6 +799,7 @@ LIB_OBJS += usage.o
799 LIB_OBJS += userdiff.o
800 LIB_OBJS += utf8.o
801 LIB_OBJS += varint.o
802 +LIB_OBJS += version.o
803 LIB_OBJS += walker.o
804 LIB_OBJS += wrapper.o
805 LIB_OBJS += write_or_die.o
@@ -1962,7 +1963,7 @@ strip: $(PROGRAMS) git$X
1963 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1964
1965 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 = \
1967 '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1968 '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1969 '-DGIT_INFO_PATH="$(infodir_SQ)"'
@@ -1979,6 +1980,9 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
1980 '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1981 '-DGIT_INFO_PATH="$(infodir_SQ)"'
1982
1983 +version.sp version.s version.o: EXTRA_CPPFLAGS = \
1984 + '-DGIT_VERSION="$(GIT_VERSION)"'
1985 +
1986 $(BUILT_INS): git$X
1987 $(QUIET_BUILT_IN)$(RM) $@ && \
1988 ln git$X $@ 2>/dev/null || \
@@ -2089,7 +2093,7 @@ configure: configure.ac
2093 $(RM) $<+
2094
2095 # These can record GIT_VERSION
2092 -git.o git.spec http.o \
2096 +version.o git.spec http.o \
2097 $(patsubst %.sh,%,$(SCRIPT_SH)) \
2098 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
2099 : GIT-VERSION-FILE
builtin.h
-1
@@ -9,7 +9,6 @@
9
10 #define DEFAULT_MERGE_LOG_LEN 20
11
12 -extern const char git_version_string[];
12 extern const char git_usage_string[];
13 extern const char git_more_info_string[];
14
builtin/log.c
+1
@@ -21,6 +21,7 @@
21 #include "parse-options.h"
22 #include "branch.h"
23 #include "streaming.h"
24 +#include "version.h"
25
26 /* Set a default date-time format for git log ("log.date" config variable) */
27 static const char *default_date_mode = NULL;
git.c
-2
@@ -256,8 +256,6 @@ static int handle_alias(int *argcp, const char ***argv)
256 return ret;
257 }
258
259 -const char git_version_string[] = GIT_VERSION;
260 -
259 #define RUN_SETUP (1<<0)
260 #define RUN_SETUP_GENTLY (1<<1)
261 #define USE_PAGER (1<<2)
help.c
+1
@@ -6,6 +6,7 @@
6 #include "common-cmds.h"
7 #include "string-list.h"
8 #include "column.h"
9 +#include "version.h"
10
11 void add_cmdname(struct cmdnames *cmds, const char *name, int len)
12 {
version.c new
+4
@@ -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 new
+6
@@ -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 */