{"thread":{"id":"30922","subject":"[PATCH v3 2/3] Allow help.htmlpath to be a URL prefix","startedAt":"2012-06-28T06:58:02Z","lastAt":"2012-06-28T23:38:30Z","messageCount":6,"participants":["Chris Webb","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"194403","messageId":"8d3c71d21710c66e4d5560cec958552b69a22338.1340866684.git.chris@arachsys.com","threadId":"30922","inReplyTo":null,"subject":"[PATCH v3 1/3] Add config variable to set HTML path for git-help --web","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2012-06-28T06:58:02Z","receivedAt":"2012-06-28T06:58:02Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"If set in git-config, help.htmlpath overrides system_path(GIT_HTML_PATH)\nwhich was compiled in. This allows users to repoint system-wide git at\ntheir own copy of the documentation without recompiling.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n builtin/help.c |   11 ++++++++++-\n 1 file changed, 10 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 8f9cd60..b467db2 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -34,6 +34,8 @@ enum help_format {\n \tHELP_FORMAT_WEB\n };\n \n+static char *html_path = NULL;\n+\n static int show_all = 0;\n static unsigned int colopts;\n static enum help_format help_format = HELP_FORMAT_NONE;\n@@ -265,6 +267,12 @@ static int git_help_config(const char *var, const char *value, void *cb)\n \t\thelp_format = parse_help_format(value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"help.htmlpath\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\thtml_path = xstrdup(value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"man.viewer\")) {\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\n@@ -387,7 +395,8 @@ static void show_info_page(const char *git_cmd)\n static void get_html_page_path(struct strbuf *page_path, const char *page)\n {\n \tstruct stat st;\n-\tconst char *html_path = system_path(GIT_HTML_PATH);\n+\tif (!html_path)\n+\t\thtml_path = system_path(GIT_HTML_PATH);\n \n \t/* Check that we have a git documentation directory. */\n \tif (stat(mkpath(\"%s/git.html\", html_path), &st)\n-- \n1.7.10\n"},{"id":"194402","messageId":"cebaecfaa217a20794e8278b4db3ce5b8d667834.1340866684.git.chris@arachsys.com","threadId":"30922","inReplyTo":"8d3c71d21710c66e4d5560cec958552b69a22338.1340866684.git.chris@arachsys.com","subject":"[PATCH v3 2/3] Allow help.htmlpath to be a URL prefix","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2012-06-28T06:58:03Z","receivedAt":"2012-06-28T06:58:03Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Setting this to a URL prefix instead of a path to a local directory allows\ngit-help --web to work even when HTML docs aren't locally installed, by\npointing the browser at a copy accessible on the web. For example,\n\n    [help]\n      format = html\n      htmlpath = http://git-scm.com/docs\n\nwill use the publicly available documentation on the git homepage.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n builtin/help.c |    8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex b467db2..92f2349 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -399,9 +399,11 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)\n \t\thtml_path = system_path(GIT_HTML_PATH);\n \n \t/* Check that we have a git documentation directory. */\n-\tif (stat(mkpath(\"%s/git.html\", html_path), &st)\n-\t    || !S_ISREG(st.st_mode))\n-\t\tdie(_(\"'%s': not a documentation directory.\"), html_path);\n+\tif (!strstr(html_path, \"://\")) {\n+\t\tif (stat(mkpath(\"%s/git.html\", html_path), &st)\n+\t\t\t\t|| !S_ISREG(st.st_mode))\n+\t\t\tdie(\"'%s': not a documentation directory.\", html_path);\n+\t}\n \n \tstrbuf_init(page_path, 0);\n \tstrbuf_addf(page_path, \"%s/%s.html\", html_path, page);\n-- \n1.7.10\n"},{"id":"194404","messageId":"2fa0d1250c26eaa0d915e8d1cfbd10554a834460.1340866684.git.chris@arachsys.com","threadId":"30922","inReplyTo":"8d3c71d21710c66e4d5560cec958552b69a22338.1340866684.git.chris@arachsys.com","subject":"[PATCH v3 3/3] Add a help format 'usage' to provide brief command usage","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2012-06-28T06:58:04Z","receivedAt":"2012-06-28T06:58:04Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Configuring the new help.format = usage makes git foo --help exactly\nequivalent to git foo -h, displaying brief command-line usage info\ninstead of full documentation in the form of a man/html page.\n\nThis is useful on stripped-down servers where man pages and viewer\naren't present, or if your fingers are trained to type COMMAND --help\ninstead of COMMAND -h to get usage info and the man page behaviour is\ndisturbing.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n builtin/help.c |   16 ++++++++++++++--\n 1 file changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 92f2349..0df5bbf 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -31,7 +31,8 @@ enum help_format {\n \tHELP_FORMAT_NONE,\n \tHELP_FORMAT_MAN,\n \tHELP_FORMAT_INFO,\n-\tHELP_FORMAT_WEB\n+\tHELP_FORMAT_WEB,\n+\tHELP_FORMAT_USAGE\n };\n \n static char *html_path = NULL;\n@@ -46,11 +47,12 @@ static struct option builtin_help_options[] = {\n \t\t\tHELP_FORMAT_WEB),\n \tOPT_SET_INT('i', \"info\", &help_format, \"show info page\",\n \t\t\tHELP_FORMAT_INFO),\n+\tOPT_SET_INT('u', \"usage\", &help_format, \"show usage\", HELP_FORMAT_USAGE),\n \tOPT_END(),\n };\n \n static const char * const builtin_help_usage[] = {\n-\t\"git help [--all] [--man|--web|--info] [command]\",\n+\t\"git help [--all] [--man|--web|--info|--usage] [command]\",\n \tNULL\n };\n \n@@ -62,6 +64,8 @@ static enum help_format parse_help_format(const char *format)\n \t\treturn HELP_FORMAT_INFO;\n \tif (!strcmp(format, \"web\") || !strcmp(format, \"html\"))\n \t\treturn HELP_FORMAT_WEB;\n+\tif (!strcmp(format, \"usage\"))\n+\t\treturn HELP_FORMAT_USAGE;\n \tdie(_(\"unrecognized help format '%s'\"), format);\n }\n \n@@ -431,6 +435,11 @@ static void show_html_page(const char *git_cmd)\n \topen_html(page_path.buf);\n }\n \n+static void show_usage(const char *git_cmd)\n+{\n+\texecl_git_cmd(git_cmd, \"-h\", NULL);\n+}\n+\n int cmd_help(int argc, const char **argv, const char *prefix)\n {\n \tint nongit;\n@@ -482,6 +491,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \tcase HELP_FORMAT_WEB:\n \t\tshow_html_page(argv[0]);\n \t\tbreak;\n+\tcase HELP_FORMAT_USAGE:\n+\t\tshow_usage(argv[0]);\n+\t\tbreak;\n \t}\n \n \treturn 0;\n-- \n1.7.10\n"},{"id":"194417","messageId":"7vvcib3zam.fsf@alter.siamese.dyndns.org","threadId":"30922","inReplyTo":"cebaecfaa217a20794e8278b4db3ce5b8d667834.1340866684.git.chris@arachsys.com","subject":"Re: [PATCH v3 2/3] Allow help.htmlpath to be a URL prefix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-28T21:24:33Z","receivedAt":"2012-06-28T21:24:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> Setting this to a URL prefix instead of a path to a local directory allows\n> git-help --web to work even when HTML docs aren't locally installed, by\n> pointing the browser at a copy accessible on the web. For example,\n>\n>     [help]\n>       format = html\n>       htmlpath = http://git-scm.com/docs\n>\n> will use the publicly available documentation on the git homepage.\n>\n> Signed-off-by: Chris Webb <chris@arachsys.com>\n> ---\n>  builtin/help.c |    8 +++++---\n>  1 file changed, 5 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/help.c b/builtin/help.c\n> index b467db2..92f2349 100644\n> --- a/builtin/help.c\n> +++ b/builtin/help.c\n> @@ -399,9 +399,11 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)\n>  \t\thtml_path = system_path(GIT_HTML_PATH);\n>  \n>  \t/* Check that we have a git documentation directory. */\n> -\tif (stat(mkpath(\"%s/git.html\", html_path), &st)\n> -\t    || !S_ISREG(st.st_mode))\n> -\t\tdie(_(\"'%s': not a documentation directory.\"), html_path);\n> +\tif (!strstr(html_path, \"://\")) {\n> +\t\tif (stat(mkpath(\"%s/git.html\", html_path), &st)\n> +\t\t\t\t|| !S_ISREG(st.st_mode))\n> +\t\t\tdie(\"'%s': not a documentation directory.\", html_path);\n> +\t}\n>  \n>  \tstrbuf_init(page_path, 0);\n>  \tstrbuf_addf(page_path, \"%s/%s.html\", html_path, page);\n\nSounds sensible and looks reasonable.  Thanks.\n\nI do not think [PATCH 3/3] is a positive change at all, though.\n"},{"id":"194418","messageId":"7vr4sz3yli.fsf@alter.siamese.dyndns.org","threadId":"30922","inReplyTo":"8d3c71d21710c66e4d5560cec958552b69a22338.1340866684.git.chris@arachsys.com","subject":"Re: [PATCH v3 1/3] Add config variable to set HTML path for git-help --web","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-28T21:39:37Z","receivedAt":"2012-06-28T21:39:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> If set in git-config, help.htmlpath overrides system_path(GIT_HTML_PATH)\n> which was compiled in. This allows users to repoint system-wide git at\n> their own copy of the documentation without recompiling.\n>\n> Signed-off-by: Chris Webb <chris@arachsys.com>\n> ---\n>  builtin/help.c |   11 ++++++++++-\n>  1 file changed, 10 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/help.c b/builtin/help.c\n> index 8f9cd60..b467db2 100644\n> --- a/builtin/help.c\n> +++ b/builtin/help.c\n> @@ -34,6 +34,8 @@ enum help_format {\n>  \tHELP_FORMAT_WEB\n>  };\n>  \n> +static char *html_path = NULL;\n\nI'll queue after updating this to\n\n\tstatic const char *html_path;\n\nas the return value of const char *system_path(GIT_HTML_PATH) is\nassigned to it.\n"},{"id":"194421","messageId":"20120628233830.GA2765@arachsys.com","threadId":"30922","inReplyTo":"7vvcib3zam.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 2/3] Allow help.htmlpath to be a URL prefix","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2012-06-28T23:38:30Z","receivedAt":"2012-06-28T23:38:30Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Sounds sensible and looks reasonable.  Thanks.\n\nGreat! Glad they were of interest.\n\n> I do not think [PATCH 3/3] is a positive change at all, though.\n\nYes, I think my aversion for being thrown into the full manual with\ngit foo --help is quite unusual, so this one's probably better left\nas one of my idiosyncratic local patches.\n\nThe reason I thought there was a chance this could be of wider interest is\nthat, on a machine without man pages,\n\n  $ git show --help\n  warning: failed to exec 'man': No such file or directory\n  fatal: no man viewer handled the request\n\nis a bit unfriendly when git actually has enough internal help to be able to\noffer\n\n  $ git show -h    \n  usage: git log [<options>] [<since>..<until>] [[--] <path>...]\n     or: git show [options] <object>...\n\n...but only if you know that -h exists and is not a synonym for --help.\n\nCheers,\n\nChris.\n"}]}