@@ -151,7 +151,7 @@ void cache_tree_invalidate_path(struct index_state *istate, const char *path)
151151 istate -> cache_changed |= CACHE_TREE_CHANGED ;
152152}
153153
154- static int verify_cache (const struct cache_entry * const * cache ,
154+ static int verify_cache (struct cache_entry * * cache ,
155155 int entries , int flags )
156156{
157157 int i , funny ;
@@ -236,7 +236,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
236236}
237237
238238static int update_one (struct cache_tree * it ,
239- const struct cache_entry * const * cache ,
239+ struct cache_entry * * cache ,
240240 int entries ,
241241 const char * base ,
242242 int baselen ,
@@ -398,18 +398,19 @@ static int update_one(struct cache_tree *it,
398398 return i ;
399399}
400400
401- int cache_tree_update (struct cache_tree * it ,
402- const struct cache_entry * const * cache ,
403- int entries ,
404- int flags )
401+ int cache_tree_update (struct index_state * istate , int flags )
405402{
406- int i , skip ;
407- i = verify_cache (cache , entries , flags );
403+ struct cache_tree * it = istate -> cache_tree ;
404+ struct cache_entry * * cache = istate -> cache ;
405+ int entries = istate -> cache_nr ;
406+ int skip , i = verify_cache (cache , entries , flags );
407+
408408 if (i )
409409 return i ;
410410 i = update_one (it , cache , entries , "" , 0 , & skip , flags );
411411 if (i < 0 )
412412 return i ;
413+ istate -> cache_changed |= CACHE_TREE_CHANGED ;
413414 return 0 ;
414415}
415416
@@ -597,9 +598,7 @@ int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)
597598
598599 was_valid = cache_tree_fully_valid (active_cache_tree );
599600 if (!was_valid ) {
600- if (cache_tree_update (active_cache_tree ,
601- (const struct cache_entry * const * )active_cache ,
602- active_nr , flags ) < 0 )
601+ if (cache_tree_update (& the_index , flags ) < 0 )
603602 return WRITE_TREE_UNMERGED_INDEX ;
604603 if (0 <= newfd ) {
605604 if (!write_locked_index (& the_index , lock_file , COMMIT_LOCK ))
@@ -698,7 +697,5 @@ int update_main_cache_tree(int flags)
698697{
699698 if (!the_index .cache_tree )
700699 the_index .cache_tree = cache_tree ();
701- return cache_tree_update (the_index .cache_tree ,
702- (const struct cache_entry * const * )the_index .cache ,
703- the_index .cache_nr , flags );
700+ return cache_tree_update (& the_index , flags );
704701}
0 commit comments