-
Notifications
You must be signed in to change notification settings - Fork 175
Make 'git config list --type=<X>' parse and filter types #2044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
bca83d8
93c94a1
2b2a325
4835ee5
24eb757
02849ca
9f06db2
d198c23
7568a0b
d98966f
078065c
76fc767
3c32c03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,9 @@ Valid `<type>`'s include: | |
| that the given value is canonicalize-able as an ANSI color, but it is written | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Patrick Steinhardt wrote on the Git mailing list (how to reply to this email): On Fri, Feb 13, 2026 at 11:55:08PM +0000, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <stolee@gmail.com>
>
> Previously, the --type=<X> argument to 'git config list' was ignored and
> did nothing. Now, we add the use of format_config() to the
> show_all_config() function so each key-value pair is attempted to be
> parsed. This is our first use of the 'gently' parameter with a nonzero
> value.
>
> When listing multiple values, our initial settings for the output format
> is different. Add a new init helper to specify the fact that keys should
> be shown and also add the default delimiters as they were unset in some
> cases.
>
> If there is an error in parsing, then the row is not output.
It might make sense to document the rationale behind this decision in
the commit message.
> diff --git a/builtin/config.c b/builtin/config.c
> index b4c4228311..4c4c791883 100644
> --- a/builtin/config.c
> +++ b/builtin/config.c
> @@ -318,21 +318,12 @@ static int show_all_config(const char *key_, const char *value_,
> {
> const struct config_display_options *opts = cb;
> const struct key_value_info *kvi = ctx->kvi;
> + struct strbuf formatted = STRBUF_INIT;
>
> - if (opts->show_origin || opts->show_scope) {
> - struct strbuf buf = STRBUF_INIT;
> - if (opts->show_scope)
> - show_config_scope(opts, kvi, &buf);
> - if (opts->show_origin)
> - show_config_origin(opts, kvi, &buf);
> - /* Use fwrite as "buf" can contain \0's if "end_null" is set. */
> - fwrite(buf.buf, 1, buf.len, stdout);
> - strbuf_release(&buf);
> - }
> - if (!opts->omit_values && value_)
> - printf("%s%c%s%c", key_, opts->delim, value_, opts->term);
> - else
> - printf("%s%c", key_, opts->term);
> + if (format_config(opts, &formatted, key_, value_, kvi, 1) >= 0)
> + fwrite(formatted.buf, 1, formatted.len, stdout);
We could probably use puts(3p) instead, but as we know the length of the
data ahead of time it might be more efficient to use fwrite(3p) indeed.
Ultimately I guess it doesn't matter much.
PatrickThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Junio C Hamano wrote on the Git mailing list (how to reply to this email): Patrick Steinhardt <ps@pks.im> writes:
>> - if (!opts->omit_values && value_)
>> - printf("%s%c%s%c", key_, opts->delim, value_, opts->term);
>> - else
>> - printf("%s%c", key_, opts->term);
>> + if (format_config(opts, &formatted, key_, value_, kvi, 1) >= 0)
>> + fwrite(formatted.buf, 1, formatted.len, stdout);
>
> We could probably use puts(3p) instead, but as we know the length of the
> data ahead of time it might be more efficient to use fwrite(3p) indeed.
> Ultimately I guess it doesn't matter much.
>
> Patrick
If we are not always doing LF-delimited output, puts(3) would not
help us very much, I suspect.There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Patrick Steinhardt wrote on the Git mailing list (how to reply to this email): On Tue, Feb 17, 2026 at 08:11:40AM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
>
> >> - if (!opts->omit_values && value_)
> >> - printf("%s%c%s%c", key_, opts->delim, value_, opts->term);
> >> - else
> >> - printf("%s%c", key_, opts->term);
> >> + if (format_config(opts, &formatted, key_, value_, kvi, 1) >= 0)
> >> + fwrite(formatted.buf, 1, formatted.len, stdout);
> >
> > We could probably use puts(3p) instead, but as we know the length of the
> > data ahead of time it might be more efficient to use fwrite(3p) indeed.
> > Ultimately I guess it doesn't matter much.
> >
> > Patrick
>
> If we are not always doing LF-delimited output, puts(3) would not
> help us very much, I suspect.
D'oh, right.
Patrick |
||
| as-is. | ||
| + | ||
| If the command is in `list` mode, then the `--type <type>` argument will apply | ||
| to each listed config value. If the value does not successfully parse in that | ||
| format, then it will be omitted from the list. | ||
|
|
||
| --bool:: | ||
| --int:: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derrick Stolee wrote on the Git mailing list (how to reply to this email):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):