Skip to content

Commit a3c5263

Browse files
sschuberthgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f784a4 commit a3c5263

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/help.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ static struct cmdnames main_cmds, other_cmds;
288288

289289
static int is_git_command(const char *s)
290290
{
291+
load_command_list("git-", &main_cmds, &other_cmds);
291292
return is_in_cmdlist(&main_cmds, s) ||
292293
is_in_cmdlist(&other_cmds, s);
293294
}
@@ -449,7 +450,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)
449450
int nongit;
450451
const char *alias;
451452
enum help_format parsed_help_format;
452-
load_command_list("git-", &main_cmds, &other_cmds);
453453

454454
argc = parse_options(argc, argv, prefix, builtin_help_options,
455455
builtin_help_usage, 0);
@@ -458,6 +458,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
458458
if (show_all) {
459459
git_config(git_help_config, NULL);
460460
printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
461+
load_command_list("git-", &main_cmds, &other_cmds);
461462
list_commands(colopts, &main_cmds, &other_cmds);
462463
}
463464

0 commit comments

Comments
 (0)