From 3f13877595500bd54ee370167bc868f3c1eee5b7 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 18 Jul 2017 12:05:18 -0700 Subject: repo_read_index: don't discard the index Have 'repo_read_index()' behave more like the other read_index family of functions and don't discard the index if it has already been populated and instead rely on the quick return of read_index_from which has: /* istate->initialized covers both .git/index and .git/sharedindex.xxx */ if (istate->initialized) return istate->cache_nr; Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- repository.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'repository.c') diff --git a/repository.c b/repository.c index edca907404..8e60af1d5f 100644 --- a/repository.c +++ b/repository.c @@ -235,8 +235,6 @@ 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 From ba43964d47ac29eafafd8d475c299c51c8a1ca75 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 18 Jul 2017 12:05:19 -0700 Subject: repository: have the_repository use the_index Have the index state which is stored in 'the_repository' be a pointer to the in-core index 'the_index'. This makes it easier to begin transitioning more parts of the code base to operate on a 'struct repository'. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- repository.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'repository.c') diff --git a/repository.c b/repository.c index 8e60af1d5f..c0e0e0e7e7 100644 --- a/repository.c +++ b/repository.c @@ -4,7 +4,9 @@ #include "submodule-config.h" /* The main repository */ -static struct repository the_repo; +static struct repository the_repo = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0 +}; struct repository *the_repository = &the_repo; static char *git_path_from_env(const char *envvar, const char *git_dir, -- cgit v1.2.1