diff options
author | Alex Riesen <raa.lkml@gmail.com> | 2008-08-28 19:19:07 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-28 21:51:28 -0700 |
commit | 1f08e5ce2435f1d5c78a31c0a783d5bb177cd657 (patch) | |
tree | ca29e6a3ed17cfee256c1bc5ca5991794706ed2d /help.c | |
parent | c7371e992b1aa147b640759a7fa89e722e6db8dc (diff) | |
download | git-1f08e5ce2435f1d5c78a31c0a783d5bb177cd657.tar.gz |
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>
Diffstat (limited to 'help.c')
-rw-r--r-- | help.c | 43 |
1 files changed, 20 insertions, 23 deletions
@@ -178,37 +178,34 @@ void load_command_list(const char *prefix, struct cmdnames *other_cmds) { const char *env_path = getenv("PATH"); - char *paths, *path, *colon; const char *exec_path = git_exec_path(); - if (exec_path) + if (exec_path) { list_commands_in_dir(main_cmds, exec_path, prefix); - - if (!env_path) { - fprintf(stderr, "PATH not set\n"); - exit(1); + qsort(main_cmds->names, main_cmds->cnt, + sizeof(*main_cmds->names), cmdname_compare); + uniq(main_cmds); } - path = paths = xstrdup(env_path); - while (1) { - if ((colon = strchr(path, PATH_SEP))) - *colon = 0; - - list_commands_in_dir(other_cmds, path, prefix); + if (env_path) { + char *paths, *path, *colon; + path = paths = xstrdup(env_path); + while (1) { + if ((colon = strchr(path, PATH_SEP))) + *colon = 0; - if (!colon) - break; - path = colon + 1; - } - free(paths); + list_commands_in_dir(other_cmds, path, prefix); - qsort(main_cmds->names, main_cmds->cnt, - sizeof(*main_cmds->names), cmdname_compare); - uniq(main_cmds); + if (!colon) + break; + path = colon + 1; + } + free(paths); - qsort(other_cmds->names, other_cmds->cnt, - sizeof(*other_cmds->names), cmdname_compare); - uniq(other_cmds); + qsort(other_cmds->names, other_cmds->cnt, + sizeof(*other_cmds->names), cmdname_compare); + uniq(other_cmds); + } exclude_cmds(other_cmds, main_cmds); } |