@@ -595,13 +595,6 @@ static void mark_ce_used(struct cache_entry *ce, struct unpack_trees_options *o)
595
595
{
596
596
ce -> ce_flags |= CE_UNPACKED ;
597
597
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
-
605
598
if (o -> cache_bottom < o -> src_index -> cache_nr &&
606
599
o -> src_index -> cache [o -> cache_bottom ] == ce ) {
607
600
int bottom = o -> cache_bottom ;
@@ -651,24 +644,17 @@ static void mark_ce_used_same_name(struct cache_entry *ce,
651
644
}
652
645
}
653
646
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 )
655
648
{
656
649
const struct index_state * index = o -> src_index ;
657
650
int pos = o -> cache_bottom ;
658
651
659
- if (* hint > pos )
660
- pos = * hint ;
661
-
662
652
while (pos < index -> cache_nr ) {
663
653
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 ))
666
655
return ce ;
667
- }
668
656
pos ++ ;
669
657
}
670
-
671
- * hint = pos ;
672
658
return NULL ;
673
659
}
674
660
@@ -1416,13 +1402,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
1416
1402
1417
1403
/* Are we supposed to look at the index too? */
1418
1404
if (o -> merge ) {
1419
- int hint = -1 ;
1420
1405
while (1 ) {
1421
1406
int cmp ;
1422
1407
struct cache_entry * ce ;
1423
1408
1424
1409
if (o -> diff_index_cached )
1425
- ce = next_cache_entry (o , & hint );
1410
+ ce = next_cache_entry (o );
1426
1411
else
1427
1412
ce = find_cache_entry (info , p );
1428
1413
@@ -1478,7 +1463,14 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
1478
1463
* it does not do any look-ahead, so this is safe.
1479
1464
*/
1480
1465
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 ;
1482
1474
return mask ;
1483
1475
}
1484
1476
}
@@ -1777,7 +1769,7 @@ static int verify_absent(const struct cache_entry *,
1777
1769
int unpack_trees (unsigned len , struct tree_desc * t , struct unpack_trees_options * o )
1778
1770
{
1779
1771
struct repository * repo = the_repository ;
1780
- int i , hint , ret ;
1772
+ int i , ret ;
1781
1773
static struct cache_entry * dfc ;
1782
1774
struct pattern_list pl ;
1783
1775
int free_pattern_list = 0 ;
@@ -1869,15 +1861,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1869
1861
info .pathspec = o -> pathspec ;
1870
1862
1871
1863
if (o -> prefix ) {
1872
- hint = -1 ;
1873
-
1874
1864
/*
1875
1865
* Unpack existing index entries that sort before the
1876
1866
* prefix the tree is spliced into. Note that o->merge
1877
1867
* is always true in this case.
1878
1868
*/
1879
1869
while (1 ) {
1880
- struct cache_entry * ce = next_cache_entry (o , & hint );
1870
+ struct cache_entry * ce = next_cache_entry (o );
1881
1871
if (!ce )
1882
1872
break ;
1883
1873
if (ce_in_traverse_path (ce , & info ))
@@ -1898,9 +1888,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1898
1888
1899
1889
/* Any left-over entries in the index? */
1900
1890
if (o -> merge ) {
1901
- hint = -1 ;
1902
1891
while (1 ) {
1903
- struct cache_entry * ce = next_cache_entry (o , & hint );
1892
+ struct cache_entry * ce = next_cache_entry (o );
1904
1893
if (!ce )
1905
1894
break ;
1906
1895
if (unpack_index_entry (ce , o ) < 0 )
0 commit comments