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

Function configset_add_value

config.c:1743–1778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1741}
1742
1743static int configset_add_value(const struct key_value_info *kvi_p,
1744 struct config_set *set, const char *key,
1745 const char *value)
1746{
1747 struct config_set_element *e;
1748 struct string_list_item *si;
1749 struct configset_list_item *l_item;
1750 struct key_value_info *kv_info = xmalloc(sizeof(*kv_info));
1751 int ret;
1752
1753 ret = configset_find_element(set, key, &e);
1754 if (ret)
1755 return ret;
1756 /*
1757 * Since the keys are being fed by git_config*() callback mechanism, they
1758 * are already normalized. So simply add them without any further munging.
1759 */
1760 if (!e) {
1761 e = xmalloc(sizeof(*e));
1762 hashmap_entry_init(&e->ent, strhash(key));
1763 e->key = xstrdup(key);
1764 string_list_init_dup(&e->value_list);
1765 hashmap_add(&set->config_hash, &e->ent);
1766 }
1767 si = string_list_append_nodup(&e->value_list, xstrdup_or_null(value));
1768
1769 ALLOC_GROW(set->list.items, set->list.nr + 1, set->list.alloc);
1770 l_item = &set->list.items[set->list.nr++];
1771 l_item->e = e;
1772 l_item->value_index = e->value_list.nr - 1;
1773
1774 *kv_info = *kvi_p;
1775 si->util = kv_info;
1776
1777 return 0;
1778}
1779
1780static int config_set_element_cmp(const void *cmp_data UNUSED,
1781 const struct hashmap_entry *eptr,

Callers 1

config_set_callbackFunction · 0.85

Calls 9

configset_find_elementFunction · 0.85
hashmap_entry_initFunction · 0.85
strhashFunction · 0.85
xstrdupFunction · 0.85
string_list_init_dupFunction · 0.85
hashmap_addFunction · 0.85
string_list_append_nodupFunction · 0.85
xstrdup_or_nullFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected