@matheusbsbs / matheus-bagliano / commits / c3c8835fbb
Fork 0

Builtin git-init-db

Basically this just renames init-db.c to builtin-init-db.c and makes some strings const. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Timo Hirvonen committed May 19, 2006 at 13:03 UTC c3c8835fbb182d971d71939b9a3ec7c8b86d6caf
4 files changed +15 -12
Makefile
+6 -7
@@ -154,7 +154,7 @@ PROGRAMS = \
154 git-convert-objects$X git-diff-files$X \
155 git-diff-index$X git-diff-stages$X \
156 git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
157 - git-hash-object$X git-index-pack$X git-init-db$X git-local-fetch$X \
157 + git-hash-object$X git-index-pack$X git-local-fetch$X \
158 git-ls-files$X git-ls-tree$X git-mailinfo$X git-merge-base$X \
159 git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
160 git-peek-remote$X git-prune-packed$X git-read-tree$X \
@@ -170,7 +170,8 @@ PROGRAMS = \
170
171 BUILT_INS = git-log$X git-whatchanged$X git-show$X \
172 git-count-objects$X git-diff$X git-push$X \
173 - git-grep$X git-rev-list$X git-check-ref-format$X
173 + git-grep$X git-rev-list$X git-check-ref-format$X \
174 + git-init-db$X
175
176 # what 'all' will build and 'install' will install, in gitexecdir
177 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@ -218,7 +219,8 @@ LIB_OBJS = \
219
220 BUILTIN_OBJS = \
221 builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
221 - builtin-grep.o builtin-rev-list.o builtin-check-ref-format.o
222 + builtin-grep.o builtin-rev-list.o builtin-check-ref-format.o \
223 + builtin-init-db.o
224
225 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
226 LIBS = $(GITLIBS) -lz
@@ -473,6 +475,7 @@ strip: $(PROGRAMS) git$X
475
476 git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS)
477 $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
478 + -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' \
479 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
480 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
481
@@ -565,10 +568,6 @@ git-http-push$X: revision.o http.o http-push.o $(LIB_FILE)
568 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
569 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
570
568 -init-db.o: init-db.c
569 - $(CC) -c $(ALL_CFLAGS) \
570 - -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $*.c
571 -
571 $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
572 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(GITLIBS)
573 $(DIFF_OBJS): diffcore.h
builtin-init-db.c renamed
+7 -5
@@ -4,6 +4,7 @@
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 #include "cache.h"
7 +#include "builtin.h"
8
9 #ifndef DEFAULT_GIT_TEMPLATE_DIR
10 #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/"
@@ -116,7 +117,7 @@ static void copy_templates_1(char *path, int baselen,
117 }
118 }
119
119 -static void copy_templates(const char *git_dir, int len, char *template_dir)
120 +static void copy_templates(const char *git_dir, int len, const char *template_dir)
121 {
122 char path[PATH_MAX];
123 char template_path[PATH_MAX];
@@ -163,7 +164,7 @@ static void copy_templates(const char *git_dir, int len, char *template_dir)
164 closedir(dir);
165 }
166
166 -static void create_default_files(const char *git_dir, char *template_path)
167 +static void create_default_files(const char *git_dir, const char *template_path)
168 {
169 unsigned len = strlen(git_dir);
170 static char path[PATH_MAX];
@@ -234,15 +235,16 @@ static const char init_db_usage[] =
235 * On the other hand, it might just make lookup slower and messier. You
236 * be the judge. The default case is to have one DB per managed directory.
237 */
237 -int main(int argc, char **argv)
238 +int cmd_init_db(int argc, const char **argv, char **envp)
239 {
240 const char *git_dir;
241 const char *sha1_dir;
241 - char *path, *template_dir = NULL;
242 + const char *template_dir = NULL;
243 + char *path;
244 int len, i;
245
246 for (i = 1; i < argc; i++, argv++) {
245 - char *arg = argv[1];
247 + const char *arg = argv[1];
248 if (!strncmp(arg, "--template=", 11))
249 template_dir = arg+11;
250 else if (!strcmp(arg, "--shared"))
builtin.h
+1
@@ -26,5 +26,6 @@ extern int cmd_push(int argc, const char **argv, char **envp);
26 extern int cmd_grep(int argc, const char **argv, char **envp);
27 extern int cmd_rev_list(int argc, const char **argv, char **envp);
28 extern int cmd_check_ref_format(int argc, const char **argv, char **envp);
29 +extern int cmd_init_db(int argc, const char **argv, char **envp);
30
31 #endif
git.c
+1
@@ -51,6 +51,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
51 { "diff", cmd_diff },
52 { "grep", cmd_grep },
53 { "rev-list", cmd_rev_list },
54 + { "init-db", cmd_init_db },
55 { "check-ref-format", cmd_check_ref_format }
56 };
57 int i;