summaryrefslogtreecommitdiff
path: root/sha1-file.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2019-01-06 16:45:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-08 17:40:19 (GMT)
commit0000d6543f1c2ceea017161a2807167cdfbf8c0b (patch)
tree5b6a69a5dedba99739ecee0c2f9c617ab4cac157 /sha1-file.c
parentecbdaf0899161c067986e9d9d564586d4b045d62 (diff)
downloadgit-0000d6543f1c2ceea017161a2807167cdfbf8c0b.zip
git-0000d6543f1c2ceea017161a2807167cdfbf8c0b.tar.gz
git-0000d6543f1c2ceea017161a2807167cdfbf8c0b.tar.bz2
object-store: factor out odb_loose_cache()
Add and use a function for loading the entries of a loose object subdirectory for a given object ID. It frees callers from deriving the fanout key; they can use the returned oid_array reference for lookups or forward range scans. Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-file.c')
-rw-r--r--sha1-file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sha1-file.c b/sha1-file.c
index 5a272f7..cb8583b 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -924,7 +924,6 @@ static int open_sha1_file(struct repository *r,
static int quick_has_loose(struct repository *r,
const unsigned char *sha1)
{
- int subdir_nr = sha1[0];
struct object_id oid;
struct object_directory *odb;
@@ -932,8 +931,7 @@ static int quick_has_loose(struct repository *r,
prepare_alt_odb(r);
for (odb = r->objects->odb; odb; odb = odb->next) {
- odb_load_loose_cache(odb, subdir_nr);
- if (oid_array_lookup(&odb->loose_objects_cache, &oid) >= 0)
+ if (oid_array_lookup(odb_loose_cache(odb, &oid), &oid) >= 0)
return 1;
}
return 0;
@@ -2152,6 +2150,14 @@ static int append_loose_object(const struct object_id *oid, const char *path,
return 0;
}
+struct oid_array *odb_loose_cache(struct object_directory *odb,
+ const struct object_id *oid)
+{
+ int subdir_nr = oid->hash[0];
+ odb_load_loose_cache(odb, subdir_nr);
+ return &odb->loose_objects_cache;
+}
+
void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
{
struct strbuf buf = STRBUF_INIT;