summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-10-20 02:17:22 -0700
committerEdward Thomson <ethomson@edwardthomson.com>2018-10-20 14:37:41 +0100
commit820e1e9300d775f642288fa73818ead0dac33905 (patch)
treee348c578811ad88dfd18666db2cecbe2673f15d6
parentb433a22a979ae78c28c8b16f8c3487e2787cb73e (diff)
downloadlibgit2-820e1e9300d775f642288fa73818ead0dac33905.tar.gz
repository: load_config for non-repo configs
Teach `load_config` how to load all the configurations except (optionally) the repository configuration. This allows the new repository codepath to load the global/xdg/system configuration paths so that they can be inspected during repository initialization.
-rw-r--r--src/repository.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/repository.c b/src/repository.c
index 9af067933..490388051 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -944,18 +944,20 @@ static int load_config(
git_buf config_path = GIT_BUF_INIT;
git_config *cfg = NULL;
- assert(repo && out);
+ assert(out);
if ((error = git_config_new(&cfg)) < 0)
return error;
- if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
- error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0);
+ if (repo) {
+ if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
+ error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0);
- if (error && error != GIT_ENOTFOUND)
- goto on_error;
+ if (error && error != GIT_ENOTFOUND)
+ goto on_error;
- git_buf_dispose(&config_path);
+ git_buf_dispose(&config_path);
+ }
if (global_config_path != NULL &&
(error = git_config_add_file_ondisk(