Skip to content

Commit 7c6fc31

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 78e57b3 commit 7c6fc31

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
@@ -1846,6 +1846,13 @@ struct oidtree *odb_loose_cache(struct odb_source *source,
18461846
return source->loose_objects_cache;
18471847
}
18481848

1849+
void odb_loose_cache_add_new_oid(struct odb_source *source,
1850+
const struct object_id *oid)
1851+
{
1852+
struct oidtree *cache = odb_loose_cache(source, oid);
1853+
append_loose_object(oid, NULL, cache);
1854+
}
1855+
18491856
void odb_clear_loose_cache(struct odb_source *source)
18501857
{
18511858
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)