aboutsummaryrefslogtreecommitdiff
path: root/repository.c
diff options
context:
space:
mode:
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 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);
}