MCPcopy Create free account
hub / github.com/git/git / git_attr_internal

Function git_attr_internal

attr.c:233–256  ·  view source on GitHub ↗

* Given a 'name', lookup and return the corresponding attribute in the global * dictionary. If no entry is found, create a new attribute and store it in * the dictionary. */

Source from the content-addressed store, hash-verified

231 * the dictionary.
232 */
233static const struct git_attr *git_attr_internal(const char *name, size_t namelen)
234{
235 struct git_attr *a;
236
237 if (!attr_name_valid(name, namelen))
238 return NULL;
239
240 hashmap_lock(&g_attr_hashmap);
241
242 a = attr_hashmap_get(&g_attr_hashmap, name, namelen);
243
244 if (!a) {
245 FLEX_ALLOC_MEM(a, name, name, namelen);
246 a->attr_nr = hashmap_get_size(&g_attr_hashmap.map);
247
248 attr_hashmap_add(&g_attr_hashmap, a->name, namelen, a);
249 if (a->attr_nr != hashmap_get_size(&g_attr_hashmap.map) - 1)
250 die(_("unable to add additional attribute"));
251 }
252
253 hashmap_unlock(&g_attr_hashmap);
254
255 return a;
256}
257
258const struct git_attr *git_attr(const char *name)
259{

Callers 3

git_attrFunction · 0.85
parse_attrFunction · 0.85
parse_attr_lineFunction · 0.85

Calls 7

attr_name_validFunction · 0.85
hashmap_lockFunction · 0.85
attr_hashmap_getFunction · 0.85
hashmap_get_sizeFunction · 0.85
attr_hashmap_addFunction · 0.85
hashmap_unlockFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected