Skip to content

Commit 8c86981

Browse files
pks-tgitster
authored andcommitted
builtin/config: move respect_includes_opt into location options
The variable tracking whether or not we want to honor includes is tracked via a global variable. Move it into the location options instead. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4090a9c commit 8c86981

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

builtin/config.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ struct config_location_options {
7979
int use_system_config;
8080
int use_local_config;
8181
int use_worktree_config;
82+
int respect_includes_opt;
8283
};
83-
#define CONFIG_LOCATION_OPTIONS_INIT {0}
84+
#define CONFIG_LOCATION_OPTIONS_INIT { \
85+
.respect_includes_opt = -1, \
86+
}
8487

8588
#define CONFIG_TYPE_OPTIONS(type) \
8689
OPT_GROUP(N_("Type")), \
@@ -127,7 +130,6 @@ static regex_t *regexp;
127130
static int use_key_regexp;
128131
static int do_all;
129132
static int do_not_match;
130-
static int respect_includes_opt = -1;
131133
static int fixed_value;
132134

133135
#define TYPE_BOOL 1
@@ -776,10 +778,10 @@ static void location_options_init(struct config_location_options *opts,
776778
opts->source.scope = CONFIG_SCOPE_COMMAND;
777779
}
778780

779-
if (respect_includes_opt == -1)
781+
if (opts->respect_includes_opt == -1)
780782
opts->options.respect_includes = !opts->source.file;
781783
else
782-
opts->options.respect_includes = respect_includes_opt;
784+
opts->options.respect_includes = opts->respect_includes_opt;
783785
if (startup_info->have_repository) {
784786
opts->options.commondir = get_git_common_dir();
785787
opts->options.git_dir = get_git_dir();
@@ -808,7 +810,8 @@ static int cmd_config_list(int argc, const char **argv, const char *prefix)
808810
CONFIG_LOCATION_OPTIONS(location_opts),
809811
CONFIG_DISPLAY_OPTIONS(display_opts),
810812
OPT_GROUP(N_("Other")),
811-
OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
813+
OPT_BOOL(0, "includes", &location_opts.respect_includes_opt,
814+
N_("respect include directives on lookup")),
812815
OPT_END(),
813816
};
814817

@@ -850,7 +853,8 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
850853
OPT_STRING(0, "url", &url, N_("URL"), N_("show config matching the given URL")),
851854
CONFIG_DISPLAY_OPTIONS(display_opts),
852855
OPT_GROUP(N_("Other")),
853-
OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
856+
OPT_BOOL(0, "includes", &location_opts.respect_includes_opt,
857+
N_("respect include directives on lookup")),
854858
OPT_STRING(0, "default", &display_opts.default_value,
855859
N_("value"), N_("use default value when missing entry")),
856860
OPT_END(),
@@ -1133,7 +1137,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
11331137
N_("value"), N_("with --get, use default value when missing entry")),
11341138
OPT_STRING(0, "comment", &comment_arg, N_("value"), N_("human-readable comment string (# will be prepended as needed)")),
11351139
OPT_BOOL(0, "fixed-value", &fixed_value, N_("use string equality when comparing values to 'value-pattern'")),
1136-
OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
1140+
OPT_BOOL(0, "includes", &location_opts.respect_includes_opt,
1141+
N_("respect include directives on lookup")),
11371142
OPT_END(),
11381143
};
11391144
char *value = NULL, *comment = NULL;

0 commit comments

Comments
 (0)