Skip to content

Commit bfe45f8

Browse files
pks-tgitster
authored andcommitted
builtin/config: convert value_pattern to a local variable
The `value_pattern` variable is used by the `format_config()` callback when `CONFIG_FLAGS_FIXED_VALUE` is used. It is only ever set up by its only caller, `collect_config()` and can thus easily be moved into the `collect_config_data` structure. Do so to remove our reliance on global state. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65d197c commit bfe45f8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ struct config_display_options {
125125

126126
static char *key;
127127
static regex_t *key_regexp;
128-
static const char *value_pattern;
129128
static regex_t *regexp;
130129
static int use_key_regexp;
131130
static int do_all;
@@ -327,6 +326,7 @@ static int format_config(const struct config_display_options *opts,
327326
struct collect_config_data {
328327
const struct config_display_options *display_opts;
329328
struct strbuf_list *values;
329+
const char *value_pattern;
330330
int do_not_match;
331331
};
332332

@@ -341,7 +341,7 @@ static int collect_config(const char *key_, const char *value_,
341341
return 0;
342342
if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))
343343
return 0;
344-
if (fixed_value && strcmp(value_pattern, (value_?value_:"")))
344+
if (fixed_value && strcmp(data->value_pattern, (value_?value_:"")))
345345
return 0;
346346
if (regexp != NULL &&
347347
(data->do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0)))
@@ -398,7 +398,7 @@ static int get_value(const struct config_location_options *opts,
398398
}
399399

400400
if (regex_ && (flags & CONFIG_FLAGS_FIXED_VALUE))
401-
value_pattern = regex_;
401+
data.value_pattern = regex_;
402402
else if (regex_) {
403403
if (regex_[0] == '!') {
404404
data.do_not_match = 1;

0 commit comments

Comments
 (0)