Skip to content

Commit 6a13193

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 <[email protected]>
1 parent 3a6b2e5 commit 6a13193

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
@@ -1481,6 +1481,13 @@ struct oidtree *odb_loose_cache(struct odb_source *source,
14811481
return source->loose_objects_cache;
14821482
}
14831483

1484+
void odb_loose_cache_add_new_oid(struct odb_source *source,
1485+
const struct object_id *oid)
1486+
{
1487+
struct oidtree *cache = odb_loose_cache(source, oid);
1488+
append_loose_object(oid, NULL, cache);
1489+
}
1490+
14841491
void odb_clear_loose_cache(struct odb_source *source)
14851492
{
14861493
oidtree_clear(source->loose_objects_cache);

object-file.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ struct odb_source;
3333
struct oidtree *odb_loose_cache(struct odb_source *source,
3434
const struct object_id *oid);
3535

36+
/*
37+
* Add a new object to the loose object cache (possibly after the
38+
* cache was populated). This might be used after dynamically
39+
* fetching a missing object.
40+
*/
41+
void odb_loose_cache_add_new_oid(struct odb_source *source,
42+
const struct object_id *oid);
43+
3644
/* Empty the loose object cache for the specified object directory. */
3745
void odb_clear_loose_cache(struct odb_source *source);
3846

0 commit comments

Comments
 (0)