Skip to content

Commit 9d27fd7

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 91d3c70 commit 9d27fd7

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
@@ -1859,6 +1859,13 @@ struct oidtree *odb_source_loose_cache(struct odb_source *source,
18591859
return source->loose->cache;
18601860
}
18611861

1862+
void odb_source_loose_cache_add_new_oid(struct odb_source *source,
1863+
const struct object_id *oid)
1864+
{
1865+
struct oidtree *cache = odb_source_loose_cache(source, oid);
1866+
append_loose_object(oid, NULL, cache);
1867+
}
1868+
18621869
static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
18631870
{
18641871
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)