All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Matthias Aßhauer via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Matthias Aßhauer" <mha1993@live.de>
Subject: Re: [PATCH 1/2] help: make sure local html page exists before calling external processes
Date: Mon, 13 Sep 2021 12:25:11 -0700	[thread overview]
Message-ID: <xmqqa6kgffc8.fsf@gitster.g> (raw)
In-Reply-To: <8674d67a439a23425133fa005e519ebb6ac19c42.1631531219.git.gitgitgadget@gmail.com> ("Matthias Aßhauer via GitGitGadget"'s message of "Mon, 13 Sep 2021 11:06:57 +0000")

"Matthias Aßhauer via GitGitGadget"  <gitgitgadget@gmail.com>
writes:

> diff --git a/builtin/help.c b/builtin/help.c
> index b7eec06c3de..77b1b926f60 100644
> --- a/builtin/help.c
> +++ b/builtin/help.c
> @@ -467,11 +467,18 @@ 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 we have a git documentation directory and the page we're
> +	 * looking for exists.
> +	 */
>  	if (!strstr(html_path, "://")) {
>  		if (stat(mkpath("%s/git.html", html_path), &st)
>  		    || !S_ISREG(st.st_mode))
>  			die("'%s': not a documentation directory.", html_path);
> +		if (stat(mkpath("%s/%s.html", html_path, page), &st)
> +		    || !S_ISREG(st.st_mode))
> +			die("'%s/%s.html': documentation file not found.",
> +				html_path, page);

I do not remember why we did not originally use the "page"
information and only checked "git.html", but because the "page" is
ultimately what the end-user will see, I wonder if it even makes
sense to still check "git.html" anymore.

If the request were "git help -w git", the new check added here
would catch the missing page, and for "git help -w log", it is
unfair to call the directory that we successfully found the
"git-log.html" in as "not a doc directory" only because it is for
whatever reason is missing "git.html" next to it.

It seems that this check dates back to 482cce82 (help: make
'git-help--browse' usable outside 'git-help'., 2008-02-02); even in
the context of that commit, I think it would have been better to
check for the generated page_path instead of git.html, so I actually
prefer to see the existing hardcoded check for git.html replaced with
the new check.

Thanks.


>  	}
>  
>  	strbuf_init(page_path, 0);
> diff --git a/t/t0012-help.sh b/t/t0012-help.sh
> index 5679e29c624..a83a59d44d9 100755
> --- a/t/t0012-help.sh
> +++ b/t/t0012-help.sh
> @@ -77,6 +77,13 @@ test_expect_success 'generate builtin list' '
>  	git --list-cmds=builtins >builtins
>  '
>  
> +test_expect_success 'git help fails for non-existing html pages' '
> +	configure_help &&
> +	mkdir html-doc &&
> +	touch html-doc/git.html &&
> +	test_must_fail git -c help.htmlpath=html-doc help status
> +'
> +
>  while read builtin
>  do
>  	test_expect_success "$builtin can handle -h" '

  parent reply	other threads:[~2021-09-13 19:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 11:06 [PATCH 0/2] documentation: handle non-existing html pages and document 'git version' Matthias Aßhauer via GitGitGadget
2021-09-13 11:06 ` [PATCH 1/2] help: make sure local html page exists before calling external processes Matthias Aßhauer via GitGitGadget
2021-09-13 15:59   ` Eric Sunshine
2021-09-13 16:17     ` Matthias Aßhauer
2021-09-13 19:25   ` Junio C Hamano [this message]
2021-09-13 11:06 ` [PATCH 2/2] documentation: add documentation for 'git version' Matthias Aßhauer via GitGitGadget
2021-09-13 11:19   ` Ævar Arnfjörð Bjarmason
2021-09-13 11:46     ` Matthias Aßhauer
2021-09-13 19:43     ` Junio C Hamano
2021-09-14 13:27 ` [PATCH v2 0/2] documentation: handle non-existing html pages and document " Matthias Aßhauer via GitGitGadget
2021-09-14 13:27   ` [PATCH v2 1/2] help: make sure local html page exists before calling external processes Matthias Aßhauer via GitGitGadget
2021-09-14 13:27   ` [PATCH v2 2/2] documentation: add documentation for 'git version' Matthias Aßhauer via GitGitGadget
2021-09-24 13:00     ` Is "make check-docs" useful anymore? Ævar Arnfjörð Bjarmason
2021-09-24 17:59       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa6kgffc8.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=mha1993@live.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.