@@ -369,6 +369,10 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
369
369
full = xcalloc (1 , sizeof (struct index_state ));
370
370
memcpy (full , istate , sizeof (struct index_state ));
371
371
372
+ full -> name_hash_initialized = 0 ;
373
+ memset (& full -> name_hash , 0 , sizeof (full -> name_hash ));
374
+ memset (& full -> dir_hash , 0 , sizeof (full -> dir_hash ));
375
+
372
376
/*
373
377
* This slightly-misnamed 'full' index might still be sparse if we
374
378
* are only modifying the list of sparse directories. This hinges
@@ -427,9 +431,15 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
427
431
}
428
432
429
433
/* Copy back into original index. */
434
+ if (istate -> name_hash_initialized ) {
435
+ hashmap_clear (& istate -> name_hash );
436
+ hashmap_clear (& istate -> dir_hash );
437
+ }
438
+
430
439
istate -> name_hash_initialized = full -> name_hash_initialized ;
431
440
memcpy (& istate -> name_hash , & full -> name_hash , sizeof (full -> name_hash ));
432
441
memcpy (& istate -> dir_hash , & full -> dir_hash , sizeof (full -> dir_hash ));
442
+
433
443
istate -> sparse_index = pl ? INDEX_PARTIALLY_SPARSE : INDEX_EXPANDED ;
434
444
free (istate -> cache );
435
445
istate -> cache = full -> cache ;
0 commit comments