{"thread":{"id":"3937","subject":"Split up builtin commands into separate files from git.c","startedAt":"2006-04-21T17:27:34Z","lastAt":"2006-04-21T17:27:34Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"18971","messageId":"Pine.LNX.4.64.0604211022440.3701@g5.osdl.org","threadId":"3937","inReplyTo":null,"subject":"Split up builtin commands into separate files from git.c","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-04-21T17:27:34Z","receivedAt":"2006-04-21T17:27:34Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nRight now it split it into \"builtin-log.c\" for log-related commands\n(\"log\", \"show\" and \"whatchanged\"), and \"builtin-help.c\" for the\ninformational commands (usage printing and \"help\" and \"version\").\n\nThis just makes things easier to read, I find.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\n\n[ Hey, make of this what you will. There's no real code changes, except I \n  used that \"git_version_string[]\" variable to make things easier to \n  build, and I renamed \"cmd_wc\" to \"cmd_whatchanged\", since when it's \n  split up into another file, we don't want to have a gratuitous \n  short-hand that we have to remember across files.\n\n  I find things easier to work with the more you split them up along \n  conceptual lines, and as we do more and more built-ins, git.c would end \n  up a horrible mess unless we do _something_ like this.\n\n  But if people don't like it, it's not a big deal. Another throw-away \n  patch from me. ]\n\n Makefile       |    9 +-\n builtin-help.c |  241 ++++++++++++++++++++++++++++++++++++++++++++\n builtin-log.c  |   69 +++++++++++++\n builtin.h      |   23 ++++\n git.c          |  305 +-------------------------------------------------------\n 5 files changed, 342 insertions(+), 305 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 3ecd674..a83c502 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -213,6 +213,9 @@ LIB_OBJS = \\\n \tfetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \\\n \t$(DIFF_OBJS)\n \n+BUILTIN_OBJS = \\\n+\tbuiltin-log.o builtin-help.o\n+\n GITLIBS = $(LIB_FILE) $(XDIFF_LIB)\n LIBS = $(GITLIBS) -lz\n \n@@ -462,10 +465,10 @@ all:\n strip: $(PROGRAMS) git$X\n \t$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X\n \n-git$X: git.c common-cmds.h $(GITLIBS)\n+git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS)\n \t$(CC) -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n \t\t$(ALL_CFLAGS) -o $@ $(filter %.c,$^) \\\n-\t\t$(ALL_LDFLAGS) $(LIBS)\n+\t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n $(BUILT_INS): git$X\n \trm -f $@ && ln git$X $@\n@@ -565,7 +568,7 @@ init-db.o: init-db.c\n \t$(CC) -c $(ALL_CFLAGS) \\\n \t\t-DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"' $*.c\n \n-$(LIB_OBJS): $(LIB_H)\n+$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n $(patsubst git-%$X,%.o,$(PROGRAMS)): $(GITLIBS)\n $(DIFF_OBJS): diffcore.h\n \ndiff --git a/builtin-help.c b/builtin-help.c\nnew file mode 100644\nindex 0000000..10a59cc\n--- /dev/null\n+++ b/builtin-help.c\n@@ -0,0 +1,241 @@\n+/*\n+ * builtin-help.c\n+ *\n+ * Builtin help-related commands (help, usage, version)\n+ */\n+#include \"cache.h\"\n+#include \"builtin.h\"\n+#include \"exec_cmd.h\"\n+#include \"common-cmds.h\"\n+\n+static const char git_usage[] =\n+\t\"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]\";\n+\n+/* most gui terms set COLUMNS (although some don't export it) */\n+static int term_columns(void)\n+{\n+\tchar *col_string = getenv(\"COLUMNS\");\n+\tint n_cols = 0;\n+\n+\tif (col_string && (n_cols = atoi(col_string)) > 0)\n+\t\treturn n_cols;\n+\n+#ifdef TIOCGWINSZ\n+\t{\n+\t\tstruct winsize ws;\n+\t\tif (!ioctl(1, TIOCGWINSZ, &ws)) {\n+\t\t\tif (ws.ws_col)\n+\t\t\t\treturn ws.ws_col;\n+\t\t}\n+\t}\n+#endif\n+\n+\treturn 80;\n+}\n+\n+static void oom(void)\n+{\n+\tfprintf(stderr, \"git: out of memory\\n\");\n+\texit(1);\n+}\n+\n+static inline void mput_char(char c, unsigned int num)\n+{\n+\twhile(num--)\n+\t\tputchar(c);\n+}\n+\n+static struct cmdname {\n+\tsize_t len;\n+\tchar name[1];\n+} **cmdname;\n+static int cmdname_alloc, cmdname_cnt;\n+\n+static void add_cmdname(const char *name, int len)\n+{\n+\tstruct cmdname *ent;\n+\tif (cmdname_alloc <= cmdname_cnt) {\n+\t\tcmdname_alloc = cmdname_alloc + 200;\n+\t\tcmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n+\t\tif (!cmdname)\n+\t\t\toom();\n+\t}\n+\tent = malloc(sizeof(*ent) + len);\n+\tif (!ent)\n+\t\toom();\n+\tent->len = len;\n+\tmemcpy(ent->name, name, len);\n+\tent->name[len] = 0;\n+\tcmdname[cmdname_cnt++] = ent;\n+}\n+\n+static int cmdname_compare(const void *a_, const void *b_)\n+{\n+\tstruct cmdname *a = *(struct cmdname **)a_;\n+\tstruct cmdname *b = *(struct cmdname **)b_;\n+\treturn strcmp(a->name, b->name);\n+}\n+\n+static void pretty_print_string_list(struct cmdname **cmdname, int longest)\n+{\n+\tint cols = 1, rows;\n+\tint space = longest + 1; /* min 1 SP between words */\n+\tint max_cols = term_columns() - 1; /* don't print *on* the edge */\n+\tint i, j;\n+\n+\tif (space < max_cols)\n+\t\tcols = max_cols / space;\n+\trows = (cmdname_cnt + cols - 1) / cols;\n+\n+\tqsort(cmdname, cmdname_cnt, sizeof(*cmdname), cmdname_compare);\n+\n+\tfor (i = 0; i < rows; i++) {\n+\t\tprintf(\"  \");\n+\n+\t\tfor (j = 0; j < cols; j++) {\n+\t\t\tint n = j * rows + i;\n+\t\t\tint size = space;\n+\t\t\tif (n >= cmdname_cnt)\n+\t\t\t\tbreak;\n+\t\t\tif (j == cols-1 || n + rows >= cmdname_cnt)\n+\t\t\t\tsize = 1;\n+\t\t\tprintf(\"%-*s\", size, cmdname[n]->name);\n+\t\t}\n+\t\tputchar('\\n');\n+\t}\n+}\n+\n+static void list_commands(const char *exec_path, const char *pattern)\n+{\n+\tunsigned int longest = 0;\n+\tchar path[PATH_MAX];\n+\tint dirlen;\n+\tDIR *dir = opendir(exec_path);\n+\tstruct dirent *de;\n+\n+\tif (!dir) {\n+\t\tfprintf(stderr, \"git: '%s': %s\\n\", exec_path, strerror(errno));\n+\t\texit(1);\n+\t}\n+\n+\tdirlen = strlen(exec_path);\n+\tif (PATH_MAX - 20 < dirlen) {\n+\t\tfprintf(stderr, \"git: insanely long exec-path '%s'\\n\",\n+\t\t\texec_path);\n+\t\texit(1);\n+\t}\n+\n+\tmemcpy(path, exec_path, dirlen);\n+\tpath[dirlen++] = '/';\n+\n+\twhile ((de = readdir(dir)) != NULL) {\n+\t\tstruct stat st;\n+\t\tint entlen;\n+\n+\t\tif (strncmp(de->d_name, \"git-\", 4))\n+\t\t\tcontinue;\n+\t\tstrcpy(path+dirlen, de->d_name);\n+\t\tif (stat(path, &st) || /* stat, not lstat */\n+\t\t    !S_ISREG(st.st_mode) ||\n+\t\t    !(st.st_mode & S_IXUSR))\n+\t\t\tcontinue;\n+\n+\t\tentlen = strlen(de->d_name);\n+\t\tif (4 < entlen && !strcmp(de->d_name + entlen - 4, \".exe\"))\n+\t\t\tentlen -= 4;\n+\n+\t\tif (longest < entlen)\n+\t\t\tlongest = entlen;\n+\n+\t\tadd_cmdname(de->d_name + 4, entlen-4);\n+\t}\n+\tclosedir(dir);\n+\n+\tprintf(\"git commands available in '%s'\\n\", exec_path);\n+\tprintf(\"----------------------------\");\n+\tmput_char('-', strlen(exec_path));\n+\tputchar('\\n');\n+\tpretty_print_string_list(cmdname, longest - 4);\n+\tputchar('\\n');\n+}\n+\n+static void list_common_cmds_help(void)\n+{\n+\tint i, longest = 0;\n+\n+\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n+\t\tif (longest < strlen(common_cmds[i].name))\n+\t\t\tlongest = strlen(common_cmds[i].name);\n+\t}\n+\n+\tputs(\"The most commonly used git commands are:\");\n+\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n+\t\tprintf(\"    %s\", common_cmds[i].name);\n+\t\tmput_char(' ', longest - strlen(common_cmds[i].name) + 4);\n+\t\tputs(common_cmds[i].help);\n+\t}\n+\tputs(\"(use 'git help -a' to get a list of all installed git commands)\");\n+}\n+\n+void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n+{\n+\tif (fmt) {\n+\t\tva_list ap;\n+\n+\t\tva_start(ap, fmt);\n+\t\tprintf(\"git: \");\n+\t\tvprintf(fmt, ap);\n+\t\tva_end(ap);\n+\t\tputchar('\\n');\n+\t}\n+\telse\n+\t\tputs(git_usage);\n+\n+\tif (exec_path) {\n+\t\tputchar('\\n');\n+\t\tif (show_all)\n+\t\t\tlist_commands(exec_path, \"git-*\");\n+\t\telse\n+\t\t\tlist_common_cmds_help();\n+        }\n+\n+\texit(1);\n+}\n+\n+static void show_man_page(const char *git_cmd)\n+{\n+\tconst char *page;\n+\n+\tif (!strncmp(git_cmd, \"git\", 3))\n+\t\tpage = git_cmd;\n+\telse {\n+\t\tint page_len = strlen(git_cmd) + 4;\n+\t\tchar *p = malloc(page_len + 1);\n+\t\tstrcpy(p, \"git-\");\n+\t\tstrcpy(p + 4, git_cmd);\n+\t\tp[page_len] = 0;\n+\t\tpage = p;\n+\t}\n+\n+\texeclp(\"man\", \"man\", page, NULL);\n+}\n+\n+int cmd_version(int argc, const char **argv, char **envp)\n+{\n+\tprintf(\"git version %s\\n\", git_version_string);\n+\treturn 0;\n+}\n+\n+int cmd_help(int argc, const char **argv, char **envp)\n+{\n+\tconst char *help_cmd = argv[1];\n+\tif (!help_cmd)\n+\t\tcmd_usage(0, git_exec_path(), NULL);\n+\telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\"))\n+\t\tcmd_usage(1, git_exec_path(), NULL);\n+\telse\n+\t\tshow_man_page(help_cmd);\n+\treturn 0;\n+}\n+\n+\ndiff --git a/builtin-log.c b/builtin-log.c\nnew file mode 100644\nindex 0000000..418101d\n--- /dev/null\n+++ b/builtin-log.c\n@@ -0,0 +1,69 @@\n+/*\n+ * Builtin \"git log\" and related commands (show, whatchanged)\n+ *\n+ * (C) Copyright 2006 Linus Torvalds\n+ *\t\t 2006 Junio Hamano\n+ */ \n+#include \"cache.h\"\n+#include \"commit.h\"\n+#include \"diff.h\"\n+#include \"revision.h\"\n+#include \"log-tree.h\"\n+\n+static int cmd_log_wc(int argc, const char **argv, char **envp,\n+\t\t      struct rev_info *rev)\n+{\n+\tstruct commit *commit;\n+\n+\trev->abbrev = DEFAULT_ABBREV;\n+\trev->commit_format = CMIT_FMT_DEFAULT;\n+\trev->verbose_header = 1;\n+\targc = setup_revisions(argc, argv, rev, \"HEAD\");\n+\n+\tif (argc > 1)\n+\t\tdie(\"unrecognized argument: %s\", argv[1]);\n+\n+\tprepare_revision_walk(rev);\n+\tsetup_pager();\n+\twhile ((commit = get_revision(rev)) != NULL) {\n+\t\tlog_tree_commit(rev, commit);\n+\t\tfree(commit->buffer);\n+\t\tcommit->buffer = NULL;\n+\t}\n+\treturn 0;\n+}\n+\n+int cmd_whatchanged(int argc, const char **argv, char **envp)\n+{\n+\tstruct rev_info rev;\n+\n+\tinit_revisions(&rev);\n+\trev.diff = 1;\n+\trev.diffopt.recursive = 1;\n+\treturn cmd_log_wc(argc, argv, envp, &rev);\n+}\n+\n+int cmd_show(int argc, const char **argv, char **envp)\n+{\n+\tstruct rev_info rev;\n+\n+\tinit_revisions(&rev);\n+\trev.diff = 1;\n+\trev.diffopt.recursive = 1;\n+\trev.combine_merges = 1;\n+\trev.dense_combined_merges = 1;\n+\trev.always_show_header = 1;\n+\trev.ignore_merges = 0;\n+\trev.no_walk = 1;\n+\treturn cmd_log_wc(argc, argv, envp, &rev);\n+}\n+\n+int cmd_log(int argc, const char **argv, char **envp)\n+{\n+\tstruct rev_info rev;\n+\n+\tinit_revisions(&rev);\n+\trev.always_show_header = 1;\n+\trev.diffopt.recursive = 1;\n+\treturn cmd_log_wc(argc, argv, envp, &rev);\n+}\ndiff --git a/builtin.h b/builtin.h\nnew file mode 100644\nindex 0000000..47408a0\n--- /dev/null\n+++ b/builtin.h\n@@ -0,0 +1,23 @@\n+#ifndef BUILTIN_H\n+#define BUILTIN_H\n+\n+#ifndef PATH_MAX\n+# define PATH_MAX 4096\n+#endif\n+\n+extern const char git_version_string[];\n+\n+void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n+#ifdef __GNUC__\n+\t__attribute__((__format__(__printf__, 3, 4), __noreturn__))\n+#endif\n+\t;\n+\n+extern int cmd_help(int argc, const char **argv, char **envp);\n+extern int cmd_version(int argc, const char **argv, char **envp);\n+\n+extern int cmd_whatchanged(int argc, const char **argv, char **envp);\n+extern int cmd_show(int argc, const char **argv, char **envp);\n+extern int cmd_log(int argc, const char **argv, char **envp);\n+\n+#endif\ndiff --git a/git.c b/git.c\nindex 40b7e42..aa2b814 100644\n--- a/git.c\n+++ b/git.c\n@@ -11,215 +11,8 @@ #include <stdarg.h>\n #include <sys/ioctl.h>\n #include \"git-compat-util.h\"\n #include \"exec_cmd.h\"\n-#include \"common-cmds.h\"\n \n-#include \"cache.h\"\n-#include \"commit.h\"\n-#include \"diff.h\"\n-#include \"revision.h\"\n-#include \"log-tree.h\"\n-\n-#ifndef PATH_MAX\n-# define PATH_MAX 4096\n-#endif\n-\n-static const char git_usage[] =\n-\t\"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]\";\n-\n-/* most gui terms set COLUMNS (although some don't export it) */\n-static int term_columns(void)\n-{\n-\tchar *col_string = getenv(\"COLUMNS\");\n-\tint n_cols = 0;\n-\n-\tif (col_string && (n_cols = atoi(col_string)) > 0)\n-\t\treturn n_cols;\n-\n-#ifdef TIOCGWINSZ\n-\t{\n-\t\tstruct winsize ws;\n-\t\tif (!ioctl(1, TIOCGWINSZ, &ws)) {\n-\t\t\tif (ws.ws_col)\n-\t\t\t\treturn ws.ws_col;\n-\t\t}\n-\t}\n-#endif\n-\n-\treturn 80;\n-}\n-\n-static void oom(void)\n-{\n-\tfprintf(stderr, \"git: out of memory\\n\");\n-\texit(1);\n-}\n-\n-static inline void mput_char(char c, unsigned int num)\n-{\n-\twhile(num--)\n-\t\tputchar(c);\n-}\n-\n-static struct cmdname {\n-\tsize_t len;\n-\tchar name[1];\n-} **cmdname;\n-static int cmdname_alloc, cmdname_cnt;\n-\n-static void add_cmdname(const char *name, int len)\n-{\n-\tstruct cmdname *ent;\n-\tif (cmdname_alloc <= cmdname_cnt) {\n-\t\tcmdname_alloc = cmdname_alloc + 200;\n-\t\tcmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n-\t\tif (!cmdname)\n-\t\t\toom();\n-\t}\n-\tent = malloc(sizeof(*ent) + len);\n-\tif (!ent)\n-\t\toom();\n-\tent->len = len;\n-\tmemcpy(ent->name, name, len);\n-\tent->name[len] = 0;\n-\tcmdname[cmdname_cnt++] = ent;\n-}\n-\n-static int cmdname_compare(const void *a_, const void *b_)\n-{\n-\tstruct cmdname *a = *(struct cmdname **)a_;\n-\tstruct cmdname *b = *(struct cmdname **)b_;\n-\treturn strcmp(a->name, b->name);\n-}\n-\n-static void pretty_print_string_list(struct cmdname **cmdname, int longest)\n-{\n-\tint cols = 1, rows;\n-\tint space = longest + 1; /* min 1 SP between words */\n-\tint max_cols = term_columns() - 1; /* don't print *on* the edge */\n-\tint i, j;\n-\n-\tif (space < max_cols)\n-\t\tcols = max_cols / space;\n-\trows = (cmdname_cnt + cols - 1) / cols;\n-\n-\tqsort(cmdname, cmdname_cnt, sizeof(*cmdname), cmdname_compare);\n-\n-\tfor (i = 0; i < rows; i++) {\n-\t\tprintf(\"  \");\n-\n-\t\tfor (j = 0; j < cols; j++) {\n-\t\t\tint n = j * rows + i;\n-\t\t\tint size = space;\n-\t\t\tif (n >= cmdname_cnt)\n-\t\t\t\tbreak;\n-\t\t\tif (j == cols-1 || n + rows >= cmdname_cnt)\n-\t\t\t\tsize = 1;\n-\t\t\tprintf(\"%-*s\", size, cmdname[n]->name);\n-\t\t}\n-\t\tputchar('\\n');\n-\t}\n-}\n-\n-static void list_commands(const char *exec_path, const char *pattern)\n-{\n-\tunsigned int longest = 0;\n-\tchar path[PATH_MAX];\n-\tint dirlen;\n-\tDIR *dir = opendir(exec_path);\n-\tstruct dirent *de;\n-\n-\tif (!dir) {\n-\t\tfprintf(stderr, \"git: '%s': %s\\n\", exec_path, strerror(errno));\n-\t\texit(1);\n-\t}\n-\n-\tdirlen = strlen(exec_path);\n-\tif (PATH_MAX - 20 < dirlen) {\n-\t\tfprintf(stderr, \"git: insanely long exec-path '%s'\\n\",\n-\t\t\texec_path);\n-\t\texit(1);\n-\t}\n-\n-\tmemcpy(path, exec_path, dirlen);\n-\tpath[dirlen++] = '/';\n-\n-\twhile ((de = readdir(dir)) != NULL) {\n-\t\tstruct stat st;\n-\t\tint entlen;\n-\n-\t\tif (strncmp(de->d_name, \"git-\", 4))\n-\t\t\tcontinue;\n-\t\tstrcpy(path+dirlen, de->d_name);\n-\t\tif (stat(path, &st) || /* stat, not lstat */\n-\t\t    !S_ISREG(st.st_mode) ||\n-\t\t    !(st.st_mode & S_IXUSR))\n-\t\t\tcontinue;\n-\n-\t\tentlen = strlen(de->d_name);\n-\t\tif (4 < entlen && !strcmp(de->d_name + entlen - 4, \".exe\"))\n-\t\t\tentlen -= 4;\n-\n-\t\tif (longest < entlen)\n-\t\t\tlongest = entlen;\n-\n-\t\tadd_cmdname(de->d_name + 4, entlen-4);\n-\t}\n-\tclosedir(dir);\n-\n-\tprintf(\"git commands available in '%s'\\n\", exec_path);\n-\tprintf(\"----------------------------\");\n-\tmput_char('-', strlen(exec_path));\n-\tputchar('\\n');\n-\tpretty_print_string_list(cmdname, longest - 4);\n-\tputchar('\\n');\n-}\n-\n-static void list_common_cmds_help(void)\n-{\n-\tint i, longest = 0;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n-\t\tif (longest < strlen(common_cmds[i].name))\n-\t\t\tlongest = strlen(common_cmds[i].name);\n-\t}\n-\n-\tputs(\"The most commonly used git commands are:\");\n-\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n-\t\tprintf(\"    %s\", common_cmds[i].name);\n-\t\tmput_char(' ', longest - strlen(common_cmds[i].name) + 4);\n-\t\tputs(common_cmds[i].help);\n-\t}\n-\tputs(\"(use 'git help -a' to get a list of all installed git commands)\");\n-}\n-\n-#ifdef __GNUC__\n-static void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n-\t__attribute__((__format__(__printf__, 3, 4), __noreturn__));\n-#endif\n-static void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)\n-{\n-\tif (fmt) {\n-\t\tva_list ap;\n-\n-\t\tva_start(ap, fmt);\n-\t\tprintf(\"git: \");\n-\t\tvprintf(fmt, ap);\n-\t\tva_end(ap);\n-\t\tputchar('\\n');\n-\t}\n-\telse\n-\t\tputs(git_usage);\n-\n-\tif (exec_path) {\n-\t\tputchar('\\n');\n-\t\tif (show_all)\n-\t\t\tlist_commands(exec_path, \"git-*\");\n-\t\telse\n-\t\t\tlist_common_cmds_help();\n-        }\n-\n-\texit(1);\n-}\n+#include \"builtin.h\"\n \n static void prepend_to_path(const char *dir, int len)\n {\n@@ -240,99 +33,7 @@ static void prepend_to_path(const char *\n \tsetenv(\"PATH\", path, 1);\n }\n \n-static void show_man_page(const char *git_cmd)\n-{\n-\tconst char *page;\n-\n-\tif (!strncmp(git_cmd, \"git\", 3))\n-\t\tpage = git_cmd;\n-\telse {\n-\t\tint page_len = strlen(git_cmd) + 4;\n-\t\tchar *p = malloc(page_len + 1);\n-\t\tstrcpy(p, \"git-\");\n-\t\tstrcpy(p + 4, git_cmd);\n-\t\tp[page_len] = 0;\n-\t\tpage = p;\n-\t}\n-\n-\texeclp(\"man\", \"man\", page, NULL);\n-}\n-\n-static int cmd_version(int argc, const char **argv, char **envp)\n-{\n-\tprintf(\"git version %s\\n\", GIT_VERSION);\n-\treturn 0;\n-}\n-\n-static int cmd_help(int argc, const char **argv, char **envp)\n-{\n-\tconst char *help_cmd = argv[1];\n-\tif (!help_cmd)\n-\t\tcmd_usage(0, git_exec_path(), NULL);\n-\telse if (!strcmp(help_cmd, \"--all\") || !strcmp(help_cmd, \"-a\"))\n-\t\tcmd_usage(1, git_exec_path(), NULL);\n-\telse\n-\t\tshow_man_page(help_cmd);\n-\treturn 0;\n-}\n-\n-static int cmd_log_wc(int argc, const char **argv, char **envp,\n-\t\t      struct rev_info *rev)\n-{\n-\tstruct commit *commit;\n-\n-\trev->abbrev = DEFAULT_ABBREV;\n-\trev->commit_format = CMIT_FMT_DEFAULT;\n-\trev->verbose_header = 1;\n-\targc = setup_revisions(argc, argv, rev, \"HEAD\");\n-\n-\tif (argc > 1)\n-\t\tdie(\"unrecognized argument: %s\", argv[1]);\n-\n-\tprepare_revision_walk(rev);\n-\tsetup_pager();\n-\twhile ((commit = get_revision(rev)) != NULL) {\n-\t\tlog_tree_commit(rev, commit);\n-\t\tfree(commit->buffer);\n-\t\tcommit->buffer = NULL;\n-\t}\n-\treturn 0;\n-}\n-\n-static int cmd_wc(int argc, const char **argv, char **envp)\n-{\n-\tstruct rev_info rev;\n-\n-\tinit_revisions(&rev);\n-\trev.diff = 1;\n-\trev.diffopt.recursive = 1;\n-\treturn cmd_log_wc(argc, argv, envp, &rev);\n-}\n-\n-static int cmd_show(int argc, const char **argv, char **envp)\n-{\n-\tstruct rev_info rev;\n-\n-\tinit_revisions(&rev);\n-\trev.diff = 1;\n-\trev.diffopt.recursive = 1;\n-\trev.combine_merges = 1;\n-\trev.dense_combined_merges = 1;\n-\trev.always_show_header = 1;\n-\trev.ignore_merges = 0;\n-\trev.no_walk = 1;\n-\treturn cmd_log_wc(argc, argv, envp, &rev);\n-}\n-\n-static int cmd_log(int argc, const char **argv, char **envp)\n-{\n-\tstruct rev_info rev;\n-\n-\tinit_revisions(&rev);\n-\trev.always_show_header = 1;\n-\trev.diffopt.recursive = 1;\n-\treturn cmd_log_wc(argc, argv, envp, &rev);\n-}\n+const char git_version_string[] = GIT_VERSION;\n \n static void handle_internal_command(int argc, const char **argv, char **envp)\n {\n@@ -344,7 +45,7 @@ static void handle_internal_command(int \n \t\t{ \"version\", cmd_version },\n \t\t{ \"help\", cmd_help },\n \t\t{ \"log\", cmd_log },\n-\t\t{ \"whatchanged\", cmd_wc },\n+\t\t{ \"whatchanged\", cmd_whatchanged },\n \t\t{ \"show\", cmd_show },\n \t};\n \tint i;\n"}]}