Skip to content

Commit b1af291

Browse files
committed
Merge branch 'ps/object-info-bits-cleanup' into ps/odb-sources
* 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()`
2 parents 703c975 + 732ec9b commit b1af291

8 files changed

Lines changed: 35 additions & 29 deletions

File tree

builtin/backfill.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static int fill_missing_blobs(const char *path UNUSED,
6767
return 0;
6868

6969
for (size_t i = 0; i < list->nr; i++) {
70-
if (!odb_has_object(ctx->repo->objects, &list->oid[i],
71-
OBJECT_INFO_FOR_PREFETCH))
70+
if (!odb_has_object(ctx->repo->objects, &list->oid[i], 0))
7271
oid_array_append(&ctx->current_batch, &list->oid[i]);
7372
}
7473

builtin/fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ static int mark_object(struct object *obj, enum object_type type,
162162
return 0;
163163

164164
if (!(obj->flags & HAS_OBJ)) {
165-
if (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) {
165+
if (parent && !odb_has_object(the_repository->objects, &obj->oid,
166+
HAS_OBJECT_RECHECK_PACKED)) {
166167
printf_ln(_("broken link from %7s %s\n"
167168
" to %7s %s"),
168169
printable_type(&parent->oid, parent->type),

object-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static int read_object_info_from_path(struct odb_source *source,
399399
const char *path,
400400
const struct object_id *oid,
401401
struct object_info *oi,
402-
unsigned flags)
402+
enum object_info_flags flags)
403403
{
404404
int ret;
405405
int fd;
@@ -541,7 +541,7 @@ static int read_object_info_from_path(struct odb_source *source,
541541
int odb_source_loose_read_object_info(struct odb_source *source,
542542
const struct object_id *oid,
543543
struct object_info *oi,
544-
unsigned flags)
544+
enum object_info_flags flags)
545545
{
546546
static struct strbuf buf = STRBUF_INIT;
547547
odb_loose_path(source, &buf, oid);

object-file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void odb_source_loose_reprepare(struct odb_source *source);
4848
int odb_source_loose_read_object_info(struct odb_source *source,
4949
const struct object_id *oid,
5050
struct object_info *oi,
51-
unsigned flags);
51+
enum object_info_flags flags);
5252

5353
int odb_source_loose_read_object_stream(struct odb_read_stream **out,
5454
struct odb_source *source,

odb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ static int oid_object_info_convert(struct repository *r,
844844
int odb_read_object_info_extended(struct object_database *odb,
845845
const struct object_id *oid,
846846
struct object_info *oi,
847-
unsigned flags)
847+
enum object_info_flags flags)
848848
{
849849
int ret;
850850

@@ -966,7 +966,7 @@ void *odb_read_object_peeled(struct object_database *odb,
966966
}
967967

968968
int odb_has_object(struct object_database *odb, const struct object_id *oid,
969-
unsigned flags)
969+
enum has_object_flags flags)
970970
{
971971
unsigned object_info_flags = 0;
972972

odb.h

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -382,23 +382,29 @@ struct object_info {
382382
*/
383383
#define OBJECT_INFO_INIT { 0 }
384384

385-
/* Invoke lookup_replace_object() on the given hash */
386-
#define OBJECT_INFO_LOOKUP_REPLACE 1
387-
/* Do not retry packed storage after checking packed and loose storage */
388-
#define OBJECT_INFO_QUICK 8
389-
/*
390-
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
391-
* nonzero).
392-
*/
393-
#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
394-
/*
395-
* This is meant for bulk prefetching of missing blobs in a partial
396-
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
397-
*/
398-
#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
385+
/* Flags that can be passed to `odb_read_object_info_extended()`. */
386+
enum object_info_flags {
387+
/* Invoke lookup_replace_object() on the given hash. */
388+
OBJECT_INFO_LOOKUP_REPLACE = (1 << 0),
399389

400-
/* Die if object corruption (not just an object being missing) was detected. */
401-
#define OBJECT_INFO_DIE_IF_CORRUPT 32
390+
/* Do not reprepare object sources when the first lookup has failed. */
391+
OBJECT_INFO_QUICK = (1 << 1),
392+
393+
/*
394+
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
395+
* nonzero).
396+
*/
397+
OBJECT_INFO_SKIP_FETCH_OBJECT = (1 << 2),
398+
399+
/* Die if object corruption (not just an object being missing) was detected. */
400+
OBJECT_INFO_DIE_IF_CORRUPT = (1 << 3),
401+
402+
/*
403+
* This is meant for bulk prefetching of missing blobs in a partial
404+
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK.
405+
*/
406+
OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK),
407+
};
402408

403409
/*
404410
* Read object info from the object database and populate the `object_info`
@@ -407,7 +413,7 @@ struct object_info {
407413
int odb_read_object_info_extended(struct object_database *odb,
408414
const struct object_id *oid,
409415
struct object_info *oi,
410-
unsigned flags);
416+
enum object_info_flags flags);
411417

412418
/*
413419
* 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,
419425
const struct object_id *oid,
420426
unsigned long *sizep);
421427

422-
enum {
428+
enum has_object_flags {
423429
/* Retry packed storage after checking packed and loose storage */
424430
HAS_OBJECT_RECHECK_PACKED = (1 << 0),
425431
/* Allow fetching the object in case the repository has a promisor remote. */
@@ -432,7 +438,7 @@ enum {
432438
*/
433439
int odb_has_object(struct object_database *odb,
434440
const struct object_id *oid,
435-
unsigned flags);
441+
enum has_object_flags flags);
436442

437443
int odb_freshen_object(struct object_database *odb,
438444
const struct object_id *oid);

packfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ int packfile_store_freshen_object(struct packfile_store *store,
21752175
int packfile_store_read_object_info(struct packfile_store *store,
21762176
const struct object_id *oid,
21772177
struct object_info *oi,
2178-
unsigned flags UNUSED)
2178+
enum object_info_flags flags UNUSED)
21792179
{
21802180
struct pack_entry e;
21812181
int ret;

packfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ int packfile_store_read_object_stream(struct odb_read_stream **out,
247247
int packfile_store_read_object_info(struct packfile_store *store,
248248
const struct object_id *oid,
249249
struct object_info *oi,
250-
unsigned flags);
250+
enum object_info_flags flags);
251251

252252
/*
253253
* Open the packfile and add it to the store if it isn't yet known. Returns

0 commit comments

Comments
 (0)