Skip to content

Commit 2d48678

Browse files
committed
repository: don't fail to create config option in inmemory repo
When in an in-memory repository - without a configuration file - do not fail to create a configuration object.
1 parent 9d49a43 commit 2d48678

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/repository.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -943,13 +943,10 @@ static int load_config(
943943
if ((error = git_config_new(&cfg)) < 0)
944944
return error;
945945

946-
error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG);
947-
if (error < 0)
948-
goto on_error;
946+
if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
947+
error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, 0);
949948

950-
if ((error = git_config_add_file_ondisk(
951-
cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0 &&
952-
error != GIT_ENOTFOUND)
949+
if (error && error != GIT_ENOTFOUND)
953950
goto on_error;
954951

955952
git_buf_free(&config_path);

0 commit comments

Comments
 (0)