From f55843a7b8701546cf35204d01bb5673638acfaf Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 15 Jun 2021 11:07:11 -0400 Subject: [PATCH] repo-settings: enable sparse index by default There is some strangeness when expanding a sparse-index that exists within a submodule. We will need to resolve that later, but for now, let's do a better job of explicitly disabling the sparse-index when requested, and do so in t7817. Signed-off-by: Derrick Stolee --- repo-settings.c | 8 ++++---- sparse-index.c | 2 +- t/t1091-sparse-checkout-builtin.sh | 2 +- t/t1092-sparse-checkout-compatibility.sh | 1 + t/t7817-grep-sparse-checkout.sh | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/repo-settings.c b/repo-settings.c index fd3a9e04c491e8..21317070a7a69d 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -95,9 +95,9 @@ void prepare_repo_settings(struct repository *r) r->settings.command_requires_full_index = 1; /* - * Initialize this as off. + * Initialize this as on. */ - r->settings.sparse_index = 0; - if (!repo_config_get_bool(r, "index.sparse", &value) && value) - r->settings.sparse_index = 1; + r->settings.sparse_index = 1; + if (!repo_config_get_bool(r, "index.sparse", &value) && !value) + r->settings.sparse_index = 0; } diff --git a/sparse-index.c b/sparse-index.c index c27381d18ce66d..218eb0938a24de 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -105,7 +105,7 @@ int set_sparse_index_config(struct repository *repo, int enable) char *config_path = repo_git_path(repo, "config.worktree"); res = git_config_set_in_file_gently(config_path, "index.sparse", - enable ? "true" : NULL); + enable ? "true" : "false"); free(config_path); prepare_repo_settings(repo); diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index e0f31186d89eae..054e08d0a26b2d 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -215,7 +215,7 @@ test_expect_success 'sparse-index enabled and disabled' ' test-tool -C repo read-cache --table >cache && ! grep " tree " cache && git -C repo config --list >config && - ! grep index.sparse config + test_cmp_config -C repo false index.sparse ' test_expect_success 'cone mode: init and set' ' diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 458c3dde007119..0dfffb8856f466 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -147,6 +147,7 @@ init_repos () { git -C sparse-index reset --hard && # initialize sparse-checkout definitions + git -C sparse-checkout config index.sparse false && git -C sparse-checkout sparse-checkout init --cone && git -C sparse-checkout sparse-checkout set deep && git -C sparse-index sparse-checkout init --cone --sparse-index && diff --git a/t/t7817-grep-sparse-checkout.sh b/t/t7817-grep-sparse-checkout.sh index 590b99bbb6f7bb..547bae48619c12 100755 --- a/t/t7817-grep-sparse-checkout.sh +++ b/t/t7817-grep-sparse-checkout.sh @@ -49,7 +49,7 @@ test_expect_success 'setup' ' echo "text" >B/b && git add A B && git commit -m sub && - git sparse-checkout init --cone && + git sparse-checkout init --cone --no-sparse-index && git sparse-checkout set B ) &&