@@ -494,7 +494,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
494494 * anything in the existing directory there.
495495 */
496496 int namelen ;
497- int pos , i ;
497+ int i ;
498498 struct dir_struct d ;
499499 char * pathbuf ;
500500 int cnt = 0 ;
@@ -515,24 +515,20 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
515515 * in that directory.
516516 */
517517 namelen = strlen (ce -> name );
518- pos = index_name_pos (o -> src_index , ce -> name , namelen );
519- if (0 <= pos )
520- return cnt ; /* we have it as nondirectory */
521- pos = - pos - 1 ;
522- for (i = pos ; i < o -> src_index -> cache_nr ; i ++ ) {
523- struct cache_entry * ce = o -> src_index -> cache [i ];
524- int len = ce_namelen (ce );
518+ for (i = o -> pos ; i < o -> src_index -> cache_nr ; i ++ ) {
519+ struct cache_entry * ce2 = o -> src_index -> cache [i ];
520+ int len = ce_namelen (ce2 );
525521 if (len < namelen ||
526- strncmp (ce -> name , ce -> name , namelen ) ||
527- ce -> name [namelen ] != '/' )
522+ strncmp (ce -> name , ce2 -> name , namelen ) ||
523+ ce2 -> name [namelen ] != '/' )
528524 break ;
529525 /*
530- * ce ->name is an entry in the subdirectory.
526+ * ce2 ->name is an entry in the subdirectory.
531527 */
532- if (!ce_stage (ce )) {
533- if (verify_uptodate (ce , o ))
528+ if (!ce_stage (ce2 )) {
529+ if (verify_uptodate (ce2 , o ))
534530 return -1 ;
535- add_entry (o , ce , CE_REMOVE , 0 );
531+ add_entry (o , ce2 , CE_REMOVE , 0 );
536532 }
537533 cnt ++ ;
538534 }
@@ -588,7 +584,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
588584 return 0 ;
589585
590586 if (!lstat (ce -> name , & st )) {
591- int cnt ;
587+ int ret ;
592588 int dtype = ce_to_dtype (ce );
593589 struct cache_entry * result ;
594590
@@ -616,13 +612,15 @@ static int verify_absent(struct cache_entry *ce, const char *action,
616612 * files that are in "foo/" we would lose
617613 * it.
618614 */
619- cnt = verify_clean_subdirectory (ce , action , o );
615+ ret = verify_clean_subdirectory (ce , action , o );
616+ if (ret < 0 )
617+ return ret ;
620618
621619 /*
622620 * If this removed entries from the index,
623621 * what that means is:
624622 *
625- * (1) the caller unpack_trees_rec () saw path/foo
623+ * (1) the caller unpack_callback () saw path/foo
626624 * in the index, and it has not removed it because
627625 * it thinks it is handling 'path' as blob with
628626 * D/F conflict;
@@ -635,7 +633,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
635633 * We need to increment it by the number of
636634 * deleted entries here.
637635 */
638- o -> pos += cnt ;
636+ o -> pos += ret ;
639637 return 0 ;
640638 }
641639
0 commit comments