diff --git a/repo-settings.c b/repo-settings.c index 9a6c974c96a92e..5241a9b4a06fba 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -116,9 +116,9 @@ void prepare_repo_settings(struct repository *r) r->settings.command_requires_full_index = 1; /* - * Initialize this as on. + * Initialize this as off. */ - r->settings.sparse_index = 1; - if (!repo_config_get_bool(r, "index.sparse", &value) && !value) - r->settings.sparse_index = 0; + r->settings.sparse_index = 0; + if (!repo_config_get_bool(r, "index.sparse", &value) && value) + r->settings.sparse_index = 1; } diff --git a/sparse-index.c b/sparse-index.c index 1573284de71b79..0c9fcc5a70a7e5 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -110,7 +110,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" : "false"); + enable ? "true" : NULL); free(config_path); prepare_repo_settings(repo); diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index b52c174acc7a1f..b4d46c3b5c20de 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -39,6 +39,7 @@ int cmd__read_cache(int argc, const char **argv) int table = 0, expand = 0; initialize_the_repository(); + setup_git_directory(); prepare_repo_settings(r); r->settings.command_requires_full_index = 0; @@ -53,7 +54,6 @@ int cmd__read_cache(int argc, const char **argv) if (argc == 1) cnt = strtol(argv[0], NULL, 0); - setup_git_directory(); git_config(git_default_config, NULL); for (i = 0; i < cnt; i++) { diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index 054e08d0a26b2d..e0f31186d89eae 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 && - test_cmp_config -C repo false index.sparse + ! grep index.sparse config ' 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 2e2175262f4d5a..3aa554190bcb73 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -147,7 +147,6 @@ 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 547bae48619c12..590b99bbb6f7bb 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 --no-sparse-index && + git sparse-checkout init --cone && git sparse-checkout set B ) &&