diff options
Diffstat (limited to 'src/repository.c')
-rw-r--r-- | src/repository.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/repository.c b/src/repository.c index d010d8c08..37d5a49f0 100644 --- a/src/repository.c +++ b/src/repository.c @@ -374,16 +374,22 @@ void git_repository_free(git_repository *repo) free(repo); } -git_index *git_repository_index(git_repository *repo) +int git_repository_index(git_index **index_out, git_repository *repo) { + int error; + + assert(index_out && repo); + if (repo->index == NULL) { - if (git_index_open_inrepo(&repo->index, repo) < GIT_SUCCESS) - return NULL; + error = git_index_open_inrepo(&repo->index, repo); + if (error < GIT_SUCCESS) + return error; - assert(repo->index); + assert(repo->index != NULL); } - return repo->index; + *index_out = repo->index; + return GIT_SUCCESS; } git_odb *git_repository_database(git_repository *repo) |