@@ -375,6 +375,10 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
375
375
full = xcalloc (1 , sizeof (struct index_state ));
376
376
memcpy (full , istate , sizeof (struct index_state ));
377
377
378
+ full -> name_hash_initialized = 0 ;
379
+ memset (& full -> name_hash , 0 , sizeof (full -> name_hash ));
380
+ memset (& full -> dir_hash , 0 , sizeof (full -> dir_hash ));
381
+
378
382
/*
379
383
* This slightly-misnamed 'full' index might still be sparse if we
380
384
* are only modifying the list of sparse directories. This hinges
@@ -433,9 +437,15 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
433
437
}
434
438
435
439
/* Copy back into original index. */
440
+ if (istate -> name_hash_initialized ) {
441
+ hashmap_clear (& istate -> name_hash );
442
+ hashmap_clear (& istate -> dir_hash );
443
+ }
444
+
436
445
istate -> name_hash_initialized = full -> name_hash_initialized ;
437
446
memcpy (& istate -> name_hash , & full -> name_hash , sizeof (full -> name_hash ));
438
447
memcpy (& istate -> dir_hash , & full -> dir_hash , sizeof (full -> dir_hash ));
448
+
439
449
istate -> sparse_index = pl ? INDEX_PARTIALLY_SPARSE : INDEX_EXPANDED ;
440
450
free (istate -> cache );
441
451
istate -> cache = full -> cache ;
0 commit comments