Subject: Re: [PATCH 2/3] Allow help.htmlpath to be an http: URL

From: Junio C Hamano <[email-masked]>
Date: Wed, 27 Jun 2012 14:32:49 -0700

Jeff King <[email-masked]> writes:

> On Wed, Jun 27, 2012 at 09:55:13PM +0100, Chris Webb wrote:
>
>> Setting this to a URL prefix instead of a path to a local directory allows
>> git-help --web to work even when HTML docs aren't locally installed, by
>> pointing the browser at 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.
>
> Nice.
>
>>  	/* 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);
>> +	if (prefixcmp(html_path, "http:")) {
>> +		if (stat(mkpath("%s/git.html", html_path), &st)
>> +				|| !S_ISREG(st.st_mode))
>> +			die("'%s': not a documentation directory.", html_path);
>> +	}
>
> I'd rather not tie this directly to http. Is there any reason not to
> allow https, for example? Can we maybe just look for strstr("://")
> instead? That's the same magic we use to differentiate URLs from paths
> when looking for repositories.

One part of me says "any non-standard html-path should be sent to
the browser".  Another part of me says "what if network is
unavailable?  Wouldn't it be nice to fall back to use the local
copy?"

And a small voice in me responds to the latter with "If you have a
local copy anyway, why would you want to go to the network even if
you could?"

Which leads me to conclude that it is the right thing to do if
html_path came from the configuration, not from the compiled-in
default, to always ask browser to do its thing, and let it fail if
it has to fail---it is not Git's problem anymore at that point.

It also is the simplest.