git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyen Thai Ngoc Duy" <pclouds@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Show html help with git-help --html
Date: Mon, 4 Jun 2007 09:29:22 -0400	[thread overview]
Message-ID: <fcaeb9bf0706040629k489d4818sa291725cbbeead79@mail.gmail.com> (raw)
In-Reply-To: <7vps4cjg1w.fsf@assigned-by-dhcp.cox.net>

On 6/4/07, Junio C Hamano <gitster@pobox.com> wrote:
> > diff --git a/Documentation/config.txt b/Documentation/config.txt
> > index 3d8f03d..2ec8545 100644
> > --- a/Documentation/config.txt
> > +++ b/Documentation/config.txt
> > @@ -261,6 +261,18 @@ core.excludeFile::
> > ...
> > +core.htmlprogram::
> > +     Specify the program used to open html help files when 'git-help'
> > +     is called with option --html or core.help is other than 'man'.
> > +     By default, xdg-open will be used.
>
> Is the program's calling convention something that needs to be
> customizable for this to be useful?

At first I thought xdg-open would be flexible enough for most Linux
systems because it will choose the best browser you have. But I now
recall that Git does not only run on Linux.  Will make it a parameter
in config.mak.in

>
> > diff --git a/Makefile b/Makefile
> > index cac0a4a..43e0d15 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -145,6 +145,7 @@ prefix = $(HOME)
> >  bindir = $(prefix)/bin
> >  gitexecdir = $(bindir)
> >  sharedir = $(prefix)/share/
> > +htmldir = $(sharedir)/html/
> >  template_dir = $(sharedir)/git-core/templates/
> >  ifeq ($(prefix),/usr)
> >  sysconfdir = /etc
>
> Is it customary to have HTMLized documentation material for
> different packages all together in a single .../share/html/
> directory, like manpages are placed in share/man/man1/
> directory?  I somehow had an impression that a layout to have
> html directory per package (i.e. share/doc/$pkg/html/) was more
> common.  I dunno.

The default value is not really useful. I would leave that for
distribution package mantainers to decide proper location because they
have to install html files separately anyway (at least in Gentoo).
However it's not convenient for compiling-from-source users. Will redo
the patch and add rules to install html files also.

>
> > diff --git a/help.c b/help.c
> > index 6a9af4d..e3e705b 100644
> > --- a/help.c
> > +++ b/help.c
> > @@ -183,6 +187,36 @@ static void show_man_page(const char *git_cmd)
> >       execlp("man", "man", page, NULL);
> >  }
> >
> > +static void show_html_page(const char *git_cmd)
> > +{
> > +     const char *html_dir;
> > +     int i,len,ret;
> > +     char *p;
> > +
> > +     html_dir = HTML_DIR;
> > +     if (!html_help_program)
> > +             html_help_program = "xdg-open";
> > +
> > +     /* html_help_program space html_dir git- git_cmd .html */
> > +     len = strlen(html_help_program) + 1 + strlen(html_dir) + 4 + strlen(git_cmd) + 5;
> > +     p = xmalloc(len + 1);
> > +
> > +     strcpy(p, html_help_program);
> > +     strcat(p," ");
> > +     strcat(p,html_dir);
> > +     if (prefixcmp(git_cmd, "git"))
> > +             strcat(p,"git-");
> > +     strcat(p,git_cmd);
> > +     strcat(p,".html");
> > +
> > +     ret = system(p);
>
> This is sloppy in the presense of potentially unsafe characters...

I personally think users will not shoot themselves with "git help
--html ';rm -rf'" but again scripts can. Thank you for pointing out.
Will add check for file existence before calling system().
-- 
Duy

  reply	other threads:[~2007-06-04 13:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-02  1:53 [PATCH] Show html help with git-help --html Nguyễn Thái Ngọc Duy
2007-06-03 22:04 ` Junio C Hamano
2007-06-04  8:10 ` Junio C Hamano
2007-06-04 13:29   ` Nguyen Thai Ngoc Duy [this message]
2007-06-04 20:42     ` Junio C Hamano
2007-06-04 23:29       ` Nguyen Thai Ngoc Duy

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=fcaeb9bf0706040629k489d4818sa291725cbbeead79@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 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).