sparse-checkout: avoid using internal API of unpack-trees, take 2

Commit 2f6b1eb794 ("cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()", 2023-01-12) mistakenly added some initialization of a member of unpack_trees_options that was intended to be internal-only. This initialization should be done within update_sparsity() instead. Note that while o->result is mostly meant for unpack_trees() and update_sparsity() mostly operates without o->result, check_ok_to_remove() does consult it so we need to ensure it is properly initialized. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Feb 27, 2023 at 15:28 UTC 33b1b4c7681703c44babdbd229cc96a3ad540569
2 files changed +1 -1
builtin/sparse-checkout.c
-1
@@ -217,7 +217,6 @@ static int update_working_directory(struct pattern_list *pl)
217 o.head_idx = -1;
218 o.src_index = r->index;
219 o.dst_index = r->index;
220 - index_state_init(&o.result, r);
220 o.skip_sparse_checkout = 0;
221
222 setup_work_tree();
unpack-trees.c
+1
@@ -2101,6 +2101,7 @@ enum update_sparsity_result update_sparsity(struct unpack_trees_options *o,
2101
2102 old_show_all_errors = o->show_all_errors;
2103 o->show_all_errors = 1;
2104 + index_state_init(&o->result, o->src_index->repo);
2105
2106 /* Sanity checks */
2107 if (!o->update || o->index_only || o->skip_sparse_checkout)