Skip to content

Commit

Permalink
repo-settings: enable sparse index by default
Browse files Browse the repository at this point in the history
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 <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Aug 24, 2021
1 parent acb8623 commit d59110a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions repo-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion sparse-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion t/t1091-sparse-checkout-builtin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' '
Expand Down
1 change: 1 addition & 0 deletions t/t1092-sparse-checkout-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion t/t7817-grep-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
) &&
Expand Down

0 comments on commit d59110a

Please sign in to comment.