diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2017-06-12 12:02:27 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2017-06-12 12:02:27 +0100 |
commit | 78a039b0974b2ff5849a426a66d96cb3f9ee5b7c (patch) | |
tree | 7f5767fee2133afdb4346c22296e8f9c88d601bf | |
parent | 3ff9a4e468a687206478cd1b1d5857ccfecc2434 (diff) | |
download | libgit2-ethomson/config_for_innemory_Repo.tar.gz |
repository: don't fail to create config option in inmemory repoethomson/config_for_innemory_Repo
When in an in-memory repository - without a configuration file - do not
fail to create a configuration object.
-rw-r--r-- | src/repository.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/repository.c b/src/repository.c index 27553ad0a..1944e3633 100644 --- a/src/repository.c +++ b/src/repository.c @@ -943,16 +943,15 @@ static int load_config( if ((error = git_config_new(&cfg)) < 0) return error; - error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG); - if (error < 0) - goto on_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, 0); - if ((error = git_config_add_file_ondisk( - cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0 && - error != GIT_ENOTFOUND) + if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } else if (error < 0) { goto on_error; - - git_buf_free(&config_path); + } if (global_config_path != NULL && (error = git_config_add_file_ondisk( |