Skip to content

Commit f55843a

Browse files
committed
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 <[email protected]>
1 parent acb8623 commit f55843a

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

repo-settings.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ void prepare_repo_settings(struct repository *r)
9595
r->settings.command_requires_full_index = 1;
9696

9797
/*
98-
* Initialize this as off.
98+
* Initialize this as on.
9999
*/
100-
r->settings.sparse_index = 0;
101-
if (!repo_config_get_bool(r, "index.sparse", &value) && value)
102-
r->settings.sparse_index = 1;
100+
r->settings.sparse_index = 1;
101+
if (!repo_config_get_bool(r, "index.sparse", &value) && !value)
102+
r->settings.sparse_index = 0;
103103
}

sparse-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int set_sparse_index_config(struct repository *repo, int enable)
105105
char *config_path = repo_git_path(repo, "config.worktree");
106106
res = git_config_set_in_file_gently(config_path,
107107
"index.sparse",
108-
enable ? "true" : NULL);
108+
enable ? "true" : "false");
109109
free(config_path);
110110

111111
prepare_repo_settings(repo);

t/t1091-sparse-checkout-builtin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ test_expect_success 'sparse-index enabled and disabled' '
215215
test-tool -C repo read-cache --table >cache &&
216216
! grep " tree " cache &&
217217
git -C repo config --list >config &&
218-
! grep index.sparse config
218+
test_cmp_config -C repo false index.sparse
219219
'
220220

221221
test_expect_success 'cone mode: init and set' '

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ init_repos () {
147147
git -C sparse-index reset --hard &&
148148

149149
# initialize sparse-checkout definitions
150+
git -C sparse-checkout config index.sparse false &&
150151
git -C sparse-checkout sparse-checkout init --cone &&
151152
git -C sparse-checkout sparse-checkout set deep &&
152153
git -C sparse-index sparse-checkout init --cone --sparse-index &&

t/t7817-grep-sparse-checkout.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_expect_success 'setup' '
4949
echo "text" >B/b &&
5050
git add A B &&
5151
git commit -m sub &&
52-
git sparse-checkout init --cone &&
52+
git sparse-checkout init --cone --no-sparse-index &&
5353
git sparse-checkout set B
5454
) &&
5555

0 commit comments

Comments
 (0)