summaryrefslogtreecommitdiff
path: root/src/config_entries.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-08-10 14:53:09 +0200
committerPatrick Steinhardt <ps@pks.im>2018-09-28 11:14:13 +0200
commit60ebc137bc38a5cff67cf86023447111b96f7d4d (patch)
tree0fa1c8bcfa25c9a815a39fa07a75592a7e2a8bbc /src/config_entries.h
parentfb8a87da5a459af8d7b8723a8f16fa6b51c5c2c9 (diff)
downloadlibgit2-60ebc137bc38a5cff67cf86023447111b96f7d4d.tar.gz
config_entries: abstract away retrieval of config entries
The code accessing config entries in the `git_config_entries` structure is still much too intimate with implementation details, directly accessing the maps and handling indices. Provide two new functions to get config entries from the internal map structure to decouple the interfaces and use them in the config file code. The function `git_config_entries_get` will simply look up the entry by name and, in the case of a multi-value, return the last occurrence of that entry. The second function, `git_config_entries_get_unique`, will only return an entry if it is unique and not included via another configuration file. This one is required to properly implement write operations for single entries, as we refuse to write to or delete a single entry if it is not clear which one was meant.
Diffstat (limited to 'src/config_entries.h')
-rw-r--r--src/config_entries.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/config_entries.h b/src/config_entries.h
index d74e17231..555f9bec5 100644
--- a/src/config_entries.h
+++ b/src/config_entries.h
@@ -31,6 +31,8 @@ int git_config_entries_new(git_config_entries **out);
void git_config_entries_free(git_config_entries *entries);
/* Add or append the new config option */
int git_config_entries_append(git_config_entries *entries, git_config_entry *entry);
+int git_config_entries_get(git_config_entry **out, git_config_entries *entries, const char *key);
+int git_config_entries_get_unique(git_config_entry **out, git_config_entries *entries, const char *key);
void config_iterator_free(git_config_iterator* iter);
int config_iterator_next(git_config_entry **entry,