diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index dbc403afa43169..4ac566b5e22cb2 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -128,8 +128,9 @@ static int checkout_all(const char *prefix, int prefix_length, int include_spars int i, errs = 0; struct cache_entry *last_ce = NULL; - /* TODO: audit for interaction with sparse-index. */ - ensure_full_index(&the_index); + if (include_sparse) + ensure_full_index(&the_index); + for (i = 0; i < active_nr ; i++) { struct cache_entry *ce = active_cache[i]; if (!include_sparse && !path_in_sparse_checkout(ce->name, &the_index)) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 27da8d9154a787..d97ef4c9a66eb2 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -1148,6 +1148,7 @@ test_expect_success 'sparse-index is not expanded' ' ensure_not_expanded add . && ensure_not_expanded checkout-index -f a && + ensure_not_expanded checkout-index -f --all && for ref in update-deep update-folder1 update-folder2 update-deep do echo >>sparse-index/README.md &&