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>main
parent
86f7ab5a1f
commit
d8b9e8bb23
|
|
@ -87,15 +87,6 @@ int check_and_freshen_file(const char *fn, int freshen)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int check_and_freshen_source(struct odb_source *source,
|
||||
const struct object_id *oid,
|
||||
int freshen)
|
||||
{
|
||||
static struct strbuf path = STRBUF_INIT;
|
||||
odb_loose_path(source, &path, oid);
|
||||
return check_and_freshen_file(path.buf, freshen);
|
||||
}
|
||||
|
||||
int format_object_header(char *str, size_t size, enum object_type type,
|
||||
size_t objsize)
|
||||
{
|
||||
|
|
@ -815,12 +806,6 @@ static int write_loose_object(struct odb_source *source,
|
|||
FOF_SKIP_COLLISION_CHECK);
|
||||
}
|
||||
|
||||
int odb_source_loose_freshen_object(struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
return !!check_and_freshen_source(source, oid, 1);
|
||||
}
|
||||
|
||||
int odb_source_loose_write_stream(struct odb_source *source,
|
||||
struct odb_write_stream *in_stream, size_t len,
|
||||
struct object_id *oid)
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa
|
|||
struct object_info;
|
||||
struct odb_source;
|
||||
|
||||
int odb_source_loose_freshen_object(struct odb_source *source,
|
||||
const struct object_id *oid);
|
||||
|
||||
int odb_source_loose_write_object(struct odb_source *source,
|
||||
const void *buf, unsigned long len,
|
||||
enum object_type type, struct object_id *oid,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue