aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-15 08:42:44 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-15 07:17:55 -0700
commitbfe45f83e7a7815cbaea04f380cd807c18c088ea (patch)
treeca4880d3b0c32cac1b812862af0c2726d585a29f
parent65d197cffc7ad52c61398c2579efa988779cc7ab (diff)
downloadgit-bfe45f83e7a7815cbaea04f380cd807c18c088ea.tar.gz
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/config.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/config.c b/builtin/config.c
index bc80fd293a..aac5f7b976 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -125,7 +125,6 @@ struct config_display_options {
static char *key;
static regex_t *key_regexp;
-static const char *value_pattern;
static regex_t *regexp;
static int use_key_regexp;
static int do_all;
@@ -327,6 +326,7 @@ static int format_config(const struct config_display_options *opts,
struct collect_config_data {
const struct config_display_options *display_opts;
struct strbuf_list *values;
+ const char *value_pattern;
int do_not_match;
};
@@ -341,7 +341,7 @@ static int collect_config(const char *key_, const char *value_,
return 0;
if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))
return 0;
- if (fixed_value && strcmp(value_pattern, (value_?value_:"")))
+ if (fixed_value && strcmp(data->value_pattern, (value_?value_:"")))
return 0;
if (regexp != NULL &&
(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,
}
if (regex_ && (flags & CONFIG_FLAGS_FIXED_VALUE))
- value_pattern = regex_;
+ data.value_pattern = regex_;
else if (regex_) {
if (regex_[0] == '!') {
data.do_not_match = 1;