summaryrefslogtreecommitdiffstats
path: root/packfile.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-10-25 09:05:03 +0200
committerTaylor Blau <me@ttaylorr.com>2024-10-25 23:35:46 +0200
commit4d995591476f0e0b11c512e4d711541118ea2b79 (patch)
tree00f03340ef764cd35e6d69d5202bed5caf0c0625 /packfile.h
parenthttp-walker: use object_id instead of bare hash (diff)
downloadgit-4d995591476f0e0b11c512e4d711541118ea2b79.tar.xz
git-4d995591476f0e0b11c512e4d711541118ea2b79.zip
packfile: convert find_sha1_pack() to use object_id
The find_sha1_pack() function has a few problems: - it's badly named, since it works with any object hash - it takes the hash as a bare pointer rather than an object_id struct We can fix both of these easily, as all callers actually have a real object_id anyway. I also found the existence of this function somewhat confusing, as it is about looking in an arbitrary set of linked packed_git structs. It's good for things like dumb-http which are looking in downloaded remote packs, and not our local packs. But despite the name, it is not a good way to find the pack which contains a local object (it skips the use of the midx, the pack mru list, and so on). So let's also add an explanatory comment above the declaration that may point people in the right direction. I suspect the calls in fast-import.c, which use the packed_git list from the repository struct, could actually just be using find_pack_entry(). But since we'd need to keep it anyway for dumb-http, I didn't dig further there. If we eventually drop dumb-http support, then it might be worth examining them to see if we can get rid of the function entirely. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'packfile.h')
-rw-r--r--packfile.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/packfile.h b/packfile.h
index ad393be9f1..3baffa940c 100644
--- a/packfile.h
+++ b/packfile.h
@@ -79,8 +79,13 @@ struct packed_git *get_all_packs(struct repository *r);
*/
unsigned long repo_approximate_object_count(struct repository *r);
-struct packed_git *find_sha1_pack(const unsigned char *sha1,
- struct packed_git *packs);
+/*
+ * Find the pack within the "packs" list whose index contains the object "oid".
+ * For general object lookups, you probably don't want this; use
+ * find_pack_entry() instead.
+ */
+struct packed_git *find_oid_pack(const struct object_id *oid,
+ struct packed_git *packs);
void pack_report(void);