Skip to content

Commit

Permalink
sparse-checkout: avoid using internal API of unpack-trees, take 2
Browse files Browse the repository at this point in the history
Commit 2f6b1eb ("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>
  • Loading branch information
newren authored and gitster committed Feb 27, 2023
1 parent 1147c56 commit 33b1b4c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 0 additions & 1 deletion builtin/sparse-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ static int update_working_directory(struct pattern_list *pl)
o.head_idx = -1;
o.src_index = r->index;
o.dst_index = r->index;
index_state_init(&o.result, r);
o.skip_sparse_checkout = 0;

setup_work_tree();
Expand Down
1 change: 1 addition & 0 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -2101,6 +2101,7 @@ enum update_sparsity_result update_sparsity(struct unpack_trees_options *o,

old_show_all_errors = o->show_all_errors;
o->show_all_errors = 1;
index_state_init(&o->result, o->src_index->repo);

/* Sanity checks */
if (!o->update || o->index_only || o->skip_sparse_checkout)
Expand Down

0 comments on commit 33b1b4c

Please sign in to comment.