Skip to content

Commit 32da4d2

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 d62bc21 commit 32da4d2

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
@@ -1832,6 +1832,13 @@ struct oidtree *odb_source_loose_cache(struct odb_source *source,
18321832
return source->loose->cache;
18331833
}
18341834

1835+
void odb_source_loose_cache_add_new_oid(struct odb_source *source,
1836+
const struct object_id *oid)
1837+
{
1838+
struct oidtree *cache = odb_source_loose_cache(source, oid);
1839+
append_loose_object(oid, NULL, cache);
1840+
}
1841+
18351842
static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
18361843
{
18371844
oidtree_clear(loose->cache);

object-file.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ int odb_source_loose_write_stream(struct odb_source *source,
8181
struct oidtree *odb_source_loose_cache(struct odb_source *source,
8282
const struct object_id *oid);
8383

84+
/*
85+
* Add a new object to the loose object cache (possibly after the
86+
* cache was populated). This might be used after dynamically
87+
* fetching a missing object.
88+
*/
89+
void odb_source_loose_cache_add_new_oid(struct odb_source *source,
90+
const struct object_id *oid);
91+
8492
/*
8593
* Put in `buf` the name of the file in the local object database that
8694
* would be used to store a loose object with the specified oid.

0 commit comments

Comments
 (0)