2 #include "trace2/tr2_cmd_name.h"
4 #define TR2_ENVVAR_PARENT_NAME "GIT_TR2_PARENT_NAME"
6 static struct strbuf tr2cmdname_hierarchy
= STRBUF_INIT
;
8 void tr2_cmd_name_append_hierarchy(const char *name
)
10 const char *parent_name
= getenv(TR2_ENVVAR_PARENT_NAME
);
12 strbuf_reset(&tr2cmdname_hierarchy
);
13 if (parent_name
&& *parent_name
) {
14 strbuf_addstr(&tr2cmdname_hierarchy
, parent_name
);
15 strbuf_addch(&tr2cmdname_hierarchy
, '/');
17 strbuf_addstr(&tr2cmdname_hierarchy
, name
);
19 setenv(TR2_ENVVAR_PARENT_NAME
, tr2cmdname_hierarchy
.buf
, 1);
22 const char *tr2_cmd_name_get_hierarchy(void)
24 return tr2cmdname_hierarchy
.buf
;
27 void tr2_cmd_name_release(void)
29 strbuf_release(&tr2cmdname_hierarchy
);