checkout-index: ensure full index

Before we iterate over all cache entries, ensure that the index is not sparse. This loop in checkout_all() might be safe to iterate over a sparse index, but let's put this protection here until it can be carefully tested. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Apr 1, 2021 at 01:49 UTC 1b850d37f42d58d1c4ad1454d80ecf33797bc467
1 file changed +2
builtin/checkout-index.c
+2
@@ -119,6 +119,8 @@ static void checkout_all(const char *prefix, int prefix_length)
119 int i, errs = 0;
120 struct cache_entry *last_ce = NULL;
121
122 + /* TODO: audit for interaction with sparse-index. */
123 + ensure_full_index(&the_index);
124 for (i = 0; i < active_nr ; i++) {
125 struct cache_entry *ce = active_cache[i];
126 if (ce_stage(ce) != checkout_stage