Skip to content

Commit

Permalink
sha1-file: add function to update existing loose object cache
Browse files Browse the repository at this point in the history
Create a function to add a new object to the loose object cache
after the existing odb/xx/ directory was scanned.

This will be used in a later commit to keep the loose object
cache fresh after dynamically fetching an individual object
and without requiring the odb/xx/ directory to be rescanned.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler authored and dscho committed Aug 16, 2023
1 parent d7ba07f commit 8667c31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions object-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2844,6 +2844,13 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
return odb->loose_objects_cache;
}

void odb_loose_cache_add_new_oid(struct object_directory *odb,
const struct object_id *oid)
{
struct oidtree *cache = odb_loose_cache(odb, oid);
append_loose_object(oid, NULL, cache);
}

void odb_clear_loose_cache(struct object_directory *odb)
{
oidtree_clear(odb->loose_objects_cache);
Expand Down
8 changes: 8 additions & 0 deletions object-store-ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ void restore_primary_odb(struct object_directory *restore_odb, const char *old_p
struct oidtree *odb_loose_cache(struct object_directory *odb,
const struct object_id *oid);

/*
* Add a new object to the loose object cache (possibly after the
* cache was populated). This might be used after dynamically
* fetching a missing object.
*/
void odb_loose_cache_add_new_oid(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);

Expand Down

0 comments on commit 8667c31

Please sign in to comment.