Skip to content

Commit 6863df3

Browse files
derrickstoleegitster
authored andcommitted
unpack-trees: ensure full index
The next change will translate full indexes into sparse indexes at write time. The existing logic provides a way for every sparse index to be expanded to a full index at read time. However, there are cases where an index is written and then continues to be used in-memory to perform further updates. unpack_trees() is frequently called after such a write. In particular, commands like 'git reset' do this double-update of the index. Ensure that we have a full index when entering unpack_trees(), but only when command_requires_full_index is true. This is always true at the moment, but we will later relax that after unpack_trees() is updated to handle sparse directory entries. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2782db3 commit 6863df3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

unpack-trees.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ static int verify_absent(const struct cache_entry *,
15671567
*/
15681568
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
15691569
{
1570+
struct repository *repo = the_repository;
15701571
int i, ret;
15711572
static struct cache_entry *dfc;
15721573
struct pattern_list pl;
@@ -1578,6 +1579,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
15781579
trace_performance_enter();
15791580
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
15801581

1582+
prepare_repo_settings(repo);
1583+
if (repo->settings.command_requires_full_index) {
1584+
ensure_full_index(o->src_index);
1585+
ensure_full_index(o->dst_index);
1586+
}
1587+
15811588
if (!core_apply_sparse_checkout || !o->update)
15821589
o->skip_sparse_checkout = 1;
15831590
if (!o->skip_sparse_checkout && !o->pl) {

0 commit comments

Comments
 (0)