aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-02 17:06:52 -0800
committerJunio C Hamano <gitster@pobox.com>2026-03-02 17:06:52 -0800
commit10dd04a3feef385358d66bf3d653325f64c20d3c (patch)
tree2129ba4a8c8b302eb888c5d14ed98139e373a30f
parent02c31a8ddc7a79a4e8f9dd0c437bcf3e73e60203 (diff)
parent732ec9b17b78a49496bfb796fcfe606f3a9f02f1 (diff)
downloadgit-10dd04a3feef385358d66bf3d653325f64c20d3c.tar.xz
Merge branch 'ps/object-info-bits-cleanup'
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()`
-rw-r--r--builtin/backfill.c3
-rw-r--r--builtin/fsck.c3
-rw-r--r--object-file.c4
-rw-r--r--object-file.h2
-rw-r--r--odb.c4
-rw-r--r--odb.h44
-rw-r--r--packfile.c2
-rw-r--r--packfile.h2
8 files changed, 35 insertions, 29 deletions
diff --git a/builtin/backfill.c b/builtin/backfill.c
index e80fc1b694..d8cb3b0eba 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -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]);
}
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 80e298049f..384d47ee77 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -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),
diff --git a/object-file.c b/object-file.c
index 8d1d8c778e..098b0541ab 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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);
diff --git a/object-file.h b/object-file.h
index 8df10bbb15..47fad6663b 100644
--- a/object-file.h
+++ b/object-file.h
@@ -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,
diff --git a/odb.c b/odb.c
index 025cd76520..776de5356c 100644
--- a/odb.c
+++ b/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;
diff --git a/odb.h b/odb.h
index 2e643de2ee..68b8ec2289 100644
--- a/odb.h
+++ b/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);
diff --git a/packfile.c b/packfile.c
index 57fbf51876..ce837f852a 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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;
diff --git a/packfile.h b/packfile.h
index 1a1b720764..224142fd34 100644
--- a/packfile.h
+++ b/packfile.h
@@ -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