X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=help.c;h=3cb19628965685ce59a5377b81bef975851996e8;hb=39702431500b76425f047209c9e9b2aae7e92b00;hp=52d39b88a36e92b00828fdb8c8d056f9b79a37e0;hpb=88bbda08d7b9503862a8fb8846d78c67825e5e3d;p=git.git diff --git a/help.c b/help.c index 52d39b88a..3cb196289 100644 --- a/help.c +++ b/help.c @@ -40,7 +40,7 @@ static struct option builtin_help_options[] = { }; static const char * const builtin_help_usage[] = { - "git-help [--all] [--man|--web|--info] [command]", + "git help [--all] [--man|--web|--info] [command]", NULL }; @@ -425,17 +425,24 @@ static unsigned int list_commands_in_dir(struct cmdnames *cmds, int prefix_len = strlen(prefix); DIR *dir = opendir(path); struct dirent *de; + struct strbuf buf = STRBUF_INIT; + int len; - if (!dir || chdir(path)) + if (!dir) return 0; + strbuf_addf(&buf, "%s/", path); + len = buf.len; + while ((de = readdir(dir)) != NULL) { int entlen; if (prefixcmp(de->d_name, prefix)) continue; - if (!is_executable(de->d_name)) + strbuf_setlen(&buf, len); + strbuf_addstr(&buf, de->d_name); + if (!is_executable(buf.buf)) continue; entlen = strlen(de->d_name) - prefix_len; @@ -448,6 +455,7 @@ static unsigned int list_commands_in_dir(struct cmdnames *cmds, add_cmdname(cmds, de->d_name + prefix_len, entlen); } closedir(dir); + strbuf_release(&buf); return longest; }