threads / patch / 13303

patchgit-help: Try to find html pages without the git- prefix

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

## tl;dr

4 messages between Apr 28, 2008 and Apr 29, 2008. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Pieter de Bie· Apr 28, 2008, 10:13 UTC · lore
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(-)
Show changes to help.c +4 −0
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· Apr 29, 2008, 03:13 UTC · re: Pieter de Bie · lore

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

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· Apr 29, 2008, 04:45 UTC · re: Christian Couder · lore

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

Christian Couder <chriscool@tuxfamily.org> writes:
Show 14 quoted lines
> 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· Apr 29, 2008, 05:18 UTC · re: Junio C Hamano · lore

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

Le mardi 29 avril 2008, Junio C Hamano a écrit :
Show 21 quoted lines
> 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 
> ;-)

← back to recent threads