Skip to content

Commit e6289f3

Browse files
jeffhostetlerdscho
authored andcommitted
sha1-file: add function to update existing loose object cache
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>
1 parent 1527081 commit e6289f3

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

object-file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,6 +2844,13 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
28442844
return odb->loose_objects_cache;
28452845
}
28462846

2847+
void odb_loose_cache_add_new_oid(struct object_directory *odb,
2848+
const struct object_id *oid)
2849+
{
2850+
struct oidtree *cache = odb_loose_cache(odb, oid);
2851+
append_loose_object(oid, NULL, cache);
2852+
}
2853+
28472854
void odb_clear_loose_cache(struct object_directory *odb)
28482855
{
28492856
oidtree_clear(odb->loose_objects_cache);

object-store-ll.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ void restore_primary_odb(struct object_directory *restore_odb, const char *old_p
9191
struct oidtree *odb_loose_cache(struct object_directory *odb,
9292
const struct object_id *oid);
9393

94+
/*
95+
* Add a new object to the loose object cache (possibly after the
96+
* cache was populated). This might be used after dynamically
97+
* fetching a missing object.
98+
*/
99+
void odb_loose_cache_add_new_oid(struct object_directory *odb,
100+
const struct object_id *oid);
101+
94102
/* Empty the loose object cache for the specified object directory. */
95103
void odb_clear_loose_cache(struct object_directory *odb);
96104

0 commit comments

Comments
 (0)