git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-help: Try to find html pages without the git- prefix
@ 2008-04-28 10:13 Pieter de Bie
  2008-04-29  3:13 ` Christian Couder
  0 siblings, 1 reply; 4+ messages in thread
From: Pieter de Bie @ 2008-04-28 10:13 UTC (permalink / raw)
  To: git; +Cc: Pieter de Bie

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] git-help: Try to find html pages without the git- prefix
  2008-04-28 10:13 [PATCH] git-help: Try to find html pages without the git- prefix Pieter de Bie
@ 2008-04-29  3:13 ` Christian Couder
  2008-04-29  4:45   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Couder @ 2008-04-29  3:13 UTC (permalink / raw)
  To: Pieter de Bie; +Cc: git

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] git-help: Try to find html pages without the git- prefix
  2008-04-29  3:13 ` Christian Couder
@ 2008-04-29  4:45   ` Junio C Hamano
  2008-04-29  5:18     ` Christian Couder
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2008-04-29  4:45 UTC (permalink / raw)
  To: Christian Couder; +Cc: Pieter de Bie, git

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 ;-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] git-help: Try to find html pages without the git- prefix
  2008-04-29  4:45   ` Junio C Hamano
@ 2008-04-29  5:18     ` Christian Couder
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Couder @ 2008-04-29  5:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pieter de Bie, git

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 
> ;-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-29  5:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 10:13 [PATCH] git-help: Try to find html pages without the git- prefix Pieter de Bie
2008-04-29  3:13 ` Christian Couder
2008-04-29  4:45   ` Junio C Hamano
2008-04-29  5:18     ` Christian Couder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).