]> asedeno.scripts.mit.edu Git - git.git/blobdiff - help.c
Merge branch 'maint'
[git.git] / help.c
diff --git a/help.c b/help.c
index a17a74631e2412a473f46809ba6de3e02c422cfc..b278257aab15f7a195dd4f3c234b3e6b68aaa8f3 100644 (file)
--- a/help.c
+++ b/help.c
@@ -178,44 +178,40 @@ 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);
 }
 
 void list_commands(const char *title, struct cmdnames *main_cmds,
                   struct cmdnames *other_cmds)
 {
-       const char *exec_path = git_exec_path();
        int i, longest = 0;
 
        for (i = 0; i < main_cmds->cnt; i++)
@@ -226,6 +222,7 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
                        longest = other_cmds->names[i]->len;
 
        if (main_cmds->cnt) {
+               const char *exec_path = git_exec_path();
                printf("available %s in '%s'\n", title, exec_path);
                printf("----------------");
                mput_char('-', strlen(title) + strlen(exec_path));