From 89a852efb911c260d3f7b56ef8382a0725cc931b Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Thu, 28 Jun 2012 07:58:02 +0100 Subject: Add config variable to set HTML path for git-help --web If set in git-config, help.htmlpath overrides system_path(GIT_HTML_PATH) which was compiled in. This allows users to repoint system-wide git at their own copy of the documentation without recompiling. Signed-off-by: Chris Webb Signed-off-by: Junio C Hamano --- builtin/help.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/builtin/help.c b/builtin/help.c index 43d3c84449..9e36fb4cc7 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -30,6 +30,8 @@ enum help_format { HELP_FORMAT_WEB }; +static const char *html_path; + static int show_all = 0; static unsigned int colopts; static enum help_format help_format = HELP_FORMAT_NONE; @@ -261,6 +263,12 @@ static int git_help_config(const char *var, const char *value, void *cb) help_format = parse_help_format(value); return 0; } + if (!strcmp(var, "help.htmlpath")) { + if (!value) + return config_error_nonbool(var); + html_path = xstrdup(value); + return 0; + } if (!strcmp(var, "man.viewer")) { if (!value) return config_error_nonbool(var); @@ -383,7 +391,8 @@ static void show_info_page(const char *git_cmd) static void get_html_page_path(struct strbuf *page_path, const char *page) { struct stat st; - const char *html_path = system_path(GIT_HTML_PATH); + if (!html_path) + html_path = system_path(GIT_HTML_PATH); /* Check that we have a git documentation directory. */ if (stat(mkpath("%s/git.html", html_path), &st) -- cgit v1.2.3 From 86272b4ffeb38fb4fb1da3603bba1094fab3731b Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Thu, 28 Jun 2012 07:58:03 +0100 Subject: Allow help.htmlpath to be a URL prefix Setting this to a URL prefix instead of a path to a local directory allows git-help --web to work even when HTML docs aren't locally installed, by pointing the browser at a copy accessible on the web. For example, [help] format = html htmlpath = http://git-scm.com/docs will use the publicly available documentation on the git homepage. Signed-off-by: Chris Webb Signed-off-by: Junio C Hamano --- builtin/help.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin/help.c b/builtin/help.c index 9e36fb4cc7..0c698b18c8 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -395,9 +395,11 @@ static void get_html_page_path(struct strbuf *page_path, const char *page) html_path = system_path(GIT_HTML_PATH); /* Check that we have a git documentation directory. */ - if (stat(mkpath("%s/git.html", html_path), &st) - || !S_ISREG(st.st_mode)) - die(_("'%s': not a documentation directory."), html_path); + if (!strstr(html_path, "://")) { + if (stat(mkpath("%s/git.html", html_path), &st) + || !S_ISREG(st.st_mode)) + die("'%s': not a documentation directory.", html_path); + } strbuf_init(page_path, 0); strbuf_addf(page_path, "%s/%s.html", html_path, page); -- cgit v1.2.3