On Sat, May 26, 2018 at 9:55 AM, Nguyễn Thái Ngọc Duy <pclo...@gmail.com> wrote:
> 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 <pclo...@gmail.com>
> ---
> diff --git a/help.c b/help.c
> @@ -409,6 +409,62 @@ void list_common_guides_help(void)
> +void list_config_help(void)
> +{
> +       for (p = config_name_list; *p; p++) {
> +               const char *var = *p;
> +               struct strbuf sb = STRBUF_INIT;
> +
> +               for (e = slot_expansions; e->prefix; e++) {
> +
> +                       strbuf_reset(&sb);

Style nit: unwanted blank line

> +                       strbuf_addf(&sb, "%s.%s", e->prefix, e->placeholder);
> +                       if (!strcasecmp(var, sb.buf)) {
> +                               e->fn(&keys, e->prefix);
> +                               e->found++;
> +                               break;
> +                       }
> +               }
> +               strbuf_release(&sb);
> +               if (!e->prefix)
> +                       string_list_append(&keys, var);
> +       }

Reply via email to