object-store: allow fetching objects via `has_object()`
We're about to fully remove `repo_has_object_file()` in favor of `has_object()`. The latter function does not yet have a way to fetch missing objects via a promisor remote though, which means that it cannot fully replace all usecases of `repo_has_object_file()`. Introduce a new flag `HAS_OBJECT_FETCH_PROMISOR` that causes the function to optionally fetch missing objects which are part of a promisor pack. This flag will be used in the subsequent commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
1a793261c5
commit
f8fc4cacd3
|
|
@ -937,12 +937,15 @@ void *read_object_with_reference(struct repository *r,
|
||||||
int has_object(struct repository *r, const struct object_id *oid,
|
int has_object(struct repository *r, const struct object_id *oid,
|
||||||
unsigned flags)
|
unsigned flags)
|
||||||
{
|
{
|
||||||
int quick = !(flags & HAS_OBJECT_RECHECK_PACKED);
|
unsigned object_info_flags = 0;
|
||||||
unsigned object_info_flags = OBJECT_INFO_SKIP_FETCH_OBJECT |
|
|
||||||
(quick ? OBJECT_INFO_QUICK : 0);
|
|
||||||
|
|
||||||
if (!startup_info->have_repository)
|
if (!startup_info->have_repository)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (!(flags & HAS_OBJECT_RECHECK_PACKED))
|
||||||
|
object_info_flags |= OBJECT_INFO_QUICK;
|
||||||
|
if (!(flags & HAS_OBJECT_FETCH_PROMISOR))
|
||||||
|
object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;
|
||||||
|
|
||||||
return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;
|
return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,12 +262,16 @@ int oid_object_info_extended(struct repository *r,
|
||||||
const struct object_id *,
|
const struct object_id *,
|
||||||
struct object_info *, unsigned flags);
|
struct object_info *, unsigned flags);
|
||||||
|
|
||||||
/* Retry packed storage after checking packed and loose storage */
|
enum {
|
||||||
#define HAS_OBJECT_RECHECK_PACKED 1
|
/* Retry packed storage after checking packed and loose storage */
|
||||||
|
HAS_OBJECT_RECHECK_PACKED = (1 << 0),
|
||||||
|
/* Allow fetching the object in case the repository has a promisor remote. */
|
||||||
|
HAS_OBJECT_FETCH_PROMISOR = (1 << 1),
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns 1 if the object exists. This function will not lazily fetch objects
|
* Returns 1 if the object exists. This function will not lazily fetch objects
|
||||||
* in a partial clone.
|
* in a partial clone by default.
|
||||||
*/
|
*/
|
||||||
int has_object(struct repository *r, const struct object_id *oid,
|
int has_object(struct repository *r, const struct object_id *oid,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue