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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 15, 2024 at 08:42 UTC
8c86981228912e06b6da1fd76076b306fb27d2b5
1 file changed
+12
-7
builtin/config.c
+12
-7
@@ -79,8 +79,11 @@ struct config_location_options {
79
int use_system_config;
80
int use_local_config;
81
int use_worktree_config;
82
+ int respect_includes_opt;
83
};
83
-#define CONFIG_LOCATION_OPTIONS_INIT {0}
84
+#define CONFIG_LOCATION_OPTIONS_INIT { \
85
+ .respect_includes_opt = -1, \
86
+}
87
88
#define CONFIG_TYPE_OPTIONS(type) \
89
OPT_GROUP(N_("Type")), \
@@ -127,7 +130,6 @@ static regex_t *regexp;
130
static int use_key_regexp;
131
static int do_all;
132
static int do_not_match;
130
-static int respect_includes_opt = -1;
133
static int fixed_value;
134
135
#define TYPE_BOOL 1
@@ -776,10 +778,10 @@ static void location_options_init(struct config_location_options *opts,
778
opts->source.scope = CONFIG_SCOPE_COMMAND;
779
}
780
779
- if (respect_includes_opt == -1)
781
+ if (opts->respect_includes_opt == -1)
782
opts->options.respect_includes = !opts->source.file;
783
else
782
- opts->options.respect_includes = respect_includes_opt;
784
+ opts->options.respect_includes = opts->respect_includes_opt;
785
if (startup_info->have_repository) {
786
opts->options.commondir = get_git_common_dir();
787
opts->options.git_dir = get_git_dir();
@@ -808,7 +810,8 @@ static int cmd_config_list(int argc, const char **argv, const char *prefix)
810
CONFIG_LOCATION_OPTIONS(location_opts),
811
CONFIG_DISPLAY_OPTIONS(display_opts),
812
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")),
815
OPT_END(),
816
};
817
@@ -850,7 +853,8 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
853
OPT_STRING(0, "url", &url, N_("URL"), N_("show config matching the given URL")),
854
CONFIG_DISPLAY_OPTIONS(display_opts),
855
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")),
858
OPT_STRING(0, "default", &display_opts.default_value,
859
N_("value"), N_("use default value when missing entry")),
860
OPT_END(),
@@ -1133,7 +1137,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1137
N_("value"), N_("with --get, use default value when missing entry")),
1138
OPT_STRING(0, "comment", &comment_arg, N_("value"), N_("human-readable comment string (# will be prepended as needed)")),
1139
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")),
1142
OPT_END(),
1143
};
1144
char *value = NULL, *comment = NULL;