| 1741 | } |
| 1742 | |
| 1743 | static 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 | |
| 1780 | static int config_set_element_cmp(const void *cmp_data UNUSED, |
| 1781 | const struct hashmap_entry *eptr, |
no test coverage detected