packfile: inline `find_kept_pack_entry()`
The `find_kept_pack_entry()` function is only used in `has_object_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>
Patrick Steinhardt committed
Jan 9, 2026 at 09:33 UTC
6acefa0d2ca0fd95461b19026917d09210032b3d
2 files changed
+10
-24
packfile.c
+10
-18
@@ -2215,12 +2215,17 @@ struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *st
2215
return store->kept_cache.packs;
2216
}
2217
2218
-int find_kept_pack_entry(struct repository *r,
2219
- const struct object_id *oid,
2220
- unsigned flags,
2221
- struct pack_entry *e)
2218
+int has_object_pack(struct repository *r, const struct object_id *oid)
2219
+{
2220
+ struct pack_entry e;
2221
+ return find_pack_entry(r, oid, &e);
2222
+}
2223
+
2224
+int has_object_kept_pack(struct repository *r, const struct object_id *oid,
2225
+ unsigned flags)
2226
{
2227
struct odb_source *source;
2228
+ struct pack_entry e;
2229
2230
for (source = r->objects->sources; source; source = source->next) {
2231
struct packed_git **cache;
@@ -2229,7 +2234,7 @@ int find_kept_pack_entry(struct repository *r,
2234
2235
for (; *cache; cache++) {
2236
struct packed_git *p = *cache;
2232
- if (fill_pack_entry(oid, e, p))
2237
+ if (fill_pack_entry(oid, &e, p))
2238
return 1;
2239
}
2240
}
@@ -2237,19 +2242,6 @@ int find_kept_pack_entry(struct repository *r,
2242
return 0;
2243
}
2244
2240
-int has_object_pack(struct repository *r, const struct object_id *oid)
2241
-{
2242
- struct pack_entry e;
2243
- return find_pack_entry(r, oid, &e);
2244
-}
2245
-
2246
-int has_object_kept_pack(struct repository *r, const struct object_id *oid,
2247
- unsigned flags)
2248
-{
2249
- struct pack_entry e;
2250
- return find_kept_pack_entry(r, oid, flags, &e);
2251
-}
2252
-
2245
int for_each_object_in_pack(struct packed_git *p,
2246
each_packed_object_fn cb, void *data,
2247
enum for_each_object_flags flags)
packfile.h
-6
@@ -445,12 +445,6 @@ int packed_object_info(struct repository *r,
445
void mark_bad_packed_object(struct packed_git *, const struct object_id *);
446
const struct packed_git *has_packed_and_bad(struct repository *, const struct object_id *);
447
448
-/*
449
- * Iff a pack file in the given repository contains the object named by sha1,
450
- * return true and store its location to e.
451
- */
452
-int find_kept_pack_entry(struct repository *r, const struct object_id *oid, unsigned flags, struct pack_entry *e);
453
-
448
int has_object_pack(struct repository *r, const struct object_id *oid);
449
int has_object_kept_pack(struct repository *r, const struct object_id *oid,
450
unsigned flags);