From 9dcfde61ed7334e925fca7e62dbb5791547a5f5b Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 4 Nov 2007 23:50:23 +0100 Subject: [PATCH] help: Teach help to try harder to locate help Help now tries to takes the argument as is and prefixed with "git-". If no html page is found an error is reported. With this change you can run "git help user-manual". Signed-off-by: Steffen Prohaska --- help.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/help.c b/help.c index b81ddf0fb5..02e59b75e0 100644 --- a/help.c +++ b/help.c @@ -7,6 +7,7 @@ #include "builtin.h" #include "exec_cmd.h" #include "common-cmds.h" +#include "dir.h" //#include /* most GUI terminals set COLUMNS (although some don't export it) */ @@ -242,6 +243,29 @@ void list_common_cmds_help(void) static void show_man_page(const char *git_cmd) { +#ifdef __MINGW32__ + { + char *htmlpath = make_native_separator( + mkpath("%s/doc/git/html/%s.html" + , git_install_prefix() + , git_cmd) + ); + if (!file_exists(htmlpath)) { + htmlpath = make_native_separator( + mkpath("%s/doc/git/html/git-%s.html" + , git_install_prefix() + , git_cmd) + ); + if (!file_exists(htmlpath)) { + fprintf(stderr, "Can't find help for '%s'.\n" + , git_cmd); + exit(1); + } + } + printf("Launching default browser to display HTML help ...\n"); + ShellExecute(NULL, "open", htmlpath, NULL, NULL, 0); + } +#else const char *page; if (!prefixcmp(git_cmd, "git")) @@ -255,17 +279,6 @@ static void show_man_page(const char *git_cmd) page = p; } -#ifdef __MINGW32__ - { - const char *htmlpath = make_native_separator( - mkpath("%s/doc/git/html/%s.html" - , git_install_prefix() - , page) - ); - printf("Launching default browser to display HTML help ...\n"); - ShellExecute(NULL, "open", htmlpath, NULL, NULL, 0); - } -#else execlp("man", "man", page, NULL); #endif }