@@ -378,9 +378,6 @@ static int checkout_worktree(const struct checkout_opts *opts,
if (pc_workers > 1)
init_parallel_checkout();
- /* TODO: audit for interaction with sparse-index. */
- ensure_full_index(&the_index);
-
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
if (ce->ce_flags & CE_MATCHED) {
@@ -530,8 +527,6 @@ static int checkout_paths(const struct checkout_opts *opts,
* Make sure all pathspecs participated in locating the paths
* to be checked out.
*/
- /* TODO: audit for interaction with sparse-index. */
- ensure_full_index(&the_index);
for (pos = 0; pos < active_nr; pos++)
if (opts->overlay_mode)
mark_ce_for_checkout_overlay(active_cache[pos],
@@ -1593,6 +1588,9 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
git_config(git_checkout_config, opts);
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
opts->track = BRANCH_TRACK_UNSPECIFIED;
if (!opts->accept_pathspec && !opts->accept_ref)
@@ -560,7 +560,15 @@ test_expect_success 'sparse-index is not expanded' '
echo >>sparse-index/a &&
ensure_not_expanded commit --include a -m a &&
echo >>sparse-index/deep/deeper1/a &&
- ensure_not_expanded commit --include deep/deeper1/a -m deeper
+ ensure_not_expanded commit --include deep/deeper1/a -m deeper &&
+ ensure_not_expanded checkout rename-out-to-out &&
+ ensure_not_expanded checkout - &&
+ ensure_not_expanded switch rename-out-to-out &&
+ ensure_not_expanded switch - &&
+ git -C sparse-index reset --hard &&
+ ensure_not_expanded checkout rename-out-to-out -- deep/deeper1 &&
+ git -C sparse-index reset --hard &&
+ ensure_not_expanded restore -s rename-out-to-out -- deep/deeper1
'
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout