diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-09 11:22:27 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-22 17:02:56 +0200 |
| commit | 15c381031391cbc24691f9bd009b991eaa440d25 (patch) | |
| tree | 9ed6bd70063a087ae3daa28deef0933343fa4b9c /src/config.c | |
| parent | 7d6dacdc17303305748fed226af35d8a4e5abc77 (diff) | |
| download | libgit2-15c381031391cbc24691f9bd009b991eaa440d25.tar.gz | |
config: provide a function to reverse-lookup mapped cvars
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index 1400b9513..77cf573e6 100644 --- a/src/config.c +++ b/src/config.c @@ -1194,6 +1194,26 @@ fail_parse: return -1; } +int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, + const git_cvar_map *maps, size_t map_n, int enum_val) +{ + size_t i; + + for (i = 0; i < map_n; i++) { + const git_cvar_map *m = &maps[i]; + + if (m->map_value != enum_val) + continue; + + *type_out = m->cvar_type; + *str_out = m->str_match; + return 0; + } + + giterr_set(GITERR_CONFIG, "invalid enum value"); + return GIT_ENOTFOUND; +} + int git_config_parse_bool(int *out, const char *value) { if (git__parse_bool(out, value) == 0) |
