|
35 | 35 | #include "midx.h"
|
36 | 36 | #include "trace2.h"
|
37 | 37 | #include "shallow.h"
|
| 38 | +#include "promisor-remote.h" |
38 | 39 |
|
39 | 40 | #define IN_PACK(obj) oe_in_pack(&to_pack, obj)
|
40 | 41 | #define SIZE(obj) oe_size(&to_pack, obj)
|
@@ -1704,9 +1705,30 @@ static int can_reuse_delta(const struct object_id *base_oid,
|
1704 | 1705 | return 0;
|
1705 | 1706 | }
|
1706 | 1707 |
|
1707 |
| -static void check_object(struct object_entry *entry) |
| 1708 | +static void prefetch_to_pack(uint32_t object_index_start) { |
| 1709 | + struct oid_array to_fetch = OID_ARRAY_INIT; |
| 1710 | + uint32_t i; |
| 1711 | + |
| 1712 | + for (i = object_index_start; i < to_pack.nr_objects; i++) { |
| 1713 | + struct object_entry *entry = to_pack.objects + i; |
| 1714 | + |
| 1715 | + if (!oid_object_info_extended(the_repository, |
| 1716 | + &entry->idx.oid, |
| 1717 | + NULL, |
| 1718 | + OBJECT_INFO_FOR_PREFETCH)) |
| 1719 | + continue; |
| 1720 | + oid_array_append(&to_fetch, &entry->idx.oid); |
| 1721 | + } |
| 1722 | + promisor_remote_get_direct(the_repository, |
| 1723 | + to_fetch.oid, to_fetch.nr); |
| 1724 | + oid_array_clear(&to_fetch); |
| 1725 | +} |
| 1726 | + |
| 1727 | +static void check_object(struct object_entry *entry, uint32_t object_index) |
1708 | 1728 | {
|
1709 | 1729 | unsigned long canonical_size;
|
| 1730 | + enum object_type type; |
| 1731 | + struct object_info oi = {.typep = &type, .sizep = &canonical_size}; |
1710 | 1732 |
|
1711 | 1733 | if (IN_PACK(entry)) {
|
1712 | 1734 | struct packed_git *p = IN_PACK(entry);
|
@@ -1840,8 +1862,18 @@ static void check_object(struct object_entry *entry)
|
1840 | 1862 | unuse_pack(&w_curs);
|
1841 | 1863 | }
|
1842 | 1864 |
|
1843 |
| - oe_set_type(entry, |
1844 |
| - oid_object_info(the_repository, &entry->idx.oid, &canonical_size)); |
| 1865 | + if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi, |
| 1866 | + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) { |
| 1867 | + if (has_promisor_remote()) { |
| 1868 | + prefetch_to_pack(object_index); |
| 1869 | + if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi, |
| 1870 | + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) |
| 1871 | + type = -1; |
| 1872 | + } else { |
| 1873 | + type = -1; |
| 1874 | + } |
| 1875 | + } |
| 1876 | + oe_set_type(entry, type); |
1845 | 1877 | if (entry->type_valid) {
|
1846 | 1878 | SET_SIZE(entry, canonical_size);
|
1847 | 1879 | } else {
|
@@ -2061,7 +2093,7 @@ static void get_object_details(void)
|
2061 | 2093 |
|
2062 | 2094 | for (i = 0; i < to_pack.nr_objects; i++) {
|
2063 | 2095 | struct object_entry *entry = sorted_by_offset[i];
|
2064 |
| - check_object(entry); |
| 2096 | + check_object(entry, i); |
2065 | 2097 | if (entry->type_valid &&
|
2066 | 2098 | oe_size_greater_than(&to_pack, entry, big_file_threshold))
|
2067 | 2099 | entry->no_try_delta = 1;
|
|
0 commit comments