Skip to content

Commit 520cf66

Browse files
jeffhostetlergitster
authored andcommitted
trace2: avoid emitting 'def_param' set more than once
During nested alias expansion it is possible for "trace2_cmd_list_config()" and "trace2_cmd_list_env_vars()" to be called more than once. This causes a full set of 'def_param' events to be emitted each time. Let's avoid that. Add code to those two functions to only emit them once. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c1c3c8 commit 520cf66

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

t/t0211-trace2-perf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ test_expect_success 'expect def_params during shell alias expansion' '
470470
grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual
471471
'
472472

473-
test_expect_failure 'expect def_params during nested git alias expansion' '
473+
test_expect_success 'expect def_params during nested git alias expansion' '
474474
test_when_finished "rm prop.perf actual" &&
475475
476476
test_config_global "trace2.configParams" "cfg.prop.*" &&

trace2.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,17 +464,29 @@ void trace2_cmd_alias_fl(const char *file, int line, const char *alias,
464464

465465
void trace2_cmd_list_config_fl(const char *file, int line)
466466
{
467+
static int emitted = 0;
468+
467469
if (!trace2_enabled)
468470
return;
469471

472+
if (emitted)
473+
return;
474+
emitted = 1;
475+
470476
tr2_cfg_list_config_fl(file, line);
471477
}
472478

473479
void trace2_cmd_list_env_vars_fl(const char *file, int line)
474480
{
481+
static int emitted = 0;
482+
475483
if (!trace2_enabled)
476484
return;
477485

486+
if (emitted)
487+
return;
488+
emitted = 1;
489+
478490
tr2_list_env_vars_fl(file, line);
479491
}
480492

0 commit comments

Comments
 (0)