Merge branch 'am/trace2-with-valueless-true'

The trace2 code was not prepared to show a configuration variable
that is set to true using the valueless true syntax, which has been
corrected.

* am/trace2-with-valueless-true:
  trace2: prevent segfault on config collection with valueless true
This commit is contained in:
Junio C Hamano
2025-01-29 14:05:10 -08:00
5 changed files with 18 additions and 6 deletions

View File

@@ -493,7 +493,8 @@ static void fn_param_fl(const char *file, int line, const char *param,
event_fmt_prepare(event_name, file, line, NULL, &jw);
jw_object_string(&jw, "scope", scope_name);
jw_object_string(&jw, "param", param);
jw_object_string(&jw, "value", value);
if (value)
jw_object_string(&jw, "value", value);
jw_end(&jw);
tr2_dst_write_line(&tr2dst_event, &jw.json);

View File

@@ -307,8 +307,9 @@ static void fn_param_fl(const char *file, int line, const char *param,
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,
value);
strbuf_addf(&buf_payload, "def_param scope:%s %s", scope_name, param);
if (value)
strbuf_addf(&buf_payload, "=%s", value);
normal_io_write_fl(file, line, &buf_payload);
strbuf_release(&buf_payload);
}

View File

@@ -448,8 +448,9 @@ static void fn_param_fl(const char *file, int line, const char *param,
struct strbuf scope_payload = STRBUF_INIT;
enum config_scope scope = kvi->scope;
const char *scope_name = config_scope_name(scope);
strbuf_addf(&buf_payload, "%s:%s", param, value);
strbuf_addstr(&buf_payload, param);
if (value)
strbuf_addf(&buf_payload, ":%s", value);
strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,