sparse-index: add index.sparse config option
When enabled, this config option signals that index writes should attempt to use sparse-directory entries. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0938e6ff55
commit
58300f4743
@ -14,6 +14,11 @@ index.recordOffsetTable::
|
|||||||
Defaults to 'true' if index.threads has been explicitly enabled,
|
Defaults to 'true' if index.threads has been explicitly enabled,
|
||||||
'false' otherwise.
|
'false' otherwise.
|
||||||
|
|
||||||
|
index.sparse::
|
||||||
|
When enabled, write the index using sparse-directory entries. This
|
||||||
|
has no effect unless `core.sparseCheckout` and
|
||||||
|
`core.sparseCheckoutCone` are both enabled. Defaults to 'false'.
|
||||||
|
|
||||||
index.threads::
|
index.threads::
|
||||||
Specifies the number of threads to spawn when loading the index.
|
Specifies the number of threads to spawn when loading the index.
|
||||||
This is meant to reduce index load time on multiprocessor machines.
|
This is meant to reduce index load time on multiprocessor machines.
|
||||||
|
1
cache.h
1
cache.h
@ -1059,6 +1059,7 @@ struct repository_format {
|
|||||||
int worktree_config;
|
int worktree_config;
|
||||||
int is_bare;
|
int is_bare;
|
||||||
int hash_algo;
|
int hash_algo;
|
||||||
|
int sparse_index;
|
||||||
char *work_tree;
|
char *work_tree;
|
||||||
struct string_list unknown_extensions;
|
struct string_list unknown_extensions;
|
||||||
struct string_list v1_only_extensions;
|
struct string_list v1_only_extensions;
|
||||||
|
@ -85,4 +85,11 @@ void prepare_repo_settings(struct repository *r)
|
|||||||
* removed.
|
* removed.
|
||||||
*/
|
*/
|
||||||
r->settings.command_requires_full_index = 1;
|
r->settings.command_requires_full_index = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize this as off.
|
||||||
|
*/
|
||||||
|
r->settings.sparse_index = 0;
|
||||||
|
if (!repo_config_get_bool(r, "index.sparse", &value) && value)
|
||||||
|
r->settings.sparse_index = 1;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,8 @@ struct repo_settings {
|
|||||||
|
|
||||||
int core_multi_pack_index;
|
int core_multi_pack_index;
|
||||||
|
|
||||||
unsigned command_requires_full_index:1;
|
unsigned command_requires_full_index:1,
|
||||||
|
sparse_index:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct repository {
|
struct repository {
|
||||||
|
@ -102,19 +102,43 @@ static int convert_to_sparse_rec(struct index_state *istate,
|
|||||||
return num_converted - start_converted;
|
return num_converted - start_converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int enable_sparse_index(struct repository *repo)
|
||||||
|
{
|
||||||
|
const char *config_path = repo_git_path(repo, "config.worktree");
|
||||||
|
|
||||||
|
git_config_set_in_file_gently(config_path,
|
||||||
|
"index.sparse",
|
||||||
|
"true");
|
||||||
|
|
||||||
|
prepare_repo_settings(repo);
|
||||||
|
repo->settings.sparse_index = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int convert_to_sparse(struct index_state *istate)
|
int convert_to_sparse(struct index_state *istate)
|
||||||
{
|
{
|
||||||
if (istate->split_index || istate->sparse_index ||
|
if (istate->split_index || istate->sparse_index ||
|
||||||
!core_apply_sparse_checkout || !core_sparse_checkout_cone)
|
!core_apply_sparse_checkout || !core_sparse_checkout_cone)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!istate->repo)
|
||||||
|
istate->repo = the_repository;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For now, only create a sparse index with the
|
* The GIT_TEST_SPARSE_INDEX environment variable triggers the
|
||||||
* GIT_TEST_SPARSE_INDEX environment variable. We will relax
|
* index.sparse config variable to be on.
|
||||||
* this once we have a proper way to opt-in (and later still,
|
|
||||||
* opt-out).
|
|
||||||
*/
|
*/
|
||||||
if (!git_env_bool("GIT_TEST_SPARSE_INDEX", 0))
|
if (git_env_bool("GIT_TEST_SPARSE_INDEX", 0)) {
|
||||||
|
int err = enable_sparse_index(istate->repo);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only convert to sparse if index.sparse is set.
|
||||||
|
*/
|
||||||
|
prepare_repo_settings(istate->repo);
|
||||||
|
if (!istate->repo->settings.sparse_index)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!istate->sparse_checkout_patterns) {
|
if (!istate->sparse_checkout_patterns) {
|
||||||
|
Loading…
Reference in New Issue
Block a user