Skip to content

Commit

Permalink
checkout-index: improve ensure_full_index scope in checkout_all
Browse files Browse the repository at this point in the history
Update `checkout_all` to only run `ensure_full_index` when entries in
sparse directories are needed (i.e., `--sparse` is specified).

Signed-off-by: Victoria Dye <vdye@github.com>
  • Loading branch information
vdye authored and dscho committed Jan 20, 2022
1 parent a7c73d8 commit 56d6e2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions builtin/checkout-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
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 @@ -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 &&
Expand Down

0 comments on commit 56d6e2b

Please sign in to comment.