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 <chris@arachsys.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chris Webb committed Jun 28, 2012 at 07:58 UTC 89a852efb911c260d3f7b56ef8382a0725cc931b
1 file changed +10 -1
builtin/help.c
+10 -1
@@ -30,6 +30,8 @@ enum help_format {
30 HELP_FORMAT_WEB
31 };
32
33 +static const char *html_path;
34 +
35 static int show_all = 0;
36 static unsigned int colopts;
37 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)
263 help_format = parse_help_format(value);
264 return 0;
265 }
266 + if (!strcmp(var, "help.htmlpath")) {
267 + if (!value)
268 + return config_error_nonbool(var);
269 + html_path = xstrdup(value);
270 + return 0;
271 + }
272 if (!strcmp(var, "man.viewer")) {
273 if (!value)
274 return config_error_nonbool(var);
@@ -383,7 +391,8 @@ static void show_info_page(const char *git_cmd)
391 static void get_html_page_path(struct strbuf *page_path, const char *page)
392 {
393 struct stat st;
386 - const char *html_path = system_path(GIT_HTML_PATH);
394 + if (!html_path)
395 + html_path = system_path(GIT_HTML_PATH);
396
397 /* Check that we have a git documentation directory. */
398 if (stat(mkpath("%s/git.html", html_path), &st)