diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-05-26 16:55:24 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-29 08:51:28 +0300 |
commit | 3ac68a93fd2b984e2a7e570217d2646a208ffcc3 (patch) | |
tree | a2daa2ec0763d187815899c677681ff7ccb6acf8 /builtin | |
parent | a46baac61ebc6a8b187f76bcd49b625e0d4f408e (diff) |
help: add --config to list all available config
Sometimes it helps to list all available config vars so the user can
search for something they want. The config man page can also be used
but it's harder to search if you want to focus on the variable name,
for example.
This is not the best way to collect the available config since it's
not precise. Ideally we should have a centralized list of config in C
code (pretty much like 'struct option'), but that's a lot more work.
This will do for now.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/branch.c | 3 | ||||
-rw-r--r-- | builtin/clean.c | 3 | ||||
-rw-r--r-- | builtin/commit.c | 3 | ||||
-rw-r--r-- | builtin/help.c | 9 |
4 files changed, 18 insertions, 0 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index 136d57caa4..426c20b61d 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -22,6 +22,7 @@ #include "wt-status.h" #include "ref-filter.h" #include "worktree.h" +#include "help.h" static const char * const builtin_branch_usage[] = { N_("git branch [<options>] [-r | -a] [--merged | --no-merged]"), @@ -67,6 +68,8 @@ static const char *color_branch_slots[] = { static struct string_list output = STRING_LIST_INIT_DUP; static unsigned int colopts; +define_list_config_array(color_branch_slots); + static int git_branch_config(const char *var, const char *value, void *cb) { const char *slot_name; diff --git a/builtin/clean.c b/builtin/clean.c index 0ccd95e693..ab402c204c 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -16,6 +16,7 @@ #include "column.h" #include "color.h" #include "pathspec.h" +#include "help.h" static int force = -1; /* unset */ static int interactive; @@ -91,6 +92,8 @@ struct menu_stuff { void *stuff; }; +define_list_config_array(color_interactive_slots); + static int git_clean_config(const char *var, const char *value, void *cb) { const char *slot_name; diff --git a/builtin/commit.c b/builtin/commit.c index f96755aa4b..8bb3911614 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -32,6 +32,7 @@ #include "column.h" #include "sequencer.h" #include "mailmap.h" +#include "help.h" static const char * const builtin_commit_usage[] = { N_("git commit [<options>] [--] <pathspec>..."), @@ -1185,6 +1186,8 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix, return commitable ? 0 : 1; } +define_list_config_array_extra(color_status_slots, {"added"}); + static int parse_status_slot(const char *slot) { if (!strcasecmp(slot, "added")) diff --git a/builtin/help.c b/builtin/help.c index 58e0a5507f..ccb206e1d4 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -37,6 +37,7 @@ static const char *html_path; static int show_all = 0; static int show_guides = 0; +static int show_config; static int verbose; static unsigned int colopts; static enum help_format help_format = HELP_FORMAT_NONE; @@ -45,6 +46,7 @@ static struct option builtin_help_options[] = { OPT_BOOL('a', "all", &show_all, N_("print all available commands")), OPT_HIDDEN_BOOL(0, "exclude-guides", &exclude_guides, N_("exclude guides")), OPT_BOOL('g', "guides", &show_guides, N_("print list of useful guides")), + OPT_BOOL('c', "config", &show_config, N_("print all configuration variable names")), 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), @@ -444,6 +446,13 @@ int cmd_help(int argc, const char **argv, const char *prefix) list_commands(colopts, &main_cmds, &other_cmds); } + if (show_config) { + setup_pager(); + list_config_help(); + printf("\n%s\n", _("'git help config' for more information")); + return 0; + } + if (show_guides) list_common_guides_help(); |