diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-06-16 20:06:36 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-06-17 22:30:30 +0200 |
| commit | f3dad3acd75651099c0502e7586ef5a44c22684f (patch) | |
| tree | 7d003391ebfe49eabe3dfad28f24830446c09e29 /src/config.c | |
| parent | 3de5df7d8e0e35653d49fb6484a4f0cf98af6c88 (diff) | |
| download | libgit2-f3dad3acd75651099c0502e7586ef5a44c22684f.tar.gz | |
Add fall-back support to the configuration
If a config has several files, we need to check all of them before we
can say that a variable doesn't exist.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/config.c b/src/config.c index 29b9b799f..39a236ad9 100644 --- a/src/config.c +++ b/src/config.c @@ -310,13 +310,19 @@ int git_config_get_string(git_config *cfg, const char *name, const char **out) { file_internal *internal; git_config_file *file; + int i, error; if (cfg->files.length == 0) return git__throw(GIT_EINVALIDARGS, "Cannot get variable value; no files open in the `git_config` instance"); - internal = git_vector_get(&cfg->files, 0); - file = internal->file; + for (i = 0; i < cfg->files.length; ++i) { + internal = git_vector_get(&cfg->files, i); + file = internal->file; + error = file->get(file, name, out); + if (error == GIT_SUCCESS) + break; + } - return file->get(file, name, out); + return error; } |
