From 482cce820554809c02bc639bb33462f9905e4342 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:33 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- help.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'help.c') 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) -- cgit v1.2.1 From caa87713bca77c441c09282aa5b18b179bcfa90d Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:41 +0100 Subject: help--browse: add '--config' option to check a config option for a browser. The value of this new command line option will be used as a key to check the configuration for an help browser. This should remove the last bit in 'git-help--browse' that was specific to 'git-help', so that other git command can use 'git-help--browse'. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'help.c') diff --git a/help.c b/help.c index b929899e6..058a39753 100644 --- a/help.c +++ b/help.c @@ -347,7 +347,7 @@ static void show_html_page(const char *git_cmd) get_html_page_path(&page_path, page); - execl_git_cmd("help--browse", page_path.buf, NULL); + execl_git_cmd("help--browse", "-c", "help.browser", page_path.buf, NULL); } void help_unknown_cmd(const char *cmd) -- cgit v1.2.1 From 5884f1fe96b33d9666a78e660042b1e3e5f9f4d9 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 2 Feb 2008 07:32:53 +0100 Subject: Rename 'git-help--browse.sh' to 'git-web--browse.sh'. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'help.c') diff --git a/help.c b/help.c index 058a39753..c35912bc5 100644 --- a/help.c +++ b/help.c @@ -347,7 +347,7 @@ static void show_html_page(const char *git_cmd) get_html_page_path(&page_path, page); - execl_git_cmd("help--browse", "-c", "help.browser", page_path.buf, NULL); + execl_git_cmd("web--browse", "-c", "help.browser", page_path.buf, NULL); } void help_unknown_cmd(const char *cmd) -- cgit v1.2.1