summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-09-23 20:44:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-23 20:44:48 (GMT)
commitbd42622e5f3ea4a5b1f5fd69174bc7914d00ea3e (patch)
tree0596aa9f814a7c4d87aa3d56e5349b17391fd491
parentc2e799012b3657f4f91560d299b5606c297e7cf7 (diff)
parenta3952f8e7c0e74d9266bc9cf4ac50dd179129f72 (diff)
downloadgit-bd42622e5f3ea4a5b1f5fd69174bc7914d00ea3e.zip
git-bd42622e5f3ea4a5b1f5fd69174bc7914d00ea3e.tar.gz
git-bd42622e5f3ea4a5b1f5fd69174bc7914d00ea3e.tar.bz2
Merge branch 'ma/help-w-check-for-requested-page'
The error in "git help no-such-git-command" is handled better. * ma/help-w-check-for-requested-page: help: make sure local html page exists before calling external processes
-rw-r--r--builtin/help.c9
-rwxr-xr-xt/t0012-help.sh16
2 files changed, 22 insertions, 3 deletions
diff --git a/builtin/help.c b/builtin/help.c
index b7eec06..7731659 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -467,11 +467,14 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
if (!html_path)
html_path = to_free = system_path(GIT_HTML_PATH);
- /* Check that we have a git documentation directory. */
+ /*
+ * Check that the page we're looking for exists.
+ */
if (!strstr(html_path, "://")) {
- if (stat(mkpath("%s/git.html", html_path), &st)
+ if (stat(mkpath("%s/%s.html", html_path, page), &st)
|| !S_ISREG(st.st_mode))
- die("'%s': not a documentation directory.", html_path);
+ die("'%s/%s.html': documentation file not found.",
+ html_path, page);
}
strbuf_init(page_path, 0);
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index 5679e29..913f34c 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -73,6 +73,22 @@ test_expect_success 'git help -g' '
test_i18ngrep "^ tutorial " help.output
'
+test_expect_success 'git help fails for non-existing html pages' '
+ configure_help &&
+ mkdir html-empty &&
+ test_must_fail git -c help.htmlpath=html-empty help status &&
+ test_must_be_empty test-browser.log
+'
+
+test_expect_success 'git help succeeds without git.html' '
+ configure_help &&
+ mkdir html-with-docs &&
+ touch html-with-docs/git-status.html &&
+ git -c help.htmlpath=html-with-docs help status &&
+ echo "html-with-docs/git-status.html" >expect &&
+ test_cmp expect test-browser.log
+'
+
test_expect_success 'generate builtin list' '
git --list-cmds=builtins >builtins
'