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>
Patrick Steinhardt committed
Jun 1, 2026 at 10:20 UTC
d8b9e8bb23ece128179ad54ed5ecbcd4bd809b1e
4 files changed
+10
-19
object-file.c
-15
@@ -87,15 +87,6 @@ int check_and_freshen_file(const char *fn, int freshen)
87
return 1;
88
}
89
90
-static int check_and_freshen_source(struct odb_source *source,
91
- const struct object_id *oid,
92
- int freshen)
93
-{
94
- static struct strbuf path = STRBUF_INIT;
95
- odb_loose_path(source, &path, oid);
96
- return check_and_freshen_file(path.buf, freshen);
97
-}
98
-
90
int format_object_header(char *str, size_t size, enum object_type type,
91
size_t objsize)
92
{
@@ -815,12 +806,6 @@ static int write_loose_object(struct odb_source *source,
806
FOF_SKIP_COLLISION_CHECK);
807
}
808
818
-int odb_source_loose_freshen_object(struct odb_source *source,
819
- const struct object_id *oid)
820
-{
821
- return !!check_and_freshen_source(source, oid, 1);
822
-}
823
-
809
int odb_source_loose_write_stream(struct odb_source *source,
810
struct odb_write_stream *in_stream, size_t len,
811
struct object_id *oid)
object-file.h
-3
@@ -23,9 +23,6 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa
23
struct object_info;
24
struct odb_source;
25
26
-int odb_source_loose_freshen_object(struct odb_source *source,
27
- const struct object_id *oid);
28
-
26
int odb_source_loose_write_object(struct odb_source *source,
27
const void *buf, unsigned long len,
28
enum object_type type, struct object_id *oid,
odb/source-files.c
+1
-1
@@ -152,7 +152,7 @@ static int odb_source_files_freshen_object(struct odb_source *source,
152
{
153
struct odb_source_files *files = odb_source_files_downcast(source);
154
if (packfile_store_freshen_object(files->packed, oid) ||
155
- odb_source_loose_freshen_object(source, oid))
155
+ odb_source_freshen_object(&files->loose->base, oid))
156
return 1;
157
return 0;
158
}
odb/source-loose.c
+9
@@ -580,6 +580,14 @@ out:
580
return ret;
581
}
582
583
+static int odb_source_loose_freshen_object(struct odb_source *source,
584
+ const struct object_id *oid)
585
+{
586
+ static struct strbuf path = STRBUF_INIT;
587
+ odb_loose_path(source, &path, oid);
588
+ return !!check_and_freshen_file(path.buf, 1);
589
+}
590
+
591
static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
592
{
593
oidtree_clear(loose->cache);
@@ -638,6 +646,7 @@ struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files)
646
loose->base.for_each_object = odb_source_loose_for_each_object;
647
loose->base.find_abbrev_len = odb_source_loose_find_abbrev_len;
648
loose->base.count_objects = odb_source_loose_count_objects;
649
+ loose->base.freshen_object = odb_source_loose_freshen_object;
650
651
if (!is_absolute_path(loose->base.path))
652
chdir_notify_register(NULL, odb_source_loose_reparent, loose);