help (Windows): Display HTML in default browser using Windows' shell API
The system's default browser for displaying HTML help pages is now used directly on Windows, instead of launching git-web--browser, which requires a Unix shell. Avoiding MSYS' bash when possible is good because it avoids potential path translation issues. In this case it is not too hard to avoid launching a shell, so let's avoid it. The Windows-specific code is implemented in compat/mingw.c to avoid platform-specific code in the main code base. On Windows, open_html is provided as a define. If open_html is not defined, git-web--browse is used. This approach avoids platform-specific ifdefs by using per-function ifdefs. The "ifndef open_html" together with the introductory comment should sufficiently warn developers, so that they hopefully will not break this mechanism. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
868da8d5e3
commit
4804aabcdb
14
help.c
14
help.c
@ -644,6 +644,18 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
|
||||
strbuf_addf(page_path, "%s/%s.html", html_path, page);
|
||||
}
|
||||
|
||||
/*
|
||||
* If open_html is not defined in a platform-specific way (see for
|
||||
* example compat/mingw.h), we use the script web--browse to display
|
||||
* HTML.
|
||||
*/
|
||||
#ifndef open_html
|
||||
void open_html(const char *path)
|
||||
{
|
||||
execl_git_cmd("web--browse", "-c", "help.browser", path, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void show_html_page(const char *git_cmd)
|
||||
{
|
||||
const char *page = cmd_to_page(git_cmd);
|
||||
@ -651,7 +663,7 @@ static void show_html_page(const char *git_cmd)
|
||||
|
||||
get_html_page_path(&page_path, page);
|
||||
|
||||
execl_git_cmd("web--browse", "-c", "help.browser", page_path.buf, NULL);
|
||||
open_html(page_path.buf);
|
||||
}
|
||||
|
||||
void help_unknown_cmd(const char *cmd)
|
||||
|
Reference in New Issue
Block a user