]> git.ipfire.org Git - thirdparty/git.git/commit - sha1-file.c
object-store: provide helpers for loose_objects_cache
authorJeff King <peff@peff.net>
Mon, 12 Nov 2018 14:50:56 +0000 (09:50 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Nov 2018 05:22:03 +0000 (14:22 +0900)
commit3a2e08245cfccd932bb3ff78521e07d4a38c2834
treeeedf38839cf088ba390bfe12230bccaf5885427d
parentf0eaf638195a6510254b075026dcad955b8b607d
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>
object-store.h
packfile.c
sha1-file.c
sha1-name.c