diff options
author | Jeff King <peff@peff.net> | 2018-11-12 09:50:56 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-13 14:22:03 +0900 |
commit | 3a2e08245cfccd932bb3ff78521e07d4a38c2834 (patch) | |
tree | eedf38839cf088ba390bfe12230bccaf5885427d /packfile.c | |
parent | sha1-file: use an object_directory for the main object dir (diff) | |
download | tgif-3a2e08245cfccd932bb3ff78521e07d4a38c2834.tar.xz |
object-store: provide helpers for loose_objects_cache
Our object_directory struct has a loose objects cache that all users of
the struct can see. But the only one that knows how to load the cache is
find_short_object_filename(). Let's extract that logic in to a reusable
function.
While we're at it, let's also reset the cache when we re-read the object
directories. This shouldn't have an impact on performance, as re-reads
are meant to be rare (and are already expensive, so we avoid them with
things like OBJECT_INFO_QUICK).
Since the cache is already meant to be an approximation, it's tempting
to skip even this bit of safety. But it's necessary to allow more code
to use it. For instance, fetch-pack explicitly re-reads the object
directory after performing its fetch, and would be confused if we didn't
clear the cache.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r-- | packfile.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/packfile.c b/packfile.c index 1eda33247f..91fd40efb0 100644 --- a/packfile.c +++ b/packfile.c @@ -987,6 +987,14 @@ static void prepare_packed_git(struct repository *r) void reprepare_packed_git(struct repository *r) { + struct object_directory *odb; + + for (odb = r->objects->odb; odb; odb = odb->next) { + oid_array_clear(&odb->loose_objects_cache); + memset(&odb->loose_objects_subdir_seen, 0, + sizeof(odb->loose_objects_subdir_seen)); + } + r->objects->approximate_object_count_valid = 0; r->objects->packed_git_initialized = 0; prepare_packed_git(r); |