From: Junio C Hamano Date: Wed, 14 Jan 2015 20:37:19 +0000 (-0800) Subject: Merge branch 'ak/fewer-includes' X-Git-Tag: v2.3.0-rc1~10 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/09deda3746a0c726a79a6e2db4fd8d864aa08e51?ds=inline;hp=-c Merge branch 'ak/fewer-includes' * ak/fewer-includes: cat-file: remove unused includes git.c: remove unnecessary #includes --- 09deda3746a0c726a79a6e2db4fd8d864aa08e51 diff --combined git.c index 82d7a1cfee,a7d170c98e..6b5ae6a2ac --- a/git.c +++ b/git.c @@@ -1,10 -1,7 +1,7 @@@ #include "builtin.h" - #include "cache.h" #include "exec_cmd.h" #include "help.h" - #include "quote.h" #include "run-command.h" - #include "commit.h" const char git_usage_string[] = "git [--version] [--help] [-C ] [-c name=value]\n" @@@ -487,20 -484,15 +484,20 @@@ static struct cmd_struct commands[] = { "write-tree", cmd_write_tree, RUN_SETUP }, }; -int is_builtin(const char *s) +static struct cmd_struct *get_builtin(const char *s) { int i; for (i = 0; i < ARRAY_SIZE(commands); i++) { - struct cmd_struct *p = commands+i; + struct cmd_struct *p = commands + i; if (!strcmp(s, p->cmd)) - return 1; + return p; } - return 0; + return NULL; +} + +int is_builtin(const char *s) +{ + return !!get_builtin(s); } static void handle_builtin(int argc, const char **argv) @@@ -508,7 -500,6 +505,7 @@@ const char *cmd = argv[0]; int i; static const char ext[] = STRIP_EXTENSION; + struct cmd_struct *builtin; if (sizeof(ext) > 1) { i = strlen(argv[0]) - strlen(ext); @@@ -525,12 -516,15 +522,12 @@@ argv[0] = cmd = "help"; } - for (i = 0; i < ARRAY_SIZE(commands); i++) { - struct cmd_struct *p = commands+i; - if (strcmp(p->cmd, cmd)) - continue; - if (saved_environment && (p->option & NO_SETUP)) { + builtin = get_builtin(cmd); + if (builtin) { + if (saved_environment && (builtin->option & NO_SETUP)) restore_env(); - break; - } - exit(run_builtin(p, argc, argv)); + else + exit(run_builtin(builtin, argc, argv)); } }