packfile: inline find_kept_pack_entry()

The `find_kept_pack_entry()` function is only used in
`has_oject_kept_pack()`, which is only a trivial wrapper itself. Inline
the latter into the former.

Furthermore, reorder the code so that we can drop the declaration of the
function in "packfile.h". This allows us to make the function file-local.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2025-12-18 07:55:27 +01:00 committed by Junio C Hamano
parent 7060cb98e9
commit b0f97d5b7d
2 changed files with 15 additions and 29 deletions

View File

@ -2215,28 +2215,6 @@ struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *st
return store->kept_cache.packs;
}
int find_kept_pack_entry(struct repository *r,
const struct object_id *oid,
unsigned flags,
struct pack_entry *e)
{
struct odb_source *source;
for (source = r->objects->sources; source; source = source->next) {
struct packed_git **cache;
cache = packfile_store_get_kept_pack_cache(source->packfiles, flags);
for (; *cache; cache++) {
struct packed_git *p = *cache;
if (fill_pack_entry(oid, e, p))
return 1;
}
}
return 0;
}
int has_object_pack(struct repository *r, const struct object_id *oid)
{
struct pack_entry e;
@ -2246,8 +2224,22 @@ int has_object_pack(struct repository *r, const struct object_id *oid)
int has_object_kept_pack(struct repository *r, const struct object_id *oid,
unsigned flags)
{
struct odb_source *source;
struct pack_entry e;
return find_kept_pack_entry(r, oid, flags, &e);
for (source = r->objects->sources; source; source = source->next) {
struct packed_git **cache;
cache = packfile_store_get_kept_pack_cache(source->packfiles, flags);
for (; *cache; cache++) {
struct packed_git *p = *cache;
if (fill_pack_entry(oid, &e, p))
return 1;
}
}
return 0;
}
int for_each_object_in_pack(struct packed_git *p,

View File

@ -445,12 +445,6 @@ int packed_object_info(struct repository *r,
void mark_bad_packed_object(struct packed_git *, const struct object_id *);
const struct packed_git *has_packed_and_bad(struct repository *, const struct object_id *);
/*
* Iff a pack file in the given repository contains the object named by sha1,
* return true and store its location to e.
*/
int find_kept_pack_entry(struct repository *r, const struct object_id *oid, unsigned flags, struct pack_entry *e);
int has_object_pack(struct repository *r, const struct object_id *oid);
int has_object_kept_pack(struct repository *r, const struct object_id *oid,
unsigned flags);