{"thread":{"id":"15250","subject":"[PATCH] Allow git help work without PATH set","startedAt":"2008-08-28T17:19:07Z","lastAt":"2008-08-28T17:19:07Z","messageCount":1,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"88923","messageId":"20080828171907.GD6024@blimp.local","threadId":"15250","inReplyTo":null,"subject":"[PATCH] Allow git help work without PATH set","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-28T17:19:07Z","receivedAt":"2008-08-28T17:19:07Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Just because we can\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n help.c |   43 ++++++++++++++++++++-----------------------\n 1 files changed, 20 insertions(+), 23 deletions(-)\n\ndiff --git a/help.c b/help.c\nindex a17a746..ab2c2ba 100644\n--- a/help.c\n+++ b/help.c\n@@ -178,37 +178,34 @@ void load_command_list(const char *prefix,\n \t\tstruct cmdnames *other_cmds)\n {\n \tconst char *env_path = getenv(\"PATH\");\n-\tchar *paths, *path, *colon;\n \tconst char *exec_path = git_exec_path();\n \n-\tif (exec_path)\n+\tif (exec_path) {\n \t\tlist_commands_in_dir(main_cmds, exec_path, prefix);\n-\n-\tif (!env_path) {\n-\t\tfprintf(stderr, \"PATH not set\\n\");\n-\t\texit(1);\n+\t\tqsort(main_cmds->names, main_cmds->cnt,\n+\t\t      sizeof(*main_cmds->names), cmdname_compare);\n+\t\tuniq(main_cmds);\n \t}\n \n-\tpath = paths = xstrdup(env_path);\n-\twhile (1) {\n-\t\tif ((colon = strchr(path, PATH_SEP)))\n-\t\t\t*colon = 0;\n-\n-\t\tlist_commands_in_dir(other_cmds, path, prefix);\n+\tif (env_path) {\n+\t\tchar *paths, *path, *colon;\n+\t\tpath = paths = xstrdup(env_path);\n+\t\twhile (1) {\n+\t\t\tif ((colon = strchr(path, PATH_SEP)))\n+\t\t\t\t*colon = 0;\n \n-\t\tif (!colon)\n-\t\t\tbreak;\n-\t\tpath = colon + 1;\n-\t}\n-\tfree(paths);\n+\t\t\tlist_commands_in_dir(other_cmds, path, prefix);\n \n-\tqsort(main_cmds->names, main_cmds->cnt,\n-\t      sizeof(*main_cmds->names), cmdname_compare);\n-\tuniq(main_cmds);\n+\t\t\tif (!colon)\n+\t\t\t\tbreak;\n+\t\t\tpath = colon + 1;\n+\t\t}\n+\t\tfree(paths);\n \n-\tqsort(other_cmds->names, other_cmds->cnt,\n-\t      sizeof(*other_cmds->names), cmdname_compare);\n-\tuniq(other_cmds);\n+\t\tqsort(other_cmds->names, other_cmds->cnt,\n+\t\t      sizeof(*other_cmds->names), cmdname_compare);\n+\t\tuniq(other_cmds);\n+\t}\n \texclude_cmds(other_cmds, main_cmds);\n }\n \n-- \n1.6.0.1.150.g5966\n"}]}