Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/trace2
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-07-06 21:54:48 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-06 21:54:48 +0300
commitb3d1c85d4833aef546f11e4d37516a1ececaefc3 (patch)
treeb5e799c3279f98f5172ce18cfd0e9b317e9822dd /trace2
parent1d76e69212102c3373b552186590b76d6ad8d84c (diff)
parent6e8e7981eb86e2c19401825dbdb55d5860d11313 (diff)
Merge branch 'gc/config-context'
Reduce reliance on a global state in the config reading API. * gc/config-context: config: pass source to config_parser_event_fn_t config: add kvi.path, use it to evaluate includes config.c: remove config_reader from configsets config: pass kvi to die_bad_number() trace2: plumb config kvi config.c: pass ctx with CLI config config: pass ctx with config files config.c: pass ctx in configsets config: add ctx arg to config_fn_t urlmatch.h: use config_fn_t type config: inline git_color_default_config
Diffstat (limited to 'trace2')
-rw-r--r--trace2/tr2_cfg.c16
-rw-r--r--trace2/tr2_sysenv.c3
-rw-r--r--trace2/tr2_tgt.h4
-rw-r--r--trace2/tr2_tgt_event.c4
-rw-r--r--trace2/tr2_tgt_normal.c4
-rw-r--r--trace2/tr2_tgt_perf.c4
6 files changed, 23 insertions, 12 deletions
diff --git a/trace2/tr2_cfg.c b/trace2/tr2_cfg.c
index db817a80c5..d96d908bb9 100644
--- a/trace2/tr2_cfg.c
+++ b/trace2/tr2_cfg.c
@@ -100,7 +100,8 @@ struct tr2_cfg_data {
/*
* See if the given config key matches any of our patterns of interest.
*/
-static int tr2_cfg_cb(const char *key, const char *value, void *d)
+static int tr2_cfg_cb(const char *key, const char *value,
+ const struct config_context *ctx, void *d)
{
struct strbuf **s;
struct tr2_cfg_data *data = (struct tr2_cfg_data *)d;
@@ -109,7 +110,8 @@ static int tr2_cfg_cb(const char *key, const char *value, void *d)
struct strbuf *buf = *s;
int wm = wildmatch(buf->buf, key, WM_CASEFOLD);
if (wm == WM_MATCH) {
- trace2_def_param_fl(data->file, data->line, key, value);
+ trace2_def_param_fl(data->file, data->line, key, value,
+ ctx->kvi);
return 0;
}
}
@@ -127,8 +129,10 @@ void tr2_cfg_list_config_fl(const char *file, int line)
void tr2_list_env_vars_fl(const char *file, int line)
{
+ struct key_value_info kvi = KVI_INIT;
struct strbuf **s;
+ kvi_from_param(&kvi);
if (tr2_load_env_vars() <= 0)
return;
@@ -136,15 +140,19 @@ void tr2_list_env_vars_fl(const char *file, int line)
struct strbuf *buf = *s;
const char *val = getenv(buf->buf);
if (val && *val)
- trace2_def_param_fl(file, line, buf->buf, val);
+ trace2_def_param_fl(file, line, buf->buf, val, &kvi);
}
}
void tr2_cfg_set_fl(const char *file, int line, const char *key,
const char *value)
{
+ struct key_value_info kvi = KVI_INIT;
+ struct config_context ctx = {
+ .kvi = &kvi,
+ };
struct tr2_cfg_data data = { file, line };
if (tr2_cfg_load_patterns() > 0)
- tr2_cfg_cb(key, value, &data);
+ tr2_cfg_cb(key, value, &ctx, &data);
}
diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c
index 069786cb92..f26ec95ab4 100644
--- a/trace2/tr2_sysenv.c
+++ b/trace2/tr2_sysenv.c
@@ -57,7 +57,8 @@ static struct tr2_sysenv_entry tr2_sysenv_settings[] = {
};
/* clang-format on */
-static int tr2_sysenv_cb(const char *key, const char *value, void *d)
+static int tr2_sysenv_cb(const char *key, const char *value,
+ const struct config_context *ctx UNUSED, void *d)
{
int k;
diff --git a/trace2/tr2_tgt.h b/trace2/tr2_tgt.h
index bf8745c4f0..1f626cffea 100644
--- a/trace2/tr2_tgt.h
+++ b/trace2/tr2_tgt.h
@@ -69,8 +69,10 @@ typedef void(tr2_tgt_evt_exec_result_fl_t)(const char *file, int line,
uint64_t us_elapsed_absolute,
int exec_id, int code);
+struct key_value_info;
typedef void(tr2_tgt_evt_param_fl_t)(const char *file, int line,
- const char *param, const char *value);
+ const char *param, const char *value,
+ const struct key_value_info *kvi);
typedef void(tr2_tgt_evt_repo_fl_t)(const char *file, int line,
const struct repository *repo);
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 2af53e5d4d..53091781ec 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -477,11 +477,11 @@ static void fn_exec_result_fl(const char *file, int line,
}
static void fn_param_fl(const char *file, int line, const char *param,
- const char *value)
+ const char *value, const struct key_value_info *kvi)
{
const char *event_name = "def_param";
struct json_writer jw = JSON_WRITER_INIT;
- enum config_scope scope = current_config_scope();
+ enum config_scope scope = kvi->scope;
const char *scope_name = config_scope_name(scope);
jw_object_begin(&jw, 0);
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index 1ebfb464d5..d25ea13164 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -297,10 +297,10 @@ static void fn_exec_result_fl(const char *file, int line,
}
static void fn_param_fl(const char *file, int line, const char *param,
- const char *value)
+ const char *value, const struct key_value_info *kvi)
{
struct strbuf buf_payload = STRBUF_INIT;
- enum config_scope scope = current_config_scope();
+ enum config_scope scope = kvi->scope;
const char *scope_name = config_scope_name(scope);
strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param,
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index 328e483a05..a6f9a8a193 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -439,12 +439,12 @@ static void fn_exec_result_fl(const char *file, int line,
}
static void fn_param_fl(const char *file, int line, const char *param,
- const char *value)
+ const char *value, const struct key_value_info *kvi)
{
const char *event_name = "def_param";
struct strbuf buf_payload = STRBUF_INIT;
struct strbuf scope_payload = STRBUF_INIT;
- enum config_scope scope = current_config_scope();
+ enum config_scope scope = kvi->scope;
const char *scope_name = config_scope_name(scope);
strbuf_addf(&buf_payload, "%s:%s", param, value);