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>
This commit is contained in:
Jeff Hostetler 2019-09-24 14:31:10 -04:00 коммит произвёл Johannes Schindelin
Родитель 56a974bae0
Коммит 348694fdc1
2 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -2862,6 +2862,13 @@ struct oidtree *odb_loose_cache(struct object_directory *odb,
return odb->loose_objects_cache;
}
void odb_loose_cache_add_new_oid(struct object_directory *odb,
const struct object_id *oid)
{
struct oidtree *cache = odb_loose_cache(odb, oid);
append_loose_object(oid, NULL, cache);
}
void odb_clear_loose_cache(struct object_directory *odb)
{
oidtree_clear(odb->loose_objects_cache);

Просмотреть файл

@ -94,6 +94,14 @@ void restore_primary_odb(struct object_directory *restore_odb, const char *old_p
struct oidtree *odb_loose_cache(struct object_directory *odb,
const struct object_id *oid);
/*
* Add a new object to the loose object cache (possibly after the
* cache was populated). This might be used after dynamically
* fetching a missing object.
*/
void odb_loose_cache_add_new_oid(struct object_directory *odb,
const struct object_id *oid);
/* Empty the loose object cache for the specified object directory. */
void odb_clear_loose_cache(struct object_directory *odb);