update-index: ensure full index

Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. 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 2508df0272fdae3025b53366ac6b456920bc0de0
1 file changed +2
builtin/update-index.c
+2
@@ -745,6 +745,8 @@ static int do_reupdate(int ac, const char **av,
745 */
746 has_head = 0;
747 redo:
748 + /* TODO: audit for interaction with sparse-index. */
749 + ensure_full_index(&the_index);
750 for (pos = 0; pos < active_nr; pos++) {
751 const struct cache_entry *ce = active_cache[pos];
752 struct cache_entry *old = NULL;