diff options
| author | Patrick Steinhardt <ps@pks.im> | 2026-03-05 15:19:42 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-05 11:45:14 -0800 |
| commit | cb506a8a69c953f7b87bb3ae099e0bed8218d3ab (patch) | |
| tree | 2b469f6c020f5fc1889a01754ed99443085eeb61 /object-file.c | |
| parent | ba1c21d34346e5979f9308806274bfcda4949ad4 (diff) | |
| download | git-cb506a8a69c953f7b87bb3ae099e0bed8218d3ab.tar.xz | |
odb: introduce "files" source
Introduce a new "files" object database source. This source encapsulates
access to both loose object files and the packfile store, similar to how
the "files" backend for refs encapsulates access to loose refs and the
packed-refs file.
Note that for now the "files" source is still a direct member of a
`struct odb_source`. This architecture will be reversed in the next
commit so that the files source contains a `struct odb_source`.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
| -rw-r--r-- | object-file.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/object-file.c b/object-file.c index 098b0541ab..db66ae5ebe 100644 --- a/object-file.c +++ b/object-file.c @@ -220,7 +220,7 @@ static void *odb_source_loose_map_object(struct odb_source *source, unsigned long *size) { const char *p; - int fd = open_loose_object(source->loose, oid, &p); + int fd = open_loose_object(source->files->loose, oid, &p); if (fd < 0) return NULL; @@ -423,7 +423,7 @@ static int read_object_info_from_path(struct odb_source *source, struct stat st; if ((!oi || (!oi->disk_sizep && !oi->mtimep)) && (flags & OBJECT_INFO_QUICK)) { - ret = quick_has_loose(source->loose, oid) ? 0 : -1; + ret = quick_has_loose(source->files->loose, oid) ? 0 : -1; goto out; } @@ -1868,31 +1868,31 @@ struct oidtree *odb_source_loose_cache(struct odb_source *source, { int subdir_nr = oid->hash[0]; struct strbuf buf = STRBUF_INIT; - size_t word_bits = bitsizeof(source->loose->subdir_seen[0]); + size_t word_bits = bitsizeof(source->files->loose->subdir_seen[0]); size_t word_index = subdir_nr / word_bits; size_t mask = (size_t)1u << (subdir_nr % word_bits); uint32_t *bitmap; if (subdir_nr < 0 || - (size_t) subdir_nr >= bitsizeof(source->loose->subdir_seen)) + (size_t) subdir_nr >= bitsizeof(source->files->loose->subdir_seen)) BUG("subdir_nr out of range"); - bitmap = &source->loose->subdir_seen[word_index]; + bitmap = &source->files->loose->subdir_seen[word_index]; if (*bitmap & mask) - return source->loose->cache; - if (!source->loose->cache) { - ALLOC_ARRAY(source->loose->cache, 1); - oidtree_init(source->loose->cache); + return source->files->loose->cache; + if (!source->files->loose->cache) { + ALLOC_ARRAY(source->files->loose->cache, 1); + oidtree_init(source->files->loose->cache); } strbuf_addstr(&buf, source->path); for_each_file_in_obj_subdir(subdir_nr, &buf, source->odb->repo->hash_algo, append_loose_object, NULL, NULL, - source->loose->cache); + source->files->loose->cache); *bitmap |= mask; strbuf_release(&buf); - return source->loose->cache; + return source->files->loose->cache; } static void odb_source_loose_clear_cache(struct odb_source_loose *loose) @@ -1905,7 +1905,7 @@ static void odb_source_loose_clear_cache(struct odb_source_loose *loose) void odb_source_loose_reprepare(struct odb_source *source) { - odb_source_loose_clear_cache(source->loose); + odb_source_loose_clear_cache(source->files->loose); } static int check_stream_oid(git_zstream *stream, |
