@@ -595,13 +595,6 @@ static void mark_ce_used(struct cache_entry *ce, struct unpack_trees_options *o)
595595{
596596 ce -> ce_flags |= CE_UNPACKED ;
597597
598- /*
599- * If this is a sparse directory, don't advance cache_bottom.
600- * That will be advanced later using the cache-tree data.
601- */
602- if (S_ISSPARSEDIR (ce -> ce_mode ))
603- return ;
604-
605598 if (o -> cache_bottom < o -> src_index -> cache_nr &&
606599 o -> src_index -> cache [o -> cache_bottom ] == ce ) {
607600 int bottom = o -> cache_bottom ;
@@ -651,24 +644,17 @@ static void mark_ce_used_same_name(struct cache_entry *ce,
651644 }
652645}
653646
654- static struct cache_entry * next_cache_entry (struct unpack_trees_options * o , int * hint )
647+ static struct cache_entry * next_cache_entry (struct unpack_trees_options * o )
655648{
656649 const struct index_state * index = o -> src_index ;
657650 int pos = o -> cache_bottom ;
658651
659- if (* hint > pos )
660- pos = * hint ;
661-
662652 while (pos < index -> cache_nr ) {
663653 struct cache_entry * ce = index -> cache [pos ];
664- if (!(ce -> ce_flags & CE_UNPACKED )) {
665- * hint = pos + 1 ;
654+ if (!(ce -> ce_flags & CE_UNPACKED ))
666655 return ce ;
667- }
668656 pos ++ ;
669657 }
670-
671- * hint = pos ;
672658 return NULL ;
673659}
674660
@@ -1416,13 +1402,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
14161402
14171403 /* Are we supposed to look at the index too? */
14181404 if (o -> merge ) {
1419- int hint = -1 ;
14201405 while (1 ) {
14211406 int cmp ;
14221407 struct cache_entry * ce ;
14231408
14241409 if (o -> diff_index_cached )
1425- ce = next_cache_entry (o , & hint );
1410+ ce = next_cache_entry (o );
14261411 else
14271412 ce = find_cache_entry (info , p );
14281413
@@ -1478,7 +1463,14 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
14781463 * it does not do any look-ahead, so this is safe.
14791464 */
14801465 if (matches ) {
1481- o -> cache_bottom += matches ;
1466+ /*
1467+ * Only increment the cache_bottom if the
1468+ * directory isn't a sparse directory index
1469+ * entry (if it is, it was already incremented)
1470+ * in 'mark_ce_used()'
1471+ */
1472+ if (!src [0 ] || !S_ISSPARSEDIR (src [0 ]-> ce_mode ))
1473+ o -> cache_bottom += matches ;
14821474 return mask ;
14831475 }
14841476 }
@@ -1777,7 +1769,7 @@ static int verify_absent(const struct cache_entry *,
17771769int unpack_trees (unsigned len , struct tree_desc * t , struct unpack_trees_options * o )
17781770{
17791771 struct repository * repo = the_repository ;
1780- int i , hint , ret ;
1772+ int i , ret ;
17811773 static struct cache_entry * dfc ;
17821774 struct pattern_list pl ;
17831775 int free_pattern_list = 0 ;
@@ -1869,15 +1861,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18691861 info .pathspec = o -> pathspec ;
18701862
18711863 if (o -> prefix ) {
1872- hint = -1 ;
1873-
18741864 /*
18751865 * Unpack existing index entries that sort before the
18761866 * prefix the tree is spliced into. Note that o->merge
18771867 * is always true in this case.
18781868 */
18791869 while (1 ) {
1880- struct cache_entry * ce = next_cache_entry (o , & hint );
1870+ struct cache_entry * ce = next_cache_entry (o );
18811871 if (!ce )
18821872 break ;
18831873 if (ce_in_traverse_path (ce , & info ))
@@ -1898,9 +1888,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18981888
18991889 /* Any left-over entries in the index? */
19001890 if (o -> merge ) {
1901- hint = -1 ;
19021891 while (1 ) {
1903- struct cache_entry * ce = next_cache_entry (o , & hint );
1892+ struct cache_entry * ce = next_cache_entry (o );
19041893 if (!ce )
19051894 break ;
19061895 if (unpack_index_entry (ce , o ) < 0 )
0 commit comments