Skip to content

Commit

Permalink
move git_version_string into version.c
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
peff authored and gitster committed Jun 3, 2012
1 parent 5498c5f commit 816fb46
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ LIB_OBJS += usage.o
LIB_OBJS += userdiff.o
LIB_OBJS += utf8.o
LIB_OBJS += varint.o
LIB_OBJS += version.o
LIB_OBJS += walker.o
LIB_OBJS += wrapper.o
LIB_OBJS += write_or_die.o
Expand Down Expand Up @@ -1962,7 +1963,7 @@ strip: $(PROGRAMS) git$X
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X

git.o: common-cmds.h
git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \
git.sp git.s git.o: EXTRA_CPPFLAGS = \
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
'-DGIT_INFO_PATH="$(infodir_SQ)"'
Expand All @@ -1979,6 +1980,9 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
'-DGIT_INFO_PATH="$(infodir_SQ)"'

version.sp version.s version.o: EXTRA_CPPFLAGS = \
'-DGIT_VERSION="$(GIT_VERSION)"'

$(BUILT_INS): git$X
$(QUIET_BUILT_IN)$(RM) $@ && \
ln git$X $@ 2>/dev/null || \
Expand Down Expand Up @@ -2089,7 +2093,7 @@ configure: configure.ac
$(RM) $<+

# These can record GIT_VERSION
git.o git.spec http.o \
version.o git.spec http.o \
$(patsubst %.sh,%,$(SCRIPT_SH)) \
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
: GIT-VERSION-FILE
Expand Down
1 change: 0 additions & 1 deletion builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#define DEFAULT_MERGE_LOG_LEN 20

extern const char git_version_string[];
extern const char git_usage_string[];
extern const char git_more_info_string[];

Expand Down
1 change: 1 addition & 0 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "parse-options.h"
#include "branch.h"
#include "streaming.h"
#include "version.h"

/* Set a default date-time format for git log ("log.date" config variable) */
static const char *default_date_mode = NULL;
Expand Down
2 changes: 0 additions & 2 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ static int handle_alias(int *argcp, const char ***argv)
return ret;
}

const char git_version_string[] = GIT_VERSION;

#define RUN_SETUP (1<<0)
#define RUN_SETUP_GENTLY (1<<1)
#define USE_PAGER (1<<2)
Expand Down
1 change: 1 addition & 0 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "common-cmds.h"
#include "string-list.h"
#include "column.h"
#include "version.h"

void add_cmdname(struct cmdnames *cmds, const char *name, int len)
{
Expand Down
4 changes: 4 additions & 0 deletions version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "git-compat-util.h"
#include "version.h"

const char git_version_string[] = GIT_VERSION;
6 changes: 6 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef VERSION_H
#define VERSION_H

extern const char git_version_string[];

#endif /* VERSION_H */

0 comments on commit 816fb46

Please sign in to comment.