Add config variable to set HTML path for git-help --web
[gitweb.git] / builtin / help.c
index e63668ade4dd0721c27ca5045bc8a524a147f9c1..9e36fb4cc708e12e1fc60903239f3b5967835954 100644 (file)
@@ -9,6 +9,7 @@
 #include "common-cmds.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "column.h"
 #include "help.h"
 
 static struct man_viewer_list {
@@ -29,7 +30,10 @@ 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;
 static struct option builtin_help_options[] = {
        OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
@@ -251,12 +255,20 @@ static int add_man_viewer_info(const char *var, const char *value)
 
 static int git_help_config(const char *var, const char *value, void *cb)
 {
+       if (!prefixcmp(var, "column."))
+               return git_column_config(var, value, "help", &colopts);
        if (!strcmp(var, "help.format")) {
                if (!value)
                        return config_error_nonbool(var);
                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);
@@ -379,7 +391,8 @@ static void show_info_page(const char *git_cmd)
 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)
@@ -424,8 +437,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)
        parsed_help_format = help_format;
 
        if (show_all) {
+               git_config(git_help_config, NULL);
                printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
-               list_commands(&main_cmds, &other_cmds);
+               list_commands(colopts, &main_cmds, &other_cmds);
                printf("%s\n", _(git_more_info_string));
                return 0;
        }