Coverage Report

Created: 2024-09-08 06:23

/src/git/trace2/tr2_cmd_name.c
Line
Count
Source (jump to first uncovered line)
1
#include "git-compat-util.h"
2
#include "strbuf.h"
3
#include "trace2/tr2_cmd_name.h"
4
5
0
#define TR2_ENVVAR_PARENT_NAME "GIT_TRACE2_PARENT_NAME"
6
7
static struct strbuf tr2cmdname_hierarchy = STRBUF_INIT;
8
9
void tr2_cmd_name_append_hierarchy(const char *name)
10
0
{
11
0
  const char *parent_name = getenv(TR2_ENVVAR_PARENT_NAME);
12
13
0
  strbuf_reset(&tr2cmdname_hierarchy);
14
0
  if (parent_name && *parent_name) {
15
0
    strbuf_addstr(&tr2cmdname_hierarchy, parent_name);
16
0
    strbuf_addch(&tr2cmdname_hierarchy, '/');
17
0
  }
18
0
  strbuf_addstr(&tr2cmdname_hierarchy, name);
19
20
0
  setenv(TR2_ENVVAR_PARENT_NAME, tr2cmdname_hierarchy.buf, 1);
21
0
}
22
23
const char *tr2_cmd_name_get_hierarchy(void)
24
0
{
25
0
  return tr2cmdname_hierarchy.buf;
26
0
}
27
28
void tr2_cmd_name_release(void)
29
0
{
30
0
  strbuf_release(&tr2cmdname_hierarchy);
31
0
}