From 9665627d8cc6f0263f0019e92c67a38223804b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 23 Apr 2012 19:30:24 +0700 Subject: i18n: help: mark strings for translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch also marks most common commands' synopsis for translation so that "git help" gives a friendly listing. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/help.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 61ff79839b..96a462cf1b 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -54,7 +54,7 @@ static enum help_format parse_help_format(const char *format) return HELP_FORMAT_INFO; if (!strcmp(format, "web") || !strcmp(format, "html")) return HELP_FORMAT_WEB; - die("unrecognized help format '%s'", format); + die(_("unrecognized help format '%s'"), format); } static const char *get_man_viewer_info(const char *name) @@ -82,7 +82,7 @@ static int check_emacsclient_version(void) ec_process.err = -1; ec_process.stdout_to_stderr = 1; if (start_command(&ec_process)) - return error("Failed to start emacsclient."); + return error(_("Failed to start emacsclient.")); strbuf_read(&buffer, ec_process.err, 20); close(ec_process.err); @@ -95,7 +95,7 @@ static int check_emacsclient_version(void) if (prefixcmp(buffer.buf, "emacsclient")) { strbuf_release(&buffer); - return error("Failed to parse emacsclient version."); + return error(_("Failed to parse emacsclient version.")); } strbuf_remove(&buffer, 0, strlen("emacsclient")); @@ -103,7 +103,7 @@ static int check_emacsclient_version(void) if (version < 22) { strbuf_release(&buffer); - return error("emacsclient version '%d' too old (< 22).", + return error(_("emacsclient version '%d' too old (< 22)."), version); } @@ -121,7 +121,7 @@ static void exec_woman_emacs(const char *path, const char *page) path = "emacsclient"; strbuf_addf(&man_page, "(woman \"%s\")", page); execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL); - warning("failed to exec '%s': %s", path, strerror(errno)); + warning(_("failed to exec '%s': %s"), path, strerror(errno)); } } @@ -149,7 +149,7 @@ static void exec_man_konqueror(const char *path, const char *page) path = "kfmclient"; strbuf_addf(&man_page, "man:%s(1)", page); execlp(path, filename, "newTab", man_page.buf, (char *)NULL); - warning("failed to exec '%s': %s", path, strerror(errno)); + warning(_("failed to exec '%s': %s"), path, strerror(errno)); } } @@ -158,7 +158,7 @@ static void exec_man_man(const char *path, const char *page) if (!path) path = "man"; execlp(path, "man", page, (char *)NULL); - warning("failed to exec '%s': %s", path, strerror(errno)); + warning(_("failed to exec '%s': %s"), path, strerror(errno)); } static void exec_man_cmd(const char *cmd, const char *page) @@ -166,7 +166,7 @@ static void exec_man_cmd(const char *cmd, const char *page) struct strbuf shell_cmd = STRBUF_INIT; strbuf_addf(&shell_cmd, "%s %s", cmd, page); execl("/bin/sh", "sh", "-c", shell_cmd.buf, (char *)NULL); - warning("failed to exec '%s': %s", cmd, strerror(errno)); + warning(_("failed to exec '%s': %s"), cmd, strerror(errno)); } static void add_man_viewer(const char *name) @@ -206,8 +206,8 @@ static int add_man_viewer_path(const char *name, if (supported_man_viewer(name, len)) do_add_man_viewer_info(name, len, value); else - warning("'%s': path for unsupported man viewer.\n" - "Please consider using 'man..cmd' instead.", + warning(_("'%s': path for unsupported man viewer.\n" + "Please consider using 'man..cmd' instead."), name); return 0; @@ -218,8 +218,8 @@ static int add_man_viewer_cmd(const char *name, const char *value) { if (supported_man_viewer(name, len)) - warning("'%s': cmd for supported man viewer.\n" - "Please consider using 'man..path' instead.", + warning(_("'%s': cmd for supported man viewer.\n" + "Please consider using 'man..path' instead."), name); else do_add_man_viewer_info(name, len, value); @@ -280,11 +280,11 @@ void list_common_cmds_help(void) longest = strlen(common_cmds[i].name); } - puts("The most commonly used git commands are:"); + puts(_("The most commonly used git commands are:")); for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { printf(" %s ", common_cmds[i].name); mput_char(' ', longest - strlen(common_cmds[i].name)); - puts(common_cmds[i].help); + puts(_(common_cmds[i].help)); } } @@ -348,7 +348,7 @@ static void exec_viewer(const char *name, const char *page) else if (info) exec_man_cmd(info, page); else - warning("'%s': unknown man viewer.", name); + warning(_("'%s': unknown man viewer."), name); } static void show_man_page(const char *git_cmd) @@ -365,7 +365,7 @@ static void show_man_page(const char *git_cmd) if (fallback) exec_viewer(fallback, page); exec_viewer("man", page); - die("no man viewer handled the request"); + die(_("no man viewer handled the request")); } static void show_info_page(const char *git_cmd) @@ -373,7 +373,7 @@ static void show_info_page(const char *git_cmd) const char *page = cmd_to_page(git_cmd); setenv("INFOPATH", system_path(GIT_INFO_PATH), 1); execlp("info", "info", "gitman", page, (char *)NULL); - die("no info viewer handled the request"); + die(_("no info viewer handled the request")); } static void get_html_page_path(struct strbuf *page_path, const char *page) @@ -384,7 +384,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page) /* 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); + die(_("'%s': not a documentation directory."), html_path); strbuf_init(page_path, 0); strbuf_addf(page_path, "%s/%s.html", html_path, page); @@ -424,16 +424,16 @@ int cmd_help(int argc, const char **argv, const char *prefix) parsed_help_format = help_format; if (show_all) { - printf("usage: %s\n\n", git_usage_string); - list_commands("git commands", &main_cmds, &other_cmds); - printf("%s\n", git_more_info_string); + printf(_("usage: %s%s"), _(git_usage_string), "\n\n"); + list_commands(_("git commands"), &main_cmds, &other_cmds); + printf("%s\n", _(git_more_info_string)); return 0; } if (!argv[0]) { - printf("usage: %s\n\n", git_usage_string); + printf(_("usage: %s%s"), _(git_usage_string), "\n\n"); list_common_cmds_help(); - printf("\n%s\n", git_more_info_string); + printf("\n%s\n", _(git_more_info_string)); return 0; } @@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix) alias = alias_lookup(argv[0]); if (alias && !is_git_command(argv[0])) { - printf("`git %s' is aliased to `%s'\n", argv[0], alias); + printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias); return 0; } -- cgit v1.2.1 From 4470ef94973cf40bb83864d480cee1e064053879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 25 Apr 2012 18:21:53 +0700 Subject: help: replace underlining "help -a" headers using hyphens with a blank line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We used to underline a header text, like this: This is a header ---------------- content... But calculating text length so that the dashes align with the text could get complicated because the text could be in any charset in translated Git. There is no point to use this pseudo underline; simply a blank line would do and it even makes it easier to read: This is a header content... While at it, give translators more context to translate, e.g. e.g. "git commands available..." instead of "%s available..." Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 96a462cf1b..e63668ade4 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -425,7 +425,7 @@ int cmd_help(int argc, const char **argv, const char *prefix) if (show_all) { printf(_("usage: %s%s"), _(git_usage_string), "\n\n"); - list_commands(_("git commands"), &main_cmds, &other_cmds); + list_commands(&main_cmds, &other_cmds); printf("%s\n", _(git_more_info_string)); return 0; } -- cgit v1.2.1 From dbfae689690bead0e49130b149c869834795cf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 13 Apr 2012 17:54:37 +0700 Subject: help: reuse print_columns() for help -a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "help -a" also respects column.ui (and column.help if presents) Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/help.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 61ff79839b..c64f1522d8 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -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 { @@ -30,6 +31,7 @@ enum help_format { }; 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,6 +253,8 @@ 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); @@ -424,8 +428,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\n\n", git_usage_string); - list_commands("git commands", &main_cmds, &other_cmds); + list_commands("git commands", colopts, &main_cmds, &other_cmds); printf("%s\n", git_more_info_string); return 0; } -- cgit v1.2.1 From 1cc8af044cad37b5f7df85b177f6aa979aa3215a Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 6 Jun 2012 20:28:16 +0000 Subject: help: use HTML as the default help format on Windows When 'git help $cmd' is run without a format option (e.g. -w), the 'man' format is always used. On some platforms, however, manual page viewers are not often available. Introduce DEFAULT_HELP_FORMAT make variable in order to allow the default format configurable at compile time, and set it to HTML when compiling on Windows (but not Cygwin). Helped-by: Jeff King Signed-off-by: Vincent van Ravesteijn Signed-off-by: Junio C Hamano --- builtin/help.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 43d3c84449..536d4fd463 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -12,6 +12,10 @@ #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]; @@ -445,7 +449,9 @@ int cmd_help(int argc, const char **argv, const char *prefix) setup_git_directory_gently(&nongit); git_config(git_help_config, NULL); - if (parsed_help_format != HELP_FORMAT_NONE) + if (parsed_help_format == HELP_FORMAT_NONE) + help_format = parse_help_format(DEFAULT_HELP_FORMAT); + else help_format = parsed_help_format; alias = alias_lookup(argv[0]); -- cgit v1.2.1 From d0408c0c8cd636233f01c0bda9ad71161609297c Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 22 Jun 2012 13:48:46 +0100 Subject: Restore use of 'help.format' configuration property in 'git help' Commit 1cc8af0 "help: use HTML as the default help format on Windows" lost the ability to make use of the help.format config value by forcing the use of a compiled in default if no command-line argument was provided. This commit restores the use of the help.format value if one is available, overriding the compiled default. Signed-off-by: Pat Thoyts Signed-off-by: Junio C Hamano --- builtin/help.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 536d4fd463..8f9cd60548 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -449,10 +449,10 @@ int cmd_help(int argc, const char **argv, const char *prefix) setup_git_directory_gently(&nongit); git_config(git_help_config, NULL); - if (parsed_help_format == HELP_FORMAT_NONE) - help_format = parse_help_format(DEFAULT_HELP_FORMAT); - else + 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])) { -- cgit v1.2.1 From 89a852efb911c260d3f7b56ef8382a0725cc931b Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Thu, 28 Jun 2012 07:58:02 +0100 Subject: Add config variable to set HTML path for git-help --web If set in git-config, help.htmlpath overrides system_path(GIT_HTML_PATH) which was compiled in. This allows users to repoint system-wide git at their own copy of the documentation without recompiling. Signed-off-by: Chris Webb Signed-off-by: Junio C Hamano --- builtin/help.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 43d3c84449..9e36fb4cc7 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -30,6 +30,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; @@ -261,6 +263,12 @@ static int git_help_config(const char *var, const char *value, void *cb) 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); @@ -383,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) -- cgit v1.2.1 From 86272b4ffeb38fb4fb1da3603bba1094fab3731b Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Thu, 28 Jun 2012 07:58:03 +0100 Subject: Allow help.htmlpath to be a URL prefix Setting this to a URL prefix instead of a path to a local directory allows git-help --web to work even when HTML docs aren't locally installed, by pointing the browser at a copy accessible on the web. For example, [help] format = html htmlpath = http://git-scm.com/docs will use the publicly available documentation on the git homepage. Signed-off-by: Chris Webb Signed-off-by: Junio C Hamano --- builtin/help.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 9e36fb4cc7..0c698b18c8 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -395,9 +395,11 @@ static void get_html_page_path(struct strbuf *page_path, const char *page) 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); -- cgit v1.2.1 From 68918696cce2db815a1b07f60d11f3c99e121b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 20 Aug 2012 19:32:17 +0700 Subject: i18n: help: mark parseopt strings for translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/help.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index efea4f55e1..bd86253d83 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -40,17 +40,17 @@ 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"), - OPT_SET_INT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN), - OPT_SET_INT('w', "web", &help_format, "show manual in web browser", + OPT_BOOLEAN('a', "all", &show_all, N_("print all available commands")), + OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN), + OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"), HELP_FORMAT_WEB), - OPT_SET_INT('i', "info", &help_format, "show info page", + OPT_SET_INT('i', "info", &help_format, N_("show info page"), HELP_FORMAT_INFO), OPT_END(), }; static const char * const builtin_help_usage[] = { - "git help [--all] [--man|--web|--info] [command]", + N_("git help [--all] [--man|--web|--info] [command]"), NULL }; -- cgit v1.2.1 From 1542d4cdad9287896fd80d84a4c2256197087308 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 18 Jan 2013 22:35:04 -0800 Subject: help: include only in one file This header not only declares but also defines the contents of the array that holds the list of command names and help text. Do not include it in multiple places to waste text space. Signed-off-by: Junio C Hamano --- builtin/help.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index bd86253d83..6067a6134b 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -6,7 +6,6 @@ #include "cache.h" #include "builtin.h" #include "exec_cmd.h" -#include "common-cmds.h" #include "parse-options.h" #include "run-command.h" #include "column.h" @@ -287,23 +286,6 @@ static int git_help_config(const char *var, const char *value, void *cb) static struct cmdnames main_cmds, other_cmds; -void list_common_cmds_help(void) -{ - int i, longest = 0; - - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { - if (longest < strlen(common_cmds[i].name)) - longest = strlen(common_cmds[i].name); - } - - puts(_("The most commonly used git commands are:")); - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { - printf(" %s ", common_cmds[i].name); - mput_char(' ', longest - strlen(common_cmds[i].name)); - puts(_(common_cmds[i].help)); - } -} - static int is_git_command(const char *s) { return is_in_cmdlist(&main_cmds, s) || -- cgit v1.2.1 From 4d5c6cefd5c3e37fdf096c955abe9f9ac5938a53 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 23 Jan 2013 01:27:09 -0500 Subject: help: use parse_config_key for man config The resulting code ends up about the same length, but it is a little more self-explanatory. It now explicitly documents and checks the pre-condition that the incoming var starts with "man.", and drops the magic offset "4". Signed-off-by: Jeff King Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/help.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index bd86253d83..04cb77d67c 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -237,21 +237,21 @@ static int add_man_viewer_cmd(const char *name, static int add_man_viewer_info(const char *var, const char *value) { - const char *name = var + 4; - const char *subkey = strrchr(name, '.'); + const char *name, *subkey; + int namelen; - if (!subkey) + if (parse_config_key(var, "man", &name, &namelen, &subkey) < 0 || !name) return 0; - if (!strcmp(subkey, ".path")) { + if (!strcmp(subkey, "path")) { if (!value) return config_error_nonbool(var); - return add_man_viewer_path(name, subkey - name, value); + return add_man_viewer_path(name, namelen, value); } - if (!strcmp(subkey, ".cmd")) { + if (!strcmp(subkey, "cmd")) { if (!value) return config_error_nonbool(var); - return add_man_viewer_cmd(name, subkey - name, value); + return add_man_viewer_cmd(name, namelen, value); } return 0; -- cgit v1.2.1 From 15f7d4943807a50e01d2fd85bcdbd44361808dd2 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Tue, 2 Apr 2013 23:39:49 +0100 Subject: builtin/help.c: split "-a" processing into two "help -a" (help all) gives the list of available commands and then further gives hints on the use of "git help". Separate these into two steps, because we will add "help -g" (help guides) that want to also show the overall hints after it is done. While at it, change the definition of the "-a" option to use OPT_BOOL, not the deprecated OPT_BOOLEAN. We do not behave differently when the user gives the "-a" option multiple times, e.g. "git help -a -a". Signed-off-by: Philip Oakley Signed-off-by: Junio C Hamano --- builtin/help.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index d1d71816a9..8969d3b2b0 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -39,7 +39,7 @@ 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, N_("print all available commands")), + OPT_BOOL('a', "all", &show_all, N_("print all available commands")), OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN), OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"), HELP_FORMAT_WEB), @@ -428,7 +428,13 @@ int cmd_help(int argc, const char **argv, const char *prefix) git_config(git_help_config, NULL); printf(_("usage: %s%s"), _(git_usage_string), "\n\n"); list_commands(colopts, &main_cmds, &other_cmds); + } + + if (show_all) { printf("%s\n", _(git_more_info_string)); + /* + * We're done. Ignore any remaining args + */ return 0; } -- cgit v1.2.1 From 65f98358c0ca5917604d3eb59b80ce14f72c2c7c Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Tue, 2 Apr 2013 23:39:50 +0100 Subject: builtin/help.c: add --guide option Logic, but no actions, included. The --all commands option, if given, will display the list of available commands. The --guide option's list of guides will then be displayed. The common commands list is only displayed if neither option, nor a command or guide name, is given. Signed-off-by: Philip Oakley Signed-off-by: Junio C Hamano --- builtin/help.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 8969d3b2b0..03d432b19e 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -36,10 +36,12 @@ enum help_format { static const char *html_path; static int show_all = 0; +static int show_guides = 0; static unsigned int colopts; static enum help_format help_format = HELP_FORMAT_NONE; static struct option builtin_help_options[] = { OPT_BOOL('a', "all", &show_all, N_("print all available commands")), + OPT_BOOL('g', "guides", &show_guides, N_("print list of useful guides")), OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN), OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"), HELP_FORMAT_WEB), @@ -49,7 +51,7 @@ static struct option builtin_help_options[] = { }; static const char * const builtin_help_usage[] = { - N_("git help [--all] [--man|--web|--info] [command]"), + N_("git help [--all] [--guides] [--man|--web|--info] [command]"), NULL }; @@ -430,7 +432,11 @@ int cmd_help(int argc, const char **argv, const char *prefix) list_commands(colopts, &main_cmds, &other_cmds); } - if (show_all) { + if (show_guides) { + /* do action - next patch */ + } + + if (show_all || show_guides) { printf("%s\n", _(git_more_info_string)); /* * We're done. Ignore any remaining args -- cgit v1.2.1 From 002b726a400a1dea16c0b59ae61527a1e55799fb Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Tue, 2 Apr 2013 23:39:51 +0100 Subject: builtin/help.c: add list_common_guides_help() function This implements what "help -g" introduced in the previous step does. Signed-off-by: Philip Oakley Signed-off-by: Junio C Hamano --- builtin/help.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 03d432b19e..034c36c254 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -415,6 +415,37 @@ static void show_html_page(const char *git_cmd) open_html(page_path.buf); } +static struct { + const char *name; + const char *help; +} common_guides[] = { + { "attributes", "Defining attributes per path" }, + { "glossary", "A Git glossary" }, + { "ignore", "Specifies intentionally untracked files to ignore" }, + { "modules", "Defining submodule properties" }, + { "revisions", "Specifying revisions and ranges for Git" }, + { "tutorial", "A tutorial introduction to Git (for version 1.5.1 or newer)" }, + { "workflows", "An overview of recommended workflows with Git"}, +}; + +static void list_common_guides_help(void) +{ + int i, longest = 0; + + for (i = 0; i < ARRAY_SIZE(common_guides); i++) { + if (longest < strlen(common_guides[i].name)) + longest = strlen(common_guides[i].name); + } + + puts(_("The common Git guides are:\n")); + for (i = 0; i < ARRAY_SIZE(common_guides); i++) { + printf(" %s ", common_guides[i].name); + mput_char(' ', longest - strlen(common_guides[i].name)); + puts(_(common_guides[i].help)); + } + putchar('\n'); +} + int cmd_help(int argc, const char **argv, const char *prefix) { int nongit; @@ -432,9 +463,8 @@ int cmd_help(int argc, const char **argv, const char *prefix) list_commands(colopts, &main_cmds, &other_cmds); } - if (show_guides) { - /* do action - next patch */ - } + if (show_guides) + list_common_guides_help(); if (show_all || show_guides) { printf("%s\n", _(git_more_info_string)); -- cgit v1.2.1 From 3561e605bc571cf28da3f90df259e9304815c5eb Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 12 Apr 2013 15:51:42 +0200 Subject: help: mark common_guides[] as translatable Signed-off-by: Simon Ruderich Acked-by: Philip Oakley Signed-off-by: Junio C Hamano --- builtin/help.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 034c36c254..062957f629 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -419,13 +419,13 @@ static struct { const char *name; const char *help; } common_guides[] = { - { "attributes", "Defining attributes per path" }, - { "glossary", "A Git glossary" }, - { "ignore", "Specifies intentionally untracked files to ignore" }, - { "modules", "Defining submodule properties" }, - { "revisions", "Specifying revisions and ranges for Git" }, - { "tutorial", "A tutorial introduction to Git (for version 1.5.1 or newer)" }, - { "workflows", "An overview of recommended workflows with Git"}, + { "attributes", N_("Defining attributes per path") }, + { "glossary", N_("A Git glossary") }, + { "ignore", N_("Specifies intentionally untracked files to ignore") }, + { "modules", N_("Defining submodule properties") }, + { "revisions", N_("Specifying revisions and ranges for Git") }, + { "tutorial", N_("A tutorial introduction to Git (for version 1.5.1 or newer)") }, + { "workflows", N_("An overview of recommended workflows with Git") }, }; static void list_common_guides_help(void) -- cgit v1.2.1 From 09b7e2204a8e41307192c800162e438ec09ddd2c Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 18 Jun 2013 13:44:58 -0400 Subject: fix "builtin-*" references to be "builtin/*" Documentation and some comments still refer to files in builtin/ as 'builtin-*.[cho]'. Update these to show the correct location. Signed-off-by: Phil Hord Reviewed-by: Jonathan Nieder Assisted-by: Junio C Hamano Signed-off-by: Junio C Hamano --- builtin/help.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'builtin/help.c') diff --git a/builtin/help.c b/builtin/help.c index 6067a6134b..7854f5a8fa 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -1,6 +1,4 @@ /* - * builtin-help.c - * * Builtin help command */ #include "cache.h" -- cgit v1.2.1