Skip to content

Commit 240afdd

Browse files
committed
config: create special init for list mode
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. There are two places, differing by the 'git config list' and 'git config --list' modes. Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent a98a859 commit 240afdd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

builtin/config.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,19 @@ static void display_options_init(struct config_display_options *opts)
10041004
}
10051005
}
10061006

1007+
static void display_options_init_list(struct config_display_options *opts)
1008+
{
1009+
opts->show_keys = 1;
1010+
1011+
if (opts->end_nul) {
1012+
display_options_init(opts);
1013+
} else {
1014+
opts->term = '\n';
1015+
opts->delim = ' ';
1016+
opts->key_delim = '=';
1017+
}
1018+
}
1019+
10071020
static int cmd_config_list(int argc, const char **argv, const char *prefix,
10081021
struct repository *repo UNUSED)
10091022
{
@@ -1022,7 +1035,7 @@ static int cmd_config_list(int argc, const char **argv, const char *prefix,
10221035
check_argc(argc, 0, 0);
10231036

10241037
location_options_init(&location_opts, prefix);
1025-
display_options_init(&display_opts);
1038+
display_options_init_list(&display_opts);
10261039

10271040
setup_auto_pager("config", 1);
10281041

@@ -1453,6 +1466,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
14531466

14541467
if (actions == ACTION_LIST) {
14551468
check_argc(argc, 0, 0);
1469+
display_options_init_list(&display_opts);
14561470
if (config_with_options(show_all_config, &display_opts,
14571471
&location_opts.source, the_repository,
14581472
&location_opts.options) < 0) {

0 commit comments

Comments
 (0)