Skip to content

Commit 8967b38

Browse files
committed
trace2: move 'def_param' events into 'cmd_name' and 'cmd_alias'
Some Git commands do not emit `def_param` events for interesting config and environment variable settings. Let's fix that. Builtin commands compiled into `git.c` have the normal control flow and emit a `cmd_name` event and then `def_param` events for each interesting config and environment variable. However, some special "query" commands, like `--exec-path`, or some forms of alias expansion, emitted a `cmd_name` but did not emit `def_param` events. Also, special commands `git-remote-https` is built from `remote-curl.c` and `git-http-fetch` is built from `http-fetch.c` and do not use the normal set up in `git.c`. These emitted a `cmd_name` but not `def_param` events. To minimize the footprint of this commit, move the calls to `trace2_cmd_list_config()` and `trace2_cmd_list_env_vars()` into `trace2_cmd_name()` and `trace2_cmd_alias()` so that we always get a set `def_param` events when a `cmd_name` or `cmd_alias` event is generated. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 0f9d4d2 commit 8967b38

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

git.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,6 @@ static int handle_alias(int *argcp, const char ***argv)
373373
strvec_pushv(&child.args, (*argv) + 1);
374374

375375
trace2_cmd_alias(alias_command, child.args.v);
376-
trace2_cmd_list_config();
377-
trace2_cmd_list_env_vars();
378376
trace2_cmd_name("_run_shell_alias_");
379377

380378
ret = run_command(&child);
@@ -411,8 +409,6 @@ static int handle_alias(int *argcp, const char ***argv)
411409
COPY_ARRAY(new_argv + count, *argv + 1, *argcp);
412410

413411
trace2_cmd_alias(alias_command, new_argv);
414-
trace2_cmd_list_config();
415-
trace2_cmd_list_env_vars();
416412

417413
*argv = new_argv;
418414
*argcp += count - 1;
@@ -462,8 +458,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
462458

463459
trace_argv_printf(argv, "trace: built-in: git");
464460
trace2_cmd_name(p->cmd);
465-
trace2_cmd_list_config();
466-
trace2_cmd_list_env_vars();
467461

468462
validate_cache_entries(the_repository->index);
469463
status = p->fn(argc, argv, prefix);

t/helper/test-tool.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ int cmd_main(int argc, const char **argv)
130130
argv++;
131131
argc--;
132132
trace2_cmd_name(cmds[i].name);
133-
trace2_cmd_list_config();
134-
trace2_cmd_list_env_vars();
135133
return cmds[i].fn(argc, argv);
136134
}
137135
}

trace2.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ void trace2_cmd_name_fl(const char *file, int line, const char *name)
433433
for_each_wanted_builtin (j, tgt_j)
434434
if (tgt_j->pfn_command_name_fl)
435435
tgt_j->pfn_command_name_fl(file, line, name, hierarchy);
436+
437+
trace2_cmd_list_config();
438+
trace2_cmd_list_env_vars();
436439
}
437440

438441
void trace2_cmd_mode_fl(const char *file, int line, const char *mode)
@@ -460,21 +463,36 @@ void trace2_cmd_alias_fl(const char *file, int line, const char *alias,
460463
for_each_wanted_builtin (j, tgt_j)
461464
if (tgt_j->pfn_alias_fl)
462465
tgt_j->pfn_alias_fl(file, line, alias, argv);
466+
467+
trace2_cmd_list_config();
468+
trace2_cmd_list_env_vars();
463469
}
464470

465471
void trace2_cmd_list_config_fl(const char *file, int line)
466472
{
473+
static int printed = 0;
474+
467475
if (!trace2_enabled)
468476
return;
469477

478+
if (printed)
479+
return;
480+
printed = 1;
481+
470482
tr2_cfg_list_config_fl(file, line);
471483
}
472484

473485
void trace2_cmd_list_env_vars_fl(const char *file, int line)
474486
{
487+
static int printed = 0;
488+
475489
if (!trace2_enabled)
476490
return;
477491

492+
if (printed)
493+
return;
494+
printed = 1;
495+
478496
tr2_list_env_vars_fl(file, line);
479497
}
480498

0 commit comments

Comments
 (0)