mirror of
https://github.com/git/git.git
synced 2026-01-22 23:07:18 +09:00
builtin/pack-objects: use packfile_store_for_each_object()
When enumerating objects that are supposed to be stored in a new cruft pack we use `for_each_packed_object()` and then derive each object's mtime individually. Refactor this logic to instead use the new `packfile_store_for_each_object()` function with an object info request that asks for the respective mtimes. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d11ff24f77
commit
3ebb07b62f
@ -4314,25 +4314,12 @@ static void show_edge(struct commit *commit)
|
||||
}
|
||||
|
||||
static int add_object_in_unpacked_pack(const struct object_id *oid,
|
||||
struct packed_git *pack,
|
||||
uint32_t pos,
|
||||
struct object_info *oi,
|
||||
void *data UNUSED)
|
||||
{
|
||||
if (cruft) {
|
||||
off_t offset;
|
||||
time_t mtime;
|
||||
|
||||
if (pack->is_cruft) {
|
||||
if (load_pack_mtimes(pack) < 0)
|
||||
die(_("could not load cruft pack .mtimes"));
|
||||
mtime = nth_packed_mtime(pack, pos);
|
||||
} else {
|
||||
mtime = pack->mtime;
|
||||
}
|
||||
offset = nth_packed_object_offset(pack, pos);
|
||||
|
||||
add_cruft_object_entry(oid, OBJ_NONE, pack, offset,
|
||||
NULL, mtime);
|
||||
add_cruft_object_entry(oid, OBJ_NONE, oi->u.packed.pack,
|
||||
oi->u.packed.offset, NULL, *oi->mtimep);
|
||||
} else {
|
||||
add_object_entry(oid, OBJ_NONE, "", 0);
|
||||
}
|
||||
@ -4341,14 +4328,24 @@ static int add_object_in_unpacked_pack(const struct object_id *oid,
|
||||
|
||||
static void add_objects_in_unpacked_packs(void)
|
||||
{
|
||||
if (for_each_packed_object(to_pack.repo,
|
||||
add_object_in_unpacked_pack,
|
||||
NULL,
|
||||
ODB_FOR_EACH_OBJECT_PACK_ORDER |
|
||||
ODB_FOR_EACH_OBJECT_LOCAL_ONLY |
|
||||
ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS |
|
||||
ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS))
|
||||
die(_("cannot open pack index"));
|
||||
struct odb_source *source;
|
||||
time_t mtime;
|
||||
struct object_info oi = {
|
||||
.mtimep = &mtime,
|
||||
};
|
||||
|
||||
odb_prepare_alternates(to_pack.repo->objects);
|
||||
for (source = to_pack.repo->objects->sources; source; source = source->next) {
|
||||
if (!source->local)
|
||||
continue;
|
||||
|
||||
if (packfile_store_for_each_object(source->packfiles, &oi,
|
||||
add_object_in_unpacked_pack, NULL,
|
||||
ODB_FOR_EACH_OBJECT_PACK_ORDER |
|
||||
ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS |
|
||||
ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS))
|
||||
die(_("cannot open pack index"));
|
||||
}
|
||||
}
|
||||
|
||||
static int add_loose_object(const struct object_id *oid, const char *path,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user