From: Eric Sunshine <sunshine@sunshineco.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 4/9] help: add --config to list all available config
Date: Fri, 11 May 2018 18:39:20 -0400 [thread overview]
Message-ID: <CAPig+cR63S-cpihwHYOadK_SbNRoCVjOOQH87Ry7fdCwxdbOxg@mail.gmail.com> (raw)
In-Reply-To: <20180510141927.23590-5-pclouds@gmail.com>
On Thu, May 10, 2018 at 10:20 AM Nguyễn Thái Ngọc Duy <pclouds@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.
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/help.c b/builtin/help.c
> @@ -44,6 +45,7 @@ static struct option builtin_help_options[] = {
> OPT_BOOL('g', "guides", &show_guides, N_("print list of useful
guides")),
> + OPT_BOOL('c', "config", &show_config, N_("print list recognized
config variables")),
s/list/& of/
Though, simpler might be better: "print all configuration variable names"
> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
> @@ -76,6 +76,24 @@ print_command_list () {
> +print_config_list() {
> + cat <<EOF
> +static const char *config_name_list[] = {
> +EOF
> + grep '^[a-zA-Z].*\..*::$' Documentation/config.txt |
> + grep -v deprecated |
> + sed 's/::$//; s/, */\n/g' |
Nit: "grep -v" and "sed" could be combined:
sed '/deprecated/d; s/::$//; s/, */\n/g' |
> + sort |
> + while read line
> + do
> + echo " \"$line\","
> + done
> + cat <<EOF
> + NULL,
> +};
> +EOF
> diff --git a/help.c b/help.c
> @@ -409,6 +409,54 @@ void list_common_guides_help(void)
> +void list_config_help(void)
> +{
> + [...]
> + for (p = config_name_list; *p; p++) {
> + const char *var = *p;
> +
> + for (e = slot_expansions; e->prefix; e++) {
> + struct strbuf sb = STRBUF_INIT;
> +
> + strbuf_addf(&sb, "%s.%s", e->prefix,
e->placeholder);
> + if (strcasecmp(var, sb.buf))
> + continue;
Isn't this "continue" leaking the strbuf? It seems that it would be easier
to declare the strbuf once outside the loop, strbuf_reset() it at the top
of the loop, and finally strbuf_release() it after the loop exits.
> + e->fn(e->prefix);
> + strbuf_release(&sb);
> + e->found++;
> + break;
> + }
> + if (!e->prefix)
> + puts(var);
> + }
next prev parent reply other threads:[~2018-05-11 22:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 14:19 [PATCH 0/9] completion: avoid hard coding config var list Nguyễn Thái Ngọc Duy
2018-05-10 14:19 ` [PATCH 1/9] Add and use generic name->id mapping code for color slot parsing Nguyễn Thái Ngọc Duy
2018-05-10 17:16 ` Stefan Beller
2018-05-11 7:22 ` Duy Nguyen
2018-05-10 14:19 ` [PATCH 2/9] grep: keep all colors in an array Nguyễn Thái Ngọc Duy
2018-05-10 14:19 ` [PATCH 3/9] fsck: factor out msg_id_info[] lazy initialization code Nguyễn Thái Ngọc Duy
2018-05-11 22:23 ` Eric Sunshine
2018-05-10 14:19 ` [PATCH 4/9] help: add --config to list all available config Nguyễn Thái Ngọc Duy
2018-05-11 22:39 ` Eric Sunshine [this message]
2018-05-10 14:19 ` [PATCH 5/9] advice: keep config name in camelCase in advice_config[] Nguyễn Thái Ngọc Duy
2018-05-10 14:19 ` [PATCH 6/9] am: move advice.amWorkDir parsing back to advice.c Nguyễn Thái Ngọc Duy
2018-05-11 22:42 ` Eric Sunshine
2018-05-10 14:19 ` [PATCH 7/9] completion: drop the hard coded list of config vars Nguyễn Thái Ngọc Duy
2018-05-11 22:47 ` Eric Sunshine
2018-05-20 16:01 ` SZEDER Gábor
2018-05-10 14:19 ` [PATCH 8/9] completion: support case-insensitive config vars just a bit Nguyễn Thái Ngọc Duy
2018-05-20 16:33 ` SZEDER Gábor
2018-05-10 14:19 ` [PATCH 9/9] log-tree: allow to customize 'grafted' color Nguyễn Thái Ngọc Duy
2018-05-10 14:22 ` [PATCH 0/9] completion: avoid hard coding config var list Duy Nguyen
2018-05-11 6:00 ` Junio C Hamano
2018-05-11 6:24 ` Duy Nguyen
2018-05-26 13:55 ` [PATCH v2 00/11] " Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 01/11] Add and use generic name->id mapping code for color slot parsing Nguyễn Thái Ngọc Duy
2018-05-29 17:41 ` Stefan Beller
2018-05-26 13:55 ` [PATCH v2 02/11] grep: keep all colors in an array Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 03/11] fsck: factor out msg_id_info[] lazy initialization code Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 04/11] help: add --config to list all available config Nguyễn Thái Ngọc Duy
2018-05-27 7:33 ` Eric Sunshine
2018-05-26 13:55 ` [PATCH v2 05/11] fsck: produce camelCase config key names Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 06/11] advice: keep config name in camelCase in advice_config[] Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 07/11] am: move advice.amWorkDir parsing back to advice.c Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 08/11] completion: drop the hard coded list of config vars Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 09/11] completion: keep other config var completion in camelCase Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 10/11] completion: support case-insensitive config vars Nguyễn Thái Ngọc Duy
2018-05-26 13:55 ` [PATCH v2 11/11] log-tree: allow to customize 'grafted' color Nguyễn Thái Ngọc Duy
2018-05-27 18:28 ` [PATCH v2 12/11] completion: complete general config vars in two steps Nguyễn Thái Ngọc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPig+cR63S-cpihwHYOadK_SbNRoCVjOOQH87Ry7fdCwxdbOxg@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).