MCPcopy Index your code
hub / github.com/git/git / get_git_namespace

Function get_git_namespace

environment.c:143–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143const char *get_git_namespace(void)
144{
145 static const char *namespace;
146 struct strbuf buf = STRBUF_INIT;
147 const char *raw_namespace;
148 struct string_list components = STRING_LIST_INIT_DUP;
149 struct string_list_item *item;
150
151 if (namespace)
152 return namespace;
153
154 raw_namespace = getenv(GIT_NAMESPACE_ENVIRONMENT);
155 if (!raw_namespace || !*raw_namespace) {
156 namespace = "";
157 return namespace;
158 }
159
160 strbuf_addstr(&buf, raw_namespace);
161
162 string_list_split(&components, buf.buf, "/", -1);
163 strbuf_reset(&buf);
164
165 for_each_string_list_item(item, &components) {
166 if (item->string[0])
167 strbuf_addf(&buf, "refs/namespaces/%s/", item->string);
168 }
169 string_list_clear(&components, 0);
170
171 strbuf_trim_trailing_dir_sep(&buf);
172 if (check_refname_format(buf.buf, 0))
173 die(_("bad git namespace path \"%s\""), raw_namespace);
174 strbuf_addch(&buf, '/');
175
176 namespace = strbuf_detach(&buf, NULL);
177
178 return namespace;
179}
180
181const char *strip_namespace(const char *namespaced_ref)
182{

Callers 11

parse_want_refFunction · 0.85
strip_namespaceFunction · 0.85
refs_head_ref_namespacedFunction · 0.85
get_info_refsFunction · 0.85
ls_refsFunction · 0.85
write_head_infoFunction · 0.85
updateFunction · 0.85
check_aliased_updateFunction · 0.85
reject_updates_to_hiddenFunction · 0.85

Calls 9

strbuf_addstrFunction · 0.85
string_list_splitFunction · 0.85
strbuf_addfFunction · 0.85
string_list_clearFunction · 0.85
check_refname_formatFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_detachFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected