From 639e30b5b2214c68c042215a279ac1fbb372d73d Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 22 Jun 2017 11:43:43 -0700 Subject: repository: add index_state to struct repo Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- repository.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'repository.c') diff --git a/repository.c b/repository.c index 686a964ad..6f6f4d91e 100644 --- a/repository.c +++ b/repository.c @@ -163,4 +163,20 @@ void repo_clear(struct repository *repo) free(repo->config); repo->config = NULL; } + + if (repo->index) { + discard_index(repo->index); + free(repo->index); + repo->index = NULL; + } +} + +int repo_read_index(struct repository *repo) +{ + if (!repo->index) + repo->index = xcalloc(1, sizeof(*repo->index)); + else + discard_index(repo->index); + + return read_index_from(repo->index, repo->index_file); } -- cgit v1.2.1