# [PATCH] git-help: Try to find html pages without the git- prefix

4 messages from 2008-04-28 to 2008-04-29. Participants: Pieter de Bie, Christian Couder, Junio C Hamano.
Thread: https://gitlist.dev/t/13303

## Pieter de Bie, 2008-04-28 10:13

Subject: [PATCH] git-help: Try to find html pages without the git- prefix
Message-ID: <1209377611-90005-1-git-send-email-pdebie@ai.rug.nl>
URL: https://gitlist.dev/e/1209377611-90005-1-git-send-email-pdebie%40ai.rug.nl

```
Some html documentation does not have the git- prefix, for example hooks.html.
If the git-command.html page does not exist, try to find the command.html
file. This allows commands like `git help -w hooks' to work
---
 help.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/help.c b/help.c
index 10298fb..633bfc9 100644
--- a/help.c
+++ b/help.c
@@ -488,11 +488,15 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
 
 static void show_html_page(const char *git_cmd)
 {
+	struct stat st;
 	const char *page = cmd_to_page(git_cmd);
 	struct strbuf page_path; /* it leaks but we exec bellow */
 
 	get_html_page_path(&page_path, page);
 
+	if (stat(page_path.buf, &st) || !S_ISREG(st.st_mode))
+		get_html_page_path(&page_path, git_cmd);
+
 	execl_git_cmd("web--browse", "-c", "help.browser", page_path.buf, NULL);
 }
 
-- 
1.5.5.1.174.g32fa0.dirty

```

## Christian Couder, 2008-04-29 03:13

Subject: Re: [PATCH] git-help: Try to find html pages without the git- prefix
Message-ID: <200804290513.40948.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/200804290513.40948.chriscool%40tuxfamily.org
In-Reply-To: <1209377611-90005-1-git-send-email-pdebie@ai.rug.nl>

```
Le lundi 28 avril 2008, Pieter de Bie a écrit :
> Some html documentation does not have the git- prefix, for example
> hooks.html. If the git-command.html page does not exist, try to find the
> command.html file. This allows commands like `git help -w hooks' to work

Yes, this works fine for html documentation.

But 'git help -w githooks' could work fine too, if the source filename 
was "githooks.txt" instead of "hooks.txt". Because the "cmd_to_page" 
function returns its input as is, if it starts with "git".

And with more filenames like "githooks.txt" we could also have 
more "githooks" like regular man pages without poluting too much the man 
page namespace.

We already have the following files following that scheme:

gitk.txt
gitattributes.txt
gitignore.txt
gitcli.txt
gitmodules.txt
git.txt

And for example the following commands are already working:

$ git help -w gitmodules
$ git help -m gitmodules
$ man gitmodules

("git help -i gitmodules" should work too, but info format help seems 
broken.)

Of course typing "git help hooks" is shorter and simpler than "git help 
githooks", so it could perhaps still be a good idea to try "gitXXX" as a 
fallback if we find nothing for "git-XXX".

Thanks,
Christian.

```

## Junio C Hamano, 2008-04-29 04:45

Subject: Re: [PATCH] git-help: Try to find html pages without the git- prefix
Message-ID: <7vy76x8e0s.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy76x8e0s.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <200804290513.40948.chriscool@tuxfamily.org>

```
Christian Couder <chriscool@tuxfamily.org> writes:

> We already have the following files following that scheme:
>
> gitk.txt
> gitattributes.txt
> gitignore.txt
> gitcli.txt
> gitmodules.txt
> git.txt
>
> And for example the following commands are already working:
>
> $ git help -w gitmodules
> $ git help -m gitmodules
> $ man gitmodules

That is not surprise as gitattributes(5), gitignore(5) and gitmodules(5)
work by design.  They are valid manual pages in section 5 (file formats).

I am not sure about hooks let alone gitcli --- they are not something you
would traditionally place in section 5.

It would be nice if "git help <any path you see in Documentation/>" worked
as expected, although I personally tend to go to the *.txt files ;-)

```

## Christian Couder, 2008-04-29 05:18

Subject: Re: [PATCH] git-help: Try to find html pages without the git- prefix
Message-ID: <200804290718.47961.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/200804290718.47961.chriscool%40tuxfamily.org
In-Reply-To: <7vy76x8e0s.fsf@gitster.siamese.dyndns.org>

```
Le mardi 29 avril 2008, Junio C Hamano a écrit :
> Christian Couder <chriscool@tuxfamily.org> writes:
> > We already have the following files following that scheme:
> >
> > gitk.txt
> > gitattributes.txt
> > gitignore.txt
> > gitcli.txt
> > gitmodules.txt
> > git.txt
> >
> > And for example the following commands are already working:
> >
> > $ git help -w gitmodules
> > $ git help -m gitmodules
> > $ man gitmodules
>
> That is not surprise as gitattributes(5), gitignore(5) and gitmodules(5)
> work by design.  They are valid manual pages in section 5 (file formats).
>
> I am not sure about hooks let alone gitcli --- they are not something you
> would traditionally place in section 5.

Aren't there other man sections where we could put them ?

> It would be nice if "git help <any path you see in Documentation/>"
> worked as expected, 

I agree and that means that we should find an appropriate man section for 
everything in "Documentation/". Otherwise how could "git help -m <any path 
you see in Documentation/>" work ?

Thanks,
Christian.

> although I personally tend to go to the *.txt files 
> ;-)

```
