summaryrefslogtreecommitdiff
path: root/repository.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-03-30 13:10:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-03-30 19:57:45 (GMT)
commit3964fc2aae7c7420a4c5da1b9530e8e8de1ed367 (patch)
tree6b4872a266678c396757fcaa36c89351671a23b9 /repository.c
parent4b3f765a2f38064c0bb221c76c7bb4f28f94a9dc (diff)
downloadgit-3964fc2aae7c7420a4c5da1b9530e8e8de1ed367.zip
git-3964fc2aae7c7420a4c5da1b9530e8e8de1ed367.tar.gz
git-3964fc2aae7c7420a4c5da1b9530e8e8de1ed367.tar.bz2
sparse-index: add guard to ensure full index
Upcoming changes will introduce modifications to the index format that allow sparse directories. It will be useful to have a mechanism for converting those sparse index files into full indexes by walking the tree at those sparse directories. Name this method ensure_full_index() as it will guarantee that the index is fully expanded. This method is not implemented yet, and instead we focus on the scaffolding to declare it and call it at the appropriate time. Add a 'command_requires_full_index' member to struct repo_settings. This will be an indicator that we need the index in full mode to do certain index operations. This starts as being true for every command, then we will set it to false as some commands integrate with sparse indexes. If 'command_requires_full_index' is true, then we will immediately expand a sparse index to a full one upon reading from disk. This suffices for now, but we will want to add more callers to ensure_full_index() later. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repository.c')
-rw-r--r--repository.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/repository.c b/repository.c
index c98298a..a8acae0 100644
--- a/repository.c
+++ b/repository.c
@@ -10,6 +10,7 @@
#include "object.h"
#include "lockfile.h"
#include "submodule-config.h"
+#include "sparse-index.h"
/* The main repository */
static struct repository the_repo;
@@ -261,6 +262,8 @@ void repo_clear(struct repository *repo)
int repo_read_index(struct repository *repo)
{
+ int res;
+
if (!repo->index)
repo->index = xcalloc(1, sizeof(*repo->index));
@@ -270,7 +273,13 @@ int repo_read_index(struct repository *repo)
else if (repo->index->repo != repo)
BUG("repo's index should point back at itself");
- return read_index_from(repo->index, repo->index_file, repo->gitdir);
+ res = read_index_from(repo->index, repo->index_file, repo->gitdir);
+
+ prepare_repo_settings(repo);
+ if (repo->settings.command_requires_full_index)
+ ensure_full_index(repo->index);
+
+ return res;
}
int repo_hold_locked_index(struct repository *repo,