@@ -1584,7 +1584,8 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
1584
1584
*/
1585
1585
static enum contains_result contains_test (struct commit * candidate ,
1586
1586
const struct commit_list * want ,
1587
- struct contains_cache * cache )
1587
+ struct contains_cache * cache ,
1588
+ uint32_t cutoff )
1588
1589
{
1589
1590
enum contains_result * cached = contains_cache_at (cache , candidate );
1590
1591
@@ -1598,8 +1599,11 @@ static enum contains_result contains_test(struct commit *candidate,
1598
1599
return CONTAINS_YES ;
1599
1600
}
1600
1601
1601
- /* Otherwise, we don't know; prepare to recurse */
1602
1602
parse_commit_or_die (candidate );
1603
+
1604
+ if (candidate -> generation < cutoff )
1605
+ return CONTAINS_NO ;
1606
+
1603
1607
return CONTAINS_UNKNOWN ;
1604
1608
}
1605
1609
@@ -1615,8 +1619,18 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
1615
1619
struct contains_cache * cache )
1616
1620
{
1617
1621
struct contains_stack contains_stack = { 0 , 0 , NULL };
1618
- enum contains_result result = contains_test (candidate , want , cache );
1622
+ enum contains_result result ;
1623
+ uint32_t cutoff = GENERATION_NUMBER_UNDEF ;
1624
+ const struct commit_list * p ;
1625
+
1626
+ for (p = want ; p ; p = p -> next ) {
1627
+ struct commit * c = p -> item ;
1628
+ parse_commit_or_die (c );
1629
+ if (c -> generation < cutoff )
1630
+ cutoff = c -> generation ;
1631
+ }
1619
1632
1633
+ result = contains_test (candidate , want , cache , cutoff );
1620
1634
if (result != CONTAINS_UNKNOWN )
1621
1635
return result ;
1622
1636
@@ -1634,7 +1648,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
1634
1648
* If we just popped the stack, parents->item has been marked,
1635
1649
* therefore contains_test will return a meaningful yes/no.
1636
1650
*/
1637
- else switch (contains_test (parents -> item , want , cache )) {
1651
+ else switch (contains_test (parents -> item , want , cache , cutoff )) {
1638
1652
case CONTAINS_YES :
1639
1653
* contains_cache_at (cache , commit ) = CONTAINS_YES ;
1640
1654
contains_stack .nr -- ;
@@ -1648,7 +1662,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
1648
1662
}
1649
1663
}
1650
1664
free (contains_stack .contains_stack );
1651
- return contains_test (candidate , want , cache );
1665
+ return contains_test (candidate , want , cache , cutoff );
1652
1666
}
1653
1667
1654
1668
static int commit_contains (struct ref_filter * filter , struct commit * commit ,
0 commit comments