Skip to content

Commit d4e19e5

Browse files
rscharfegitster
authored andcommitted
object-store: factor out odb_clear_loose_cache()
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0000d65 commit d4e19e5

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

object-store.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr);
6161
struct oid_array *odb_loose_cache(struct object_directory *odb,
6262
const struct object_id *oid);
6363

64+
/* Empty the loose object cache for the specified object directory. */
65+
void odb_clear_loose_cache(struct object_directory *odb);
66+
6467
struct packed_git {
6568
struct packed_git *next;
6669
struct list_head mru;

object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ struct raw_object_store *raw_object_store_new(void)
485485
static void free_object_directory(struct object_directory *odb)
486486
{
487487
free(odb->path);
488-
oid_array_clear(&odb->loose_objects_cache);
488+
odb_clear_loose_cache(odb);
489489
free(odb);
490490
}
491491

packfile.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -994,11 +994,8 @@ void reprepare_packed_git(struct repository *r)
994994
{
995995
struct object_directory *odb;
996996

997-
for (odb = r->objects->odb; odb; odb = odb->next) {
998-
oid_array_clear(&odb->loose_objects_cache);
999-
memset(&odb->loose_objects_subdir_seen, 0,
1000-
sizeof(odb->loose_objects_subdir_seen));
1001-
}
997+
for (odb = r->objects->odb; odb; odb = odb->next)
998+
odb_clear_loose_cache(odb);
1002999

10031000
r->objects->approximate_object_count_valid = 0;
10041001
r->objects->packed_git_initialized = 0;

sha1-file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,13 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
21782178
strbuf_release(&buf);
21792179
}
21802180

2181+
void odb_clear_loose_cache(struct object_directory *odb)
2182+
{
2183+
oid_array_clear(&odb->loose_objects_cache);
2184+
memset(&odb->loose_objects_subdir_seen, 0,
2185+
sizeof(odb->loose_objects_subdir_seen));
2186+
}
2187+
21812188
static int check_stream_sha1(git_zstream *stream,
21822189
const char *hdr,
21832190
unsigned long size,

0 commit comments

Comments
 (0)