aboutsummaryrefslogtreecommitdiff
path: root/builtin/cat-file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-23 13:48:00 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-23 13:48:00 -0800
commit703c97519dfac64291f79b1772e25c65d233e97e (patch)
treeeaa54faaa2f776393ba94dd35ef37cded5649f62 /builtin/cat-file.c
parent7c02d39fc2ed2702223c7674f73150d9a7e61ba4 (diff)
parent3565faf28c2059c6260d53ac71a303b1c04b0a7b (diff)
downloadgit-703c97519dfac64291f79b1772e25c65d233e97e.tar.xz
Merge branch 'ps/odb-for-each-object' into ps/odb-sources
* ps/odb-for-each-object: odb: drop unused `for_each_{loose,packed}_object()` functions reachable: convert to use `odb_for_each_object()` builtin/pack-objects: use `packfile_store_for_each_object()` odb: introduce mtime fields for object info requests treewide: drop uses of `for_each_{loose,packed}_object()` treewide: enumerate promisor objects via `odb_for_each_object()` builtin/fsck: refactor to use `odb_for_each_object()` odb: introduce `odb_for_each_object()` packfile: introduce function to iterate through objects packfile: extract function to iterate through objects of a store object-file: introduce function to iterate through objects object-file: extract function to read object info from path odb: fix flags parameter to be unsigned odb: rename `FOR_EACH_OBJECT_*` flags
Diffstat (limited to 'builtin/cat-file.c')
-rw-r--r--builtin/cat-file.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index df8e87a81f..53ffe80c79 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -806,11 +806,14 @@ struct for_each_object_payload {
void *payload;
};
-static int batch_one_object_loose(const struct object_id *oid,
- const char *path UNUSED,
- void *_payload)
+static int batch_one_object_oi(const struct object_id *oid,
+ struct object_info *oi,
+ void *_payload)
{
struct for_each_object_payload *payload = _payload;
+ if (oi && oi->whence == OI_PACKED)
+ return payload->callback(oid, oi->u.packed.pack, oi->u.packed.offset,
+ payload->payload);
return payload->callback(oid, NULL, 0, payload->payload);
}
@@ -846,8 +849,21 @@ static void batch_each_object(struct batch_options *opt,
.payload = _payload,
};
struct bitmap_index *bitmap = NULL;
+ struct odb_source *source;
- for_each_loose_object(the_repository->objects, batch_one_object_loose, &payload, 0);
+ /*
+ * TODO: we still need to tap into implementation details of the object
+ * database sources. Ideally, we should extend `odb_for_each_object()`
+ * to handle object filters itself so that we can move the filtering
+ * logic into the individual sources.
+ */
+ odb_prepare_alternates(the_repository->objects);
+ for (source = the_repository->objects->sources; source; source = source->next) {
+ int ret = odb_source_loose_for_each_object(source, NULL, batch_one_object_oi,
+ &payload, flags);
+ if (ret)
+ break;
+ }
if (opt->objects_filter.choice != LOFC_DISABLED &&
(bitmap = prepare_bitmap_git(the_repository)) &&
@@ -863,8 +879,14 @@ static void batch_each_object(struct batch_options *opt,
&payload, flags);
}
} else {
- for_each_packed_object(the_repository, batch_one_object_packed,
- &payload, flags);
+ struct object_info oi = { 0 };
+
+ for (source = the_repository->objects->sources; source; source = source->next) {
+ int ret = packfile_store_for_each_object(source->packfiles, &oi,
+ batch_one_object_oi, &payload, flags);
+ if (ret)
+ break;
+ }
}
free_bitmap_index(bitmap);
@@ -924,7 +946,7 @@ static int batch_objects(struct batch_options *opt)
cb.seen = &seen;
batch_each_object(opt, batch_unordered_object,
- FOR_EACH_OBJECT_PACK_ORDER, &cb);
+ ODB_FOR_EACH_OBJECT_PACK_ORDER, &cb);
oidset_clear(&seen);
} else {