commit: ensure full index

These two loops iterate over all cache entries, so ensure that a sparse index is expanded to a full index before we do so. 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 cb8388df5b3252802a0149ca558f99307e42074c
1 file changed +4
builtin/commit.c
+4
@@ -251,6 +251,8 @@ static int list_paths(struct string_list *list, const char *with_tree,
251 free(max_prefix);
252 }
253
254 + /* TODO: audit for interaction with sparse-index. */
255 + ensure_full_index(&the_index);
256 for (i = 0; i < active_nr; i++) {
257 const struct cache_entry *ce = active_cache[i];
258 struct string_list_item *item;
@@ -931,6 +933,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
933 if (get_oid(parent, &oid)) {
934 int i, ita_nr = 0;
935
936 + /* TODO: audit for interaction with sparse-index. */
937 + ensure_full_index(&the_index);
938 for (i = 0; i < active_nr; i++)
939 if (ce_intent_to_add(active_cache[i]))
940 ita_nr++;