diff options
author | Vicent Martà <vicent@github.com> | 2012-08-23 14:10:47 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2012-08-23 14:10:47 -0700 |
commit | c920e162325d0f9acba46a19c4619e6bfa17707e (patch) | |
tree | bb1d939d73ce2c2bd9d3001c643bcf28602a8271 /src/config.c | |
parent | 5fdc41e76591aebdbae3b49440bc2c8b2430718c (diff) | |
parent | e9ca852e4d77e1b1723a2dceddfa2037677e2fb4 (diff) | |
download | libgit2-c920e162325d0f9acba46a19c4619e6bfa17707e.tar.gz |
Merge pull request #844 from arrbee/init-extended
Add git_repository_init_ext for power initters
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/config.c b/src/config.c index 44cfe760c..277daaafe 100644 --- a/src/config.c +++ b/src/config.c @@ -501,17 +501,28 @@ int git_config_find_system(char *system_config_path, size_t length) return 0; } -int git_config_open_global(git_config **out) +int git_config_open_default(git_config **out) { int error; - git_buf path = GIT_BUF_INIT; + git_config *cfg = NULL; + git_buf buf = GIT_BUF_INIT; - if ((error = git_config_find_global_r(&path)) < 0) - return error; + error = git_config_new(&cfg); - error = git_config_open_ondisk(out, git_buf_cstr(&path)); - git_buf_free(&path); + if (!error && !git_config_find_global_r(&buf)) + error = git_config_add_file_ondisk(cfg, buf.ptr, 2); + + if (!error && !git_config_find_system_r(&buf)) + error = git_config_add_file_ondisk(cfg, buf.ptr, 1); + + git_buf_free(&buf); + + if (error && cfg) { + git_config_free(cfg); + cfg = NULL; + } + + *out = cfg; return error; } - |