Skip to content

Commit 4826944

Browse files
jeffhostetlermjcheetham
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 <[email protected]>
1 parent 926e6cf commit 4826944

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

object-file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,13 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
31823182
return odb->loose_objects_cache;
31833183
}
31843184

3185+
void odb_loose_cache_add_new_oid(struct object_directory *odb,
3186+
const struct object_id *oid)
3187+
{
3188+
struct oidtree *cache = odb_loose_cache(odb, oid);
3189+
append_loose_object(oid, NULL, cache);
3190+
}
3191+
31853192
void odb_clear_loose_cache(struct object_directory *odb)
31863193
{
31873194
oidtree_clear(odb->loose_objects_cache);

object-store-ll.h

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

98+
/*
99+
* Add a new object to the loose object cache (possibly after the
100+
* cache was populated). This might be used after dynamically
101+
* fetching a missing object.
102+
*/
103+
void odb_loose_cache_add_new_oid(struct object_directory *odb,
104+
const struct object_id *oid);
105+
98106
/* Empty the loose object cache for the specified object directory. */
99107
void odb_clear_loose_cache(struct object_directory *odb);
100108

0 commit comments

Comments
 (0)