@matheusbsbs / matheus-bagliano / commits / 1f08e5ce24
Fork 0

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>

Alex Riesen committed Aug 28, 2008 at 19:19 UTC 1f08e5ce2435f1d5c78a31c0a783d5bb177cd657
1 file changed +20 -23
help.c
+20 -23
@@ -178,37 +178,34 @@ void load_command_list(const char *prefix,
178 struct cmdnames *other_cmds)
179 {
180 const char *env_path = getenv("PATH");
181 - char *paths, *path, *colon;
181 const char *exec_path = git_exec_path();
182
184 - if (exec_path)
183 + if (exec_path) {
184 list_commands_in_dir(main_cmds, exec_path, prefix);
186 -
187 - if (!env_path) {
188 - fprintf(stderr, "PATH not set\n");
189 - exit(1);
185 + qsort(main_cmds->names, main_cmds->cnt,
186 + sizeof(*main_cmds->names), cmdname_compare);
187 + uniq(main_cmds);
188 }
189
192 - path = paths = xstrdup(env_path);
193 - while (1) {
194 - if ((colon = strchr(path, PATH_SEP)))
195 - *colon = 0;
196 -
197 - list_commands_in_dir(other_cmds, path, prefix);
190 + if (env_path) {
191 + char *paths, *path, *colon;
192 + path = paths = xstrdup(env_path);
193 + while (1) {
194 + if ((colon = strchr(path, PATH_SEP)))
195 + *colon = 0;
196
199 - if (!colon)
200 - break;
201 - path = colon + 1;
202 - }
203 - free(paths);
197 + list_commands_in_dir(other_cmds, path, prefix);
198
205 - qsort(main_cmds->names, main_cmds->cnt,
206 - sizeof(*main_cmds->names), cmdname_compare);
207 - uniq(main_cmds);
199 + if (!colon)
200 + break;
201 + path = colon + 1;
202 + }
203 + free(paths);
204
209 - qsort(other_cmds->names, other_cmds->cnt,
210 - sizeof(*other_cmds->names), cmdname_compare);
211 - uniq(other_cmds);
205 + qsort(other_cmds->names, other_cmds->cnt,
206 + sizeof(*other_cmds->names), cmdname_compare);
207 + uniq(other_cmds);
208 + }
209 exclude_cmds(other_cmds, main_cmds);
210 }
211