1
0
mirror of https://github.com/git/git.git synced 2025-02-06 10:03:06 +00:00

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
commit c5216a1bc6
5 changed files with 18 additions and 6 deletions

View File

@ -243,6 +243,15 @@ test_expect_success 'bug messages followed by BUG() are written to trace2' '
test_cmp expect actual
'
test_expect_success 'a valueless true configuration variable is handled' '
test_when_finished "rm -f trace2.normal actual expect" &&
echo >expect &&
GIT_TRACE2="$(pwd)/trace2.normal" \
GIT_TRACE2_CONFIG_PARAMS=foo.true \
git -c foo.true config foo.true >actual &&
test_cmp expect actual
'
sane_unset GIT_TRACE2_BRIEF
# Now test without environment variables and get all Trace2 settings

View File

@ -764,7 +764,7 @@ void trace2_def_param_fl(const char *file, int line, const char *param,
if (!trace2_enabled)
return;
redacted = redact_arg(value);
redacted = value ? redact_arg(value) : NULL;
for_each_wanted_builtin (j, tgt_j)
if (tgt_j->pfn_param_fl)

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,