odb/source-loose: wire up `reprepare()` callback
Move `odb_source_loose_reprepare()` from "object-file.c" into "odb/source-loose.c" and wire it up as the `reprepare()` callback of the loose source. While at it, make `odb_source_loose_clear_cache()` static, as it is no longer needed outside of its file. 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
a2b7db9bc8d52f133fe8fcb317788d9fe8696f07
5 files changed
+9
-13
object-file.c
-6
@@ -2041,12 +2041,6 @@ static struct oidtree *odb_source_loose_cache(struct odb_source *source,
2041
return files->loose->cache;
2042
}
2043
2044
-void odb_source_loose_reprepare(struct odb_source *source)
2045
-{
2046
- struct odb_source_files *files = odb_source_files_downcast(source);
2047
- odb_source_loose_clear_cache(files->loose);
2048
-}
2049
-
2044
static int check_stream_oid(git_zstream *stream,
2045
const char *hdr,
2046
unsigned long size,
object-file.h
-3
@@ -21,9 +21,6 @@ struct object_info;
21
struct odb_read_stream;
22
struct odb_source;
23
24
-/* Reprepare the loose source by emptying the loose object cache. */
25
-void odb_source_loose_reprepare(struct odb_source *source);
26
-
24
int odb_source_loose_read_object_info(struct odb_source *source,
25
const struct object_id *oid,
26
struct object_info *oi,
odb/source-files.c
+1
-1
@@ -42,7 +42,7 @@ static void odb_source_files_close(struct odb_source *source)
42
static void odb_source_files_reprepare(struct odb_source *source)
43
{
44
struct odb_source_files *files = odb_source_files_downcast(source);
45
- odb_source_loose_reprepare(&files->base);
45
+ odb_source_reprepare(&files->loose->base);
46
packfile_store_reprepare(files->packed);
47
}
48
odb/source-loose.c
+8
-1
@@ -7,7 +7,7 @@
7
#include "odb/source-loose.h"
8
#include "oidtree.h"
9
10
-void odb_source_loose_clear_cache(struct odb_source_loose *loose)
10
+static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
11
{
12
oidtree_clear(loose->cache);
13
FREE_AND_NULL(loose->cache);
@@ -15,6 +15,12 @@ void odb_source_loose_clear_cache(struct odb_source_loose *loose)
15
sizeof(loose->subdir_seen));
16
}
17
18
+static void odb_source_loose_reprepare(struct odb_source *source)
19
+{
20
+ struct odb_source_loose *loose = odb_source_loose_downcast(source);
21
+ odb_source_loose_clear_cache(loose);
22
+}
23
+
24
static void odb_source_loose_reparent(const char *name UNUSED,
25
const char *old_cwd,
26
const char *new_cwd,
@@ -47,6 +53,7 @@ struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files)
53
loose->files = files;
54
55
loose->base.free = odb_source_loose_free;
56
+ loose->base.reprepare = odb_source_loose_reprepare;
57
58
if (!is_absolute_path(loose->base.path))
59
chdir_notify_register(NULL, odb_source_loose_reparent, loose);
odb/source-loose.h
-2
@@ -44,6 +44,4 @@ static inline struct odb_source_loose *odb_source_loose_downcast(struct odb_sour
44
return container_of(source, struct odb_source_loose, base);
45
}
46
47
-void odb_source_loose_clear_cache(struct odb_source_loose *loose);
48
-
47
#endif