Skip to content

Commit 65d197c

Browse files
pks-tgitster
authored andcommitted
builtin/config: convert do_not_match to a local variable
The `do_not_match` variable is used by the `format_config()` callback as an indicator whether or not the passed regular expression is negated. 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 8c86981 commit 65d197c

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
@@ -129,7 +129,6 @@ static const char *value_pattern;
129129
static regex_t *regexp;
130130
static int use_key_regexp;
131131
static int do_all;
132-
static int do_not_match;
133132
static int fixed_value;
134133

135134
#define TYPE_BOOL 1
@@ -328,6 +327,7 @@ static int format_config(const struct config_display_options *opts,
328327
struct collect_config_data {
329328
const struct config_display_options *display_opts;
330329
struct strbuf_list *values;
330+
int do_not_match;
331331
};
332332

333333
static int collect_config(const char *key_, const char *value_,
@@ -344,7 +344,7 @@ static int collect_config(const char *key_, const char *value_,
344344
if (fixed_value && strcmp(value_pattern, (value_?value_:"")))
345345
return 0;
346346
if (regexp != NULL &&
347-
(do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0)))
347+
(data->do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0)))
348348
return 0;
349349

350350
ALLOC_GROW(values->items, values->nr + 1, values->alloc);
@@ -401,7 +401,7 @@ static int get_value(const struct config_location_options *opts,
401401
value_pattern = regex_;
402402
else if (regex_) {
403403
if (regex_[0] == '!') {
404-
do_not_match = 1;
404+
data.do_not_match = 1;
405405
regex_++;
406406
}
407407

0 commit comments

Comments
 (0)