| 285 | } |
| 286 | |
| 287 | void load_command_list(const char *prefix, |
| 288 | struct cmdnames *main_cmds, |
| 289 | struct cmdnames *other_cmds) |
| 290 | { |
| 291 | const char *env_path = getenv("PATH"); |
| 292 | const char *exec_path = git_exec_path(); |
| 293 | |
| 294 | load_builtin_commands(prefix, main_cmds); |
| 295 | |
| 296 | if (exec_path) { |
| 297 | list_commands_in_dir(main_cmds, exec_path, prefix); |
| 298 | QSORT(main_cmds->names, main_cmds->cnt, cmdname_compare); |
| 299 | uniq(main_cmds); |
| 300 | } |
| 301 | |
| 302 | if (env_path) { |
| 303 | char *paths, *path, *colon; |
| 304 | path = paths = xstrdup(env_path); |
| 305 | while (1) { |
| 306 | if ((colon = strchr(path, PATH_SEP))) |
| 307 | *colon = 0; |
| 308 | if (!exec_path || strcmp(path, exec_path)) |
| 309 | list_commands_in_dir(other_cmds, path, prefix); |
| 310 | |
| 311 | if (!colon) |
| 312 | break; |
| 313 | path = colon + 1; |
| 314 | } |
| 315 | free(paths); |
| 316 | |
| 317 | QSORT(other_cmds->names, other_cmds->cnt, cmdname_compare); |
| 318 | uniq(other_cmds); |
| 319 | } |
| 320 | exclude_cmds(other_cmds, main_cmds); |
| 321 | } |
| 322 | |
| 323 | static int get_colopts(const char *var, const char *value, |
| 324 | const struct config_context *ctx UNUSED, void *data) |
no test coverage detected