builtin/help.c: call load_command_list() only when it is needed
This avoids list_commands_in_dir() being called when not needed which is quite slow due to file I/O in order to list matching files in a directory. Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sebastian Schuberth committed
Jan 2, 2014 at 17:16 UTC
a3c5263438f7c0ff7dd4d0d8ea86ed7a84a32d18
1 file changed
+2
-1
builtin/help.c
+2
-1
@@ -288,6 +288,7 @@ static struct cmdnames main_cmds, other_cmds;
288
289
static int is_git_command(const char *s)
290
{
291
+ load_command_list("git-", &main_cmds, &other_cmds);
292
return is_in_cmdlist(&main_cmds, s) ||
293
is_in_cmdlist(&other_cmds, s);
294
}
@@ -449,7 +450,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)
450
int nongit;
451
const char *alias;
452
enum help_format parsed_help_format;
452
- load_command_list("git-", &main_cmds, &other_cmds);
453
454
argc = parse_options(argc, argv, prefix, builtin_help_options,
455
builtin_help_usage, 0);
@@ -458,6 +458,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
458
if (show_all) {
459
git_config(git_help_config, NULL);
460
printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
461
+ load_command_list("git-", &main_cmds, &other_cmds);
462
list_commands(colopts, &main_cmds, &other_cmds);
463
}
464