mirror of
https://github.com/git/git.git
synced 2026-06-24 08:48:31 +00:00
odb/source-loose: wire up freshen_object() callback
Move `odb_source_loose_freshen_object()` from "object-file.c" into "odb/source-loose.c" and wire it up as the `freshen_object()` callback of the loose source. As part of the move, `check_and_freshen_source()` is inlined into the callback function, as it has no other callers anymore. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
86f7ab5a1f
commit
d8b9e8bb23
@@ -152,7 +152,7 @@ static int odb_source_files_freshen_object(struct odb_source *source,
|
||||
{
|
||||
struct odb_source_files *files = odb_source_files_downcast(source);
|
||||
if (packfile_store_freshen_object(files->packed, oid) ||
|
||||
odb_source_loose_freshen_object(source, oid))
|
||||
odb_source_freshen_object(&files->loose->base, oid))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -580,6 +580,14 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int odb_source_loose_freshen_object(struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
static struct strbuf path = STRBUF_INIT;
|
||||
odb_loose_path(source, &path, oid);
|
||||
return !!check_and_freshen_file(path.buf, 1);
|
||||
}
|
||||
|
||||
static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
|
||||
{
|
||||
oidtree_clear(loose->cache);
|
||||
@@ -638,6 +646,7 @@ struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files)
|
||||
loose->base.for_each_object = odb_source_loose_for_each_object;
|
||||
loose->base.find_abbrev_len = odb_source_loose_find_abbrev_len;
|
||||
loose->base.count_objects = odb_source_loose_count_objects;
|
||||
loose->base.freshen_object = odb_source_loose_freshen_object;
|
||||
|
||||
if (!is_absolute_path(loose->base.path))
|
||||
chdir_notify_register(NULL, odb_source_loose_reparent, loose);
|
||||
|
||||
Reference in New Issue
Block a user