Merge branch 'cw/help-over-network'
authorJunio C Hamano <gitster@pobox.com>
Mon, 9 Jul 2012 16:02:19 +0000 (09:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Jul 2012 16:02:19 +0000 (09:02 -0700)
"git help -w $cmd" can show HTML version of documentation for
"git-$cmd" by setting help.htmlpath to somewhere other than the
default location where the build procedure installs them locally;
the variable can even point at a http:// URL.

* cw/help-over-network:
Allow help.htmlpath to be a URL prefix
Add config variable to set HTML path for git-help --web

1  2 
builtin/help.c
diff --combined builtin/help.c
index 8f9cd60548c122d8a6f03e0b388f0b6508a3f354,0c698b18c8467a284c223d1e7e395d31f03352fd..efea4f55e173a5ff2d7e1748316d6a94266e915a
  #include "column.h"
  #include "help.h"
  
 +#ifndef DEFAULT_HELP_FORMAT
 +#define DEFAULT_HELP_FORMAT "man"
 +#endif
 +
  static struct man_viewer_list {
        struct man_viewer_list *next;
        char name[FLEX_ARRAY];
@@@ -34,6 -30,8 +34,8 @@@ enum help_format 
        HELP_FORMAT_WEB
  };
  
+ static const char *html_path;
  static int show_all = 0;
  static unsigned int colopts;
  static enum help_format help_format = HELP_FORMAT_NONE;
@@@ -265,6 -263,12 +267,12 @@@ static int git_help_config(const char *
                help_format = parse_help_format(value);
                return 0;
        }
+       if (!strcmp(var, "help.htmlpath")) {
+               if (!value)
+                       return config_error_nonbool(var);
+               html_path = xstrdup(value);
+               return 0;
+       }
        if (!strcmp(var, "man.viewer")) {
                if (!value)
                        return config_error_nonbool(var);
@@@ -387,12 -391,15 +395,15 @@@ static void show_info_page(const char *
  static void get_html_page_path(struct strbuf *page_path, const char *page)
  {
        struct stat st;
-       const char *html_path = system_path(GIT_HTML_PATH);
+       if (!html_path)
+               html_path = system_path(GIT_HTML_PATH);
  
        /* 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 (!strstr(html_path, "://")) {
+               if (stat(mkpath("%s/git.html", html_path), &st)
+                   || !S_ISREG(st.st_mode))
+                       die("'%s': not a documentation directory.", html_path);
+       }
  
        strbuf_init(page_path, 0);
        strbuf_addf(page_path, "%s/%s.html", html_path, page);
@@@ -451,8 -458,6 +462,8 @@@ int cmd_help(int argc, const char **arg
  
        if (parsed_help_format != HELP_FORMAT_NONE)
                help_format = parsed_help_format;
 +      if (help_format == HELP_FORMAT_NONE)
 +              help_format = parse_help_format(DEFAULT_HELP_FORMAT);
  
        alias = alias_lookup(argv[0]);
        if (alias && !is_git_command(argv[0])) {