summaryrefslogtreecommitdiff
path: root/object-store.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-11-12 14:50:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-13 05:22:03 (GMT)
commit3a2e08245cfccd932bb3ff78521e07d4a38c2834 (patch)
treeeedf38839cf088ba390bfe12230bccaf5885427d /object-store.h
parentf0eaf638195a6510254b075026dcad955b8b607d (diff)
downloadgit-3a2e08245cfccd932bb3ff78521e07d4a38c2834.zip
git-3a2e08245cfccd932bb3ff78521e07d4a38c2834.tar.gz
git-3a2e08245cfccd932bb3ff78521e07d4a38c2834.tar.bz2
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 'object-store.h')
-rw-r--r--object-store.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/object-store.h b/object-store.h
index 30faf7b..bf1e0cb 100644
--- a/object-store.h
+++ b/object-store.h
@@ -11,11 +11,12 @@ struct object_directory {
struct object_directory *next;
/*
- * Used to store the results of readdir(3) calls when searching
- * for unique abbreviated hashes. This cache is never
- * invalidated, thus it's racy and not necessarily accurate.
- * That's fine for its purpose; don't use it for tasks requiring
- * greater accuracy!
+ * Used to store the results of readdir(3) calls when we are OK
+ * sacrificing accuracy due to races for speed. That includes
+ * our search for unique abbreviated hashes. Don't use it for tasks
+ * requiring greater accuracy!
+ *
+ * Be sure to call odb_load_loose_cache() before using.
*/
char loose_objects_subdir_seen[256];
struct oid_array loose_objects_cache;
@@ -45,6 +46,13 @@ void add_to_alternates_file(const char *dir);
*/
void add_to_alternates_memory(const char *dir);
+/*
+ * Populate an odb's loose object cache for one particular subdirectory (i.e.,
+ * the one that corresponds to the first byte of objects you're interested in,
+ * from 0 to 255 inclusive).
+ */
+void odb_load_loose_cache(struct object_directory *odb, int subdir_nr);
+
struct packed_git {
struct packed_git *next;
struct list_head mru;