| 1613 | } |
| 1614 | |
| 1615 | static int want_found_object(const struct object_id *oid, int exclude, |
| 1616 | struct packed_git *p, uint32_t mtime) |
| 1617 | { |
| 1618 | if (exclude) |
| 1619 | return 1; |
| 1620 | if (incremental) |
| 1621 | return 0; |
| 1622 | |
| 1623 | if (!is_pack_valid(p)) |
| 1624 | return -1; |
| 1625 | |
| 1626 | /* |
| 1627 | * When asked to do --local (do not include an object that appears in a |
| 1628 | * pack we borrow from elsewhere) or --honor-pack-keep (do not include |
| 1629 | * an object that appears in a pack marked with .keep), finding a pack |
| 1630 | * that matches the criteria is sufficient for us to decide to omit it. |
| 1631 | * However, even if this pack does not satisfy the criteria, we need to |
| 1632 | * make sure no copy of this object appears in _any_ pack that makes us |
| 1633 | * to omit the object, so we need to check all the packs. |
| 1634 | * |
| 1635 | * We can however first check whether these options can possibly matter; |
| 1636 | * if they do not matter we know we want the object in generated pack. |
| 1637 | * Otherwise, we signal "-1" at the end to tell the caller that we do |
| 1638 | * not know either way, and it needs to check more packs. |
| 1639 | */ |
| 1640 | |
| 1641 | /* |
| 1642 | * Objects in packs borrowed from elsewhere are discarded regardless of |
| 1643 | * if they appear in other packs that weren't borrowed. |
| 1644 | */ |
| 1645 | if (local && !p->pack_local) |
| 1646 | return 0; |
| 1647 | |
| 1648 | /* |
| 1649 | * Then handle .keep first, as we have a fast(er) path there. |
| 1650 | */ |
| 1651 | if (ignore_packed_keep_on_disk || ignore_packed_keep_in_core || |
| 1652 | ignore_packed_keep_in_core_open) { |
| 1653 | /* |
| 1654 | * Set the flags for the kept-pack cache to be the ones we want |
| 1655 | * to ignore. |
| 1656 | * |
| 1657 | * That is, if we are ignoring objects in on-disk keep packs, |
| 1658 | * then we want to search through the on-disk keep and ignore |
| 1659 | * the in-core ones. |
| 1660 | */ |
| 1661 | unsigned flags = 0; |
| 1662 | if (ignore_packed_keep_on_disk) |
| 1663 | flags |= KEPT_PACK_ON_DISK; |
| 1664 | if (ignore_packed_keep_in_core) |
| 1665 | flags |= KEPT_PACK_IN_CORE; |
| 1666 | if (ignore_packed_keep_in_core_open) |
| 1667 | flags |= KEPT_PACK_IN_CORE_OPEN; |
| 1668 | |
| 1669 | /* |
| 1670 | * If the object is in a pack that we want to ignore, *and* we |
| 1671 | * don't have any cruft packs that are being retained, we can |
| 1672 | * abort quickly. |
no test coverage detected