@@ -660,6 +660,17 @@ out_free_ret_1:
return -CONFIG_INVALID_KEY;
}
+static int kvi_fn(config_fn_t fn, const char *key, const char *value,
+ struct key_value_info *kvi,
+ void *data)
+{
+ int ret;
+ config_reader_set_kvi(&the_reader, kvi);
+ ret = fn(key, value, data);
+ config_reader_set_kvi(&the_reader, NULL);
+ return ret;
+}
+
static int config_parse_pair(const char *key, const char *value,
config_fn_t fn, void *data)
{
@@ -2288,27 +2299,24 @@ int config_with_options(config_fn_t fn, void *data,
return ret;
}
-static void configset_iter(struct config_reader *reader, struct config_set *set,
- config_fn_t fn, void *data)
+static void configset_iter(struct config_set *set, config_fn_t fn, void *data)
{
int i, value_index;
struct string_list *values;
struct config_set_element *entry;
struct configset_list *list = &set->list;
+ struct key_value_info *kvi;
for (i = 0; i < list->nr; i++) {
entry = list->items[i].e;
value_index = list->items[i].value_index;
values = &entry->value_list;
+ kvi = values->items[value_index].util;
- config_reader_set_kvi(reader, values->items[value_index].util);
-
- if (fn(entry->key, values->items[value_index].string, data) < 0)
- git_die_config_linenr(entry->key,
- reader->config_kvi->filename,
- reader->config_kvi->linenr);
-
- config_reader_set_kvi(reader, NULL);
+ if (kvi_fn(fn, entry->key, values->items[value_index].string,
+ kvi, data) < 0)
+ git_die_config_linenr(entry->key, kvi->filename,
+ kvi->linenr);
}
}
@@ -2696,7 +2704,7 @@ static void repo_config_clear(struct repository *repo)
void repo_config(struct repository *repo, config_fn_t fn, void *data)
{
git_config_check_init(repo);
- configset_iter(&the_reader, repo->config, fn, data);
+ configset_iter(repo->config, fn, data);
}
int repo_config_get(struct repository *repo, const char *key)
@@ -2815,7 +2823,7 @@ void git_protected_config(config_fn_t fn, void *data)
{
if (!protected_config.hash_initialized)
read_protected_config();
- configset_iter(&the_reader, &protected_config, fn, data);
+ configset_iter(&protected_config, fn, data);
}
/* Functions used historically to read configuration from 'the_repository' */