diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-11 17:41:00 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-11 17:41:00 -0700 |
commit | b3569933dd8962e79ce5e1232f06a9b74026b762 (patch) | |
tree | 3c17bdc239f45f275114d1af16cb141aaf3bf5e1 /builtin | |
parent | fa7285dc3dce8bd01fd8c665b032603ed55348e5 (diff) | |
parent | a133737b809a6556f087e590e862e8f29561710a (diff) | |
download | git-b3569933dd8962e79ce5e1232f06a9b74026b762.tar.gz |
Merge branch 'po/help-guides'
"git help" learned "-g" option to show the list of guides just like
list of commands are given with "-a".
* po/help-guides:
doc: include --guide option description for "git help"
help: mention -a and -g option, and 'git help <concept>' usage.
builtin/help.c: add list_common_guides_help() function
builtin/help.c: add --guide option
builtin/help.c: split "-a" processing into two
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/help.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/builtin/help.c b/builtin/help.c index d1d71816a9..034c36c254 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_BOOLEAN('a', "all", &show_all, N_("print all available commands")), + 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 }; @@ -413,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; @@ -428,7 +461,16 @@ 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_guides) + list_common_guides_help(); + + if (show_all || show_guides) { printf("%s\n", _(git_more_info_string)); + /* + * We're done. Ignore any remaining args + */ return 0; } |