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 derrickstolee committed Aug 31, 2022
1 parent 9026ccd commit 4cfa048
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 @@ -2689,6 +2689,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.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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 4cfa048

Please sign in to comment.