aboutsummaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2008-02-02 07:32:33 +0100
committerJunio C Hamano <gitster@pobox.com>2008-02-05 01:01:45 -0800
commit482cce820554809c02bc639bb33462f9905e4342 (patch)
tree0db89b008dba37f564ea74e6275c2bc297dfeb85 /help.c
parent7a2078b4b00fb1c5d7b0bf8155778f79377b8f2f (diff)
downloadgit-482cce820554809c02bc639bb33462f9905e4342.tar.gz
git-482cce820554809c02bc639bb33462f9905e4342.tar.xz
help: make 'git-help--browse' usable outside 'git-help'.
"git-help--browse" helper is to launch a browser of the user's choice to view the HTML version of git documentation for a given command. It used to take the name of a command, convert it to the path of the documentation by prefixing the directory name and appending the ".html" suffix, and start the browser on the path. This updates the division of labor between the caller in help.c and git-help--browser helper. The helper is now responsible for launching a browser of the user's choice on given URLs, and it is the caller's responsibility to tell it the paths to documentation files. This is in preparation to reuse the logic to choose user's preferred browser in instaweb. The helper had a provision for running it without any command name, in which case it showed the toplevel "git(7)" documentation, but the caller in help.c never makes such a call. The helper now exits with a usage message when no path is given. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.c')
-rw-r--r--help.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/help.c b/help.c
index 1302a61c8..b929899e6 100644
--- a/help.c
+++ b/help.c
@@ -328,10 +328,26 @@ static void show_info_page(const char *git_cmd)
execlp("info", "info", "gitman", page, NULL);
}
+static void get_html_page_path(struct strbuf *page_path, const char *page)
+{
+ struct stat st;
+
+ /* Check that we have a git documentation directory. */
+ if (stat(GIT_HTML_PATH "/git.html", &st) || !S_ISREG(st.st_mode))
+ die("'%s': not a documentation directory.", GIT_HTML_PATH);
+
+ strbuf_init(page_path, 0);
+ strbuf_addf(page_path, GIT_HTML_PATH "/%s.html", page);
+}
+
static void show_html_page(const char *git_cmd)
{
const char *page = cmd_to_page(git_cmd);
- execl_git_cmd("help--browse", page, NULL);
+ struct strbuf page_path; /* it leaks but we exec bellow */
+
+ get_html_page_path(&page_path, page);
+
+ execl_git_cmd("help--browse", page_path.buf, NULL);
}
void help_unknown_cmd(const char *cmd)