1 #include "git-compat-util.h"
3 #include "trace2/tr2_cmd_name.h"
5 #define TR2_ENVVAR_PARENT_NAME "GIT_TRACE2_PARENT_NAME"
7 static struct strbuf tr2cmdname_hierarchy
= STRBUF_INIT
;
9 void tr2_cmd_name_append_hierarchy(const char *name
)
11 const char *parent_name
= getenv(TR2_ENVVAR_PARENT_NAME
);
13 strbuf_reset(&tr2cmdname_hierarchy
);
14 if (parent_name
&& *parent_name
) {
15 strbuf_addstr(&tr2cmdname_hierarchy
, parent_name
);
16 strbuf_addch(&tr2cmdname_hierarchy
, '/');
18 strbuf_addstr(&tr2cmdname_hierarchy
, name
);
20 setenv(TR2_ENVVAR_PARENT_NAME
, tr2cmdname_hierarchy
.buf
, 1);
23 const char *tr2_cmd_name_get_hierarchy(void)
25 return tr2cmdname_hierarchy
.buf
;
28 void tr2_cmd_name_release(void)
30 strbuf_release(&tr2cmdname_hierarchy
);