summaryrefslogtreecommitdiff
path: root/repository.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-06-22 18:43:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-24 01:24:34 (GMT)
commit639e30b5b2214c68c042215a279ac1fbb372d73d (patch)
treefeb1abd69119562b7913d7094a8e1911f909c906 /repository.c
parent3b256228a66f8587661481ef3e08259864f3ba2a (diff)
downloadgit-639e30b5b2214c68c042215a279ac1fbb372d73d.zip
git-639e30b5b2214c68c042215a279ac1fbb372d73d.tar.gz
git-639e30b5b2214c68c042215a279ac1fbb372d73d.tar.bz2
repository: add index_state to struct repo
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repository.c')
-rw-r--r--repository.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/repository.c b/repository.c
index 686a964..6f6f4d9 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);
}