mirror of
https://github.com/git/git.git
synced 2026-02-26 01:43:43 +00:00
Merge branch 'ps/object-info-bits-cleanup' into jch
A couple of bugs in use of flag bits around odb API has been corrected, and the flag bits reordered. * ps/object-info-bits-cleanup: odb: convert `odb_has_object()` flags into an enum odb: convert object info flags into an enum odb: drop gaps in object info flag values builtin/fsck: fix flags passed to `odb_has_object()` builtin/backfill: fix flags passed to `odb_has_object()`
This commit is contained in:
@@ -67,8 +67,7 @@ static int fill_missing_blobs(const char *path UNUSED,
|
||||
return 0;
|
||||
|
||||
for (size_t i = 0; i < list->nr; i++) {
|
||||
if (!odb_has_object(ctx->repo->objects, &list->oid[i],
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
if (!odb_has_object(ctx->repo->objects, &list->oid[i], 0))
|
||||
oid_array_append(&ctx->current_batch, &list->oid[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,8 @@ static int mark_object(struct object *obj, enum object_type type,
|
||||
return 0;
|
||||
|
||||
if (!(obj->flags & HAS_OBJ)) {
|
||||
if (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {
|
||||
if (parent && !odb_has_object(the_repository->objects, &obj->oid,
|
||||
HAS_OBJECT_RECHECK_PACKED)) {
|
||||
printf_ln(_("broken link from %7s %s\n"
|
||||
" to %7s %s"),
|
||||
printable_type(&parent->oid, parent->type),
|
||||
|
||||
@@ -399,7 +399,7 @@ static int read_object_info_from_path(struct odb_source *source,
|
||||
const char *path,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags)
|
||||
enum object_info_flags flags)
|
||||
{
|
||||
int ret;
|
||||
int fd;
|
||||
@@ -541,7 +541,7 @@ out:
|
||||
int odb_source_loose_read_object_info(struct odb_source *source,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags)
|
||||
enum object_info_flags flags)
|
||||
{
|
||||
static struct strbuf buf = STRBUF_INIT;
|
||||
odb_loose_path(source, &buf, oid);
|
||||
|
||||
@@ -48,7 +48,7 @@ void odb_source_loose_reprepare(struct odb_source *source);
|
||||
int odb_source_loose_read_object_info(struct odb_source *source,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags);
|
||||
enum object_info_flags flags);
|
||||
|
||||
int odb_source_loose_read_object_stream(struct odb_read_stream **out,
|
||||
struct odb_source *source,
|
||||
|
||||
4
odb.c
4
odb.c
@@ -844,7 +844,7 @@ static int oid_object_info_convert(struct repository *r,
|
||||
int odb_read_object_info_extended(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags)
|
||||
enum object_info_flags flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -966,7 +966,7 @@ void *odb_read_object_peeled(struct object_database *odb,
|
||||
}
|
||||
|
||||
int odb_has_object(struct object_database *odb, const struct object_id *oid,
|
||||
unsigned flags)
|
||||
enum has_object_flags flags)
|
||||
{
|
||||
unsigned object_info_flags = 0;
|
||||
|
||||
|
||||
44
odb.h
44
odb.h
@@ -382,23 +382,29 @@ struct object_info {
|
||||
*/
|
||||
#define OBJECT_INFO_INIT { 0 }
|
||||
|
||||
/* Invoke lookup_replace_object() on the given hash */
|
||||
#define OBJECT_INFO_LOOKUP_REPLACE 1
|
||||
/* Do not retry packed storage after checking packed and loose storage */
|
||||
#define OBJECT_INFO_QUICK 8
|
||||
/*
|
||||
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
|
||||
* nonzero).
|
||||
*/
|
||||
#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
|
||||
/*
|
||||
* This is meant for bulk prefetching of missing blobs in a partial
|
||||
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
|
||||
*/
|
||||
#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
|
||||
/* Flags that can be passed to `odb_read_object_info_extended()`. */
|
||||
enum object_info_flags {
|
||||
/* Invoke lookup_replace_object() on the given hash. */
|
||||
OBJECT_INFO_LOOKUP_REPLACE = (1 << 0),
|
||||
|
||||
/* Die if object corruption (not just an object being missing) was detected. */
|
||||
#define OBJECT_INFO_DIE_IF_CORRUPT 32
|
||||
/* Do not reprepare object sources when the first lookup has failed. */
|
||||
OBJECT_INFO_QUICK = (1 << 1),
|
||||
|
||||
/*
|
||||
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
|
||||
* nonzero).
|
||||
*/
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT = (1 << 2),
|
||||
|
||||
/* Die if object corruption (not just an object being missing) was detected. */
|
||||
OBJECT_INFO_DIE_IF_CORRUPT = (1 << 3),
|
||||
|
||||
/*
|
||||
* This is meant for bulk prefetching of missing blobs in a partial
|
||||
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK.
|
||||
*/
|
||||
OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK),
|
||||
};
|
||||
|
||||
/*
|
||||
* Read object info from the object database and populate the `object_info`
|
||||
@@ -407,7 +413,7 @@ struct object_info {
|
||||
int odb_read_object_info_extended(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags);
|
||||
enum object_info_flags flags);
|
||||
|
||||
/*
|
||||
* Read a subset of object info for the given object ID. Returns an `enum
|
||||
@@ -419,7 +425,7 @@ int odb_read_object_info(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
unsigned long *sizep);
|
||||
|
||||
enum {
|
||||
enum has_object_flags {
|
||||
/* 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. */
|
||||
@@ -432,7 +438,7 @@ enum {
|
||||
*/
|
||||
int odb_has_object(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
unsigned flags);
|
||||
enum has_object_flags flags);
|
||||
|
||||
int odb_freshen_object(struct object_database *odb,
|
||||
const struct object_id *oid);
|
||||
|
||||
@@ -2175,7 +2175,7 @@ int packfile_store_freshen_object(struct packfile_store *store,
|
||||
int packfile_store_read_object_info(struct packfile_store *store,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags UNUSED)
|
||||
enum object_info_flags flags UNUSED)
|
||||
{
|
||||
struct pack_entry e;
|
||||
int ret;
|
||||
|
||||
@@ -247,7 +247,7 @@ int packfile_store_read_object_stream(struct odb_read_stream **out,
|
||||
int packfile_store_read_object_info(struct packfile_store *store,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
unsigned flags);
|
||||
enum object_info_flags flags);
|
||||
|
||||
/*
|
||||
* Open the packfile and add it to the store if it isn't yet known. Returns
|
||||
|
||||
Reference in New Issue
Block a user