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

Function get_hook_config_cache

hook.c:453–480  ·  view source on GitHub ↗

* Return the hook config map for `r`, populating it first if needed. * * Out-of-repo calls (r->gitdir == NULL) allocate and return a temporary * cache map; the caller is responsible for freeing it with * hook_cache_clear() + free(). */

Source from the content-addressed store, hash-verified

451 * hook_cache_clear() + free().
452 */
453static struct strmap *get_hook_config_cache(struct repository *r)
454{
455 struct strmap *cache = NULL;
456
457 if (r && r->gitdir) {
458 /*
459 * For in-repo calls, the map is stored in r->hook_config_cache,
460 * so repeated invocations don't parse the configs, so allocate
461 * it just once on the first call.
462 */
463 if (!r->hook_config_cache) {
464 CALLOC_ARRAY(r->hook_config_cache, 1);
465 strmap_init(r->hook_config_cache);
466 build_hook_config_map(r, r->hook_config_cache);
467 }
468 cache = r->hook_config_cache;
469 } else {
470 /*
471 * Out-of-repo calls (no gitdir) allocate and return a temporary
472 * cache which gets freed immediately by the caller.
473 */
474 CALLOC_ARRAY(cache, 1);
475 strmap_init(cache);
476 build_hook_config_map(r, cache);
477 }
478
479 return cache;
480}
481
482static void list_hooks_add_configured(struct repository *r,
483 const char *hookname,

Callers 1

Calls 2

strmap_initFunction · 0.85
build_hook_config_mapFunction · 0.85

Tested by

no test coverage detected