git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] Add config variable to set HTML path for git-help --web

From
Chris Webb <chris@arachsys.com>
Date
Jun 27, 2012, 22:00 UTC
Message-ID
<11ff98647b869d4753ffee53c77df5c11f43224d.1340834432.git.chris@arachsys.com>

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.

When help.htmlpath is explicitly set, it is used without checking it is a local git docs directory. This means it can instead be set to a URL prefix, allowing git-help --web to work even when HTML docs aren't locally installed, using 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 <chris@arachsys.com>
---
 builtin/help.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/builtin/help.c b/builtin/help.c
index 8f9cd60..a0bb2bf 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -34,6 +34,8 @@ enum help_format {
 	HELP_FORMAT_WEB
 };
 
+static char *html_path = NULL;
+
 static int show_all = 0;
 static unsigned int colopts;
 static enum help_format help_format = HELP_FORMAT_NONE;
@@ -265,6 +267,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);
@@ -387,12 +395,14 @@ 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)
-	    || !S_ISREG(st.st_mode))
-		die(_("'%s': not a documentation directory."), 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);
+	}
 
 	strbuf_init(page_path, 0);
 	strbuf_addf(page_path, "%s/%s.html", html_path, page);
-- 
1.7.10
Next: Chris Webb
Message 1 of 2 in “Add config variable to set HTML path for git-help --web”
  1. 1/2 Add config variable to set HTML path for git-help --webChris Webb, Jun 27, 2012
  2. 2/2 Add a help format 'usage' to provide brief command usageChris Webb, Jun 27, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.