Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2022-05-23 16:48:40 +0300
committerJunio C Hamano <gitster@pobox.com>2022-05-23 21:08:21 +0300
commit9fadb373dd4a670e761776560d3c40f6fcc80360 (patch)
tree8ab4319ce1d7f80eb6bab7012ffd8afa0eeb5479 /cache.h
parentdce241b020cf32c9485c7ef23247f0b003731afa (diff)
sparse-index: introduce partially-sparse indexes
A future change will present a temporary, in-memory mode where the index can both contain sparse directory entries but also not be completely collapsed to the smallest possible sparse directories. This will be necessary for modifying the sparse-checkout definition while using a sparse index. For now, convert the single-bit member 'sparse_index' in 'struct index_state' to be a an 'enum sparse_index_mode' with three modes: * INDEX_EXPANDED (0): No sparse directories exist. This is always the case for repositories that do not use cone-mode sparse-checkout. * INDEX_COLLAPSED: Sparse directories may exist. Files outside the sparse-checkout cone are reduced to sparse directory entries whenever possible. * INDEX_PARTIALLY_SPARSE: Sparse directories may exist. Some file entries outside the sparse-checkout cone may exist. Running convert_to_sparse() may further reduce those files to sparse directory entries. The main reason to store this extra information is to allow convert_to_sparse() to short-circuit when the index is already in INDEX_EXPANDED mode but to actually do the necessary work when in INDEX_PARTIALLY_SPARSE mode. The INDEX_PARTIALLY_SPARSE mode will be used in an upcoming change. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h33
1 files changed, 25 insertions, 8 deletions
diff --git a/cache.h b/cache.h
index 6226f6a8a5..e171ce882a 100644
--- a/cache.h
+++ b/cache.h
@@ -310,6 +310,29 @@ struct untracked_cache;
struct progress;
struct pattern_list;
+enum sparse_index_mode {
+ /*
+ * There are no sparse directories in the index at all.
+ *
+ * Repositories that don't use cone-mode sparse-checkout will
+ * always have their indexes in this mode.
+ */
+ INDEX_EXPANDED = 0,
+
+ /*
+ * The index has already been collapsed to sparse directories
+ * whereever possible.
+ */
+ INDEX_COLLAPSED,
+
+ /*
+ * The sparse directories that exist are outside the
+ * sparse-checkout boundary, but it is possible that some file
+ * entries could collapse to sparse directory entries.
+ */
+ INDEX_PARTIALLY_SPARSE,
+};
+
struct index_state {
struct cache_entry **cache;
unsigned int version;
@@ -323,14 +346,8 @@ struct index_state {
drop_cache_tree : 1,
updated_workdir : 1,
updated_skipworktree : 1,
- fsmonitor_has_run_once : 1,
-
- /*
- * sparse_index == 1 when sparse-directory
- * entries exist. Requires sparse-checkout
- * in cone mode.
- */
- sparse_index : 1;
+ fsmonitor_has_run_once : 1;
+ enum sparse_index_mode sparse_index;
struct hashmap name_hash;
struct hashmap dir_hash;
struct object_id oid;