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>main
parent
ead691927b
commit
a2b7db9bc8
|
|
@ -2041,12 +2041,6 @@ static struct oidtree *odb_source_loose_cache(struct odb_source *source,
|
|||
return files->loose->cache;
|
||||
}
|
||||
|
||||
void odb_source_loose_reprepare(struct odb_source *source)
|
||||
{
|
||||
struct odb_source_files *files = odb_source_files_downcast(source);
|
||||
odb_source_loose_clear_cache(files->loose);
|
||||
}
|
||||
|
||||
static int check_stream_oid(git_zstream *stream,
|
||||
const char *hdr,
|
||||
unsigned long size,
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ struct object_info;
|
|||
struct odb_read_stream;
|
||||
struct odb_source;
|
||||
|
||||
/* Reprepare the loose source by emptying the loose object cache. */
|
||||
void odb_source_loose_reprepare(struct odb_source *source);
|
||||
|
||||
int odb_source_loose_read_object_info(struct odb_source *source,
|
||||
const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ static void odb_source_files_close(struct odb_source *source)
|
|||
static void odb_source_files_reprepare(struct odb_source *source)
|
||||
{
|
||||
struct odb_source_files *files = odb_source_files_downcast(source);
|
||||
odb_source_loose_reprepare(&files->base);
|
||||
odb_source_reprepare(&files->loose->base);
|
||||
packfile_store_reprepare(files->packed);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "odb/source-loose.h"
|
||||
#include "oidtree.h"
|
||||
|
||||
void odb_source_loose_clear_cache(struct odb_source_loose *loose)
|
||||
static void odb_source_loose_clear_cache(struct odb_source_loose *loose)
|
||||
{
|
||||
oidtree_clear(loose->cache);
|
||||
FREE_AND_NULL(loose->cache);
|
||||
|
|
@ -15,6 +15,12 @@ void odb_source_loose_clear_cache(struct odb_source_loose *loose)
|
|||
sizeof(loose->subdir_seen));
|
||||
}
|
||||
|
||||
static void odb_source_loose_reprepare(struct odb_source *source)
|
||||
{
|
||||
struct odb_source_loose *loose = odb_source_loose_downcast(source);
|
||||
odb_source_loose_clear_cache(loose);
|
||||
}
|
||||
|
||||
static void odb_source_loose_reparent(const char *name UNUSED,
|
||||
const char *old_cwd,
|
||||
const char *new_cwd,
|
||||
|
|
@ -47,6 +53,7 @@ struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files)
|
|||
loose->files = files;
|
||||
|
||||
loose->base.free = odb_source_loose_free;
|
||||
loose->base.reprepare = odb_source_loose_reprepare;
|
||||
|
||||
if (!is_absolute_path(loose->base.path))
|
||||
chdir_notify_register(NULL, odb_source_loose_reparent, loose);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,4 @@ static inline struct odb_source_loose *odb_source_loose_downcast(struct odb_sour
|
|||
return container_of(source, struct odb_source_loose, base);
|
||||
}
|
||||
|
||||
void odb_source_loose_clear_cache(struct odb_source_loose *loose);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue