]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-store: factor out odb_clear_loose_cache()
authorRené Scharfe <l.s.r@web.de>
Sun, 6 Jan 2019 16:45:39 +0000 (17:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Jan 2019 17:40:19 +0000 (09:40 -0800)
Add and use a function for emptying the loose object cache, so callers
don't have to know any of its implementation details.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-store.h
object.c
packfile.c
sha1-file.c

index 7236c571c0c036ceab15b1579841dd4eab09e761..709bf856b678bbd9ccd10714283277524df6b394 100644 (file)
@@ -61,6 +61,9 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr);
 struct oid_array *odb_loose_cache(struct object_directory *odb,
                                  const struct object_id *oid);
 
+/* Empty the loose object cache for the specified object directory. */
+void odb_clear_loose_cache(struct object_directory *odb);
+
 struct packed_git {
        struct packed_git *next;
        struct list_head mru;
index 79d636091ca1a334a71d516326f14887ea91b946..a5c5cf830fc52d03adb4283cafd097218e1117a0 100644 (file)
--- a/object.c
+++ b/object.c
@@ -485,7 +485,7 @@ struct raw_object_store *raw_object_store_new(void)
 static void free_object_directory(struct object_directory *odb)
 {
        free(odb->path);
-       oid_array_clear(&odb->loose_objects_cache);
+       odb_clear_loose_cache(odb);
        free(odb);
 }
 
index 8c6b47cc777708d4f8e450337f2b9d205f43591b..0fe9c21bf108965867ca691c245c3be0124a9102 100644 (file)
@@ -994,11 +994,8 @@ 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));
-       }
+       for (odb = r->objects->odb; odb; odb = odb->next)
+               odb_clear_loose_cache(odb);
 
        r->objects->approximate_object_count_valid = 0;
        r->objects->packed_git_initialized = 0;
index cb8583b634c5dda914e608f05ede12310618c8b8..2f965b26880d850e78b1611669b56bd503f8a230 100644 (file)
@@ -2178,6 +2178,13 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
        strbuf_release(&buf);
 }
 
+void odb_clear_loose_cache(struct object_directory *odb)
+{
+       oid_array_clear(&odb->loose_objects_cache);
+       memset(&odb->loose_objects_subdir_seen, 0,
+              sizeof(odb->loose_objects_subdir_seen));
+}
+
 static int check_stream_sha1(git_zstream *stream,
                             const char *hdr,
                             unsigned long size,