Skip to content

Commit 820e1e9

Browse files
committed
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.
1 parent b433a22 commit 820e1e9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/repository.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,18 +944,20 @@ static int load_config(
944944
git_buf config_path = GIT_BUF_INIT;
945945
git_config *cfg = NULL;
946946

947-
assert(repo && out);
947+
assert(out);
948948

949949
if ((error = git_config_new(&cfg)) < 0)
950950
return error;
951951

952-
if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
953-
error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0);
952+
if (repo) {
953+
if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
954+
error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0);
954955

955-
if (error && error != GIT_ENOTFOUND)
956-
goto on_error;
956+
if (error && error != GIT_ENOTFOUND)
957+
goto on_error;
957958

958-
git_buf_dispose(&config_path);
959+
git_buf_dispose(&config_path);
960+
}
959961

960962
if (global_config_path != NULL &&
961963
(error = git_config_add_file_ondisk(

0 commit comments

Comments
 (0)