Allow git help work without PATH set

Just because we can

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alex Riesen 2008-08-28 19:19:07 +02:00 committed by Junio C Hamano
parent c7371e992b
commit 1f08e5ce24

17
help.c
View File

@ -178,17 +178,17 @@ void load_command_list(const char *prefix,
struct cmdnames *other_cmds) struct cmdnames *other_cmds)
{ {
const char *env_path = getenv("PATH"); const char *env_path = getenv("PATH");
char *paths, *path, *colon;
const char *exec_path = git_exec_path(); const char *exec_path = git_exec_path();
if (exec_path) if (exec_path) {
list_commands_in_dir(main_cmds, exec_path, prefix); list_commands_in_dir(main_cmds, exec_path, prefix);
qsort(main_cmds->names, main_cmds->cnt,
if (!env_path) { sizeof(*main_cmds->names), cmdname_compare);
fprintf(stderr, "PATH not set\n"); uniq(main_cmds);
exit(1);
} }
if (env_path) {
char *paths, *path, *colon;
path = paths = xstrdup(env_path); path = paths = xstrdup(env_path);
while (1) { while (1) {
if ((colon = strchr(path, PATH_SEP))) if ((colon = strchr(path, PATH_SEP)))
@ -202,13 +202,10 @@ void load_command_list(const char *prefix,
} }
free(paths); free(paths);
qsort(main_cmds->names, main_cmds->cnt,
sizeof(*main_cmds->names), cmdname_compare);
uniq(main_cmds);
qsort(other_cmds->names, other_cmds->cnt, qsort(other_cmds->names, other_cmds->cnt,
sizeof(*other_cmds->names), cmdname_compare); sizeof(*other_cmds->names), cmdname_compare);
uniq(other_cmds); uniq(other_cmds);
}
exclude_cmds(other_cmds, main_cmds); exclude_cmds(other_cmds, main_cmds);
} }