Skip to content

Commit 4cfa048

Browse files
jeffhostetlerderrickstolee
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 9026ccd commit 4cfa048

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
@@ -2689,6 +2689,13 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
26892689
return odb->loose_objects_cache;
26902690
}
26912691

2692+
void odb_loose_cache_add_new_oid(struct object_directory *odb,
2693+
const struct object_id *oid)
2694+
{
2695+
struct oidtree *cache = odb_loose_cache(odb, oid);
2696+
append_loose_object(oid, NULL, cache);
2697+
}
2698+
26922699
void odb_clear_loose_cache(struct object_directory *odb)
26932700
{
26942701
oidtree_clear(odb->loose_objects_cache);

object-store.h

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

91+
/*
92+
* Add a new object to the loose object cache (possibly after the
93+
* cache was populated). This might be used after dynamically
94+
* fetching a missing object.
95+
*/
96+
void odb_loose_cache_add_new_oid(struct object_directory *odb,
97+
const struct object_id *oid);
98+
9199
/* Empty the loose object cache for the specified object directory. */
92100
void odb_clear_loose_cache(struct object_directory *odb);
93101

0 commit comments

Comments
 (0)