]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-checkout: avoid using internal API of unpack-trees, take 2
authorElijah Newren <newren@gmail.com>
Mon, 27 Feb 2023 15:28:15 +0000 (15:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2023 16:29:51 +0000 (08:29 -0800)
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>
builtin/sparse-checkout.c
unpack-trees.c

index 4b7390ce367f917e583d306fb4518124b6dfd77d..8d5ae6f2a60f913323cebf7014fd305ab09403bc 100644 (file)
@@ -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();
index 6e4ca6fe8004920e07372850355813b69c34bc4c..c8dacd76c5f4ff0076e1650ae67ebc989c0eee18 100644 (file)
@@ -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)