mirror of
https://github.com/git/git.git
synced 2026-08-09 01:21:47 +00:00
odb/source-packed: wire up close() callback
Wire up a new `close()` callback for the packed source and call it from the "files" source via the generic `odb_source_close()` interface. 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
0de2467e6c
commit
4f35c8b060
@@ -38,7 +38,7 @@ static void odb_source_files_close(struct odb_source *source)
|
||||
{
|
||||
struct odb_source_files *files = odb_source_files_downcast(source);
|
||||
odb_source_close(&files->loose->base);
|
||||
packfile_store_close(files->packed);
|
||||
odb_source_close(&files->packed->base);
|
||||
}
|
||||
|
||||
static void odb_source_files_reprepare(struct odb_source *source)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "abspath.h"
|
||||
#include "chdir-notify.h"
|
||||
#include "midx.h"
|
||||
#include "odb/source-packed.h"
|
||||
#include "packfile.h"
|
||||
|
||||
@@ -16,6 +17,20 @@ static void odb_source_packed_reparent(const char *name UNUSED,
|
||||
packed->base.path = path;
|
||||
}
|
||||
|
||||
static void odb_source_packed_close(struct odb_source *source)
|
||||
{
|
||||
struct odb_source_packed *packed = odb_source_packed_downcast(source);
|
||||
|
||||
for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next) {
|
||||
if (e->pack->do_not_close)
|
||||
BUG("want to close pack marked 'do-not-close'");
|
||||
close_pack(e->pack);
|
||||
}
|
||||
if (packed->midx)
|
||||
close_midx(packed->midx);
|
||||
packed->midx = NULL;
|
||||
}
|
||||
|
||||
static void odb_source_packed_free(struct odb_source *source)
|
||||
{
|
||||
struct odb_source_packed *packed = odb_source_packed_downcast(source);
|
||||
@@ -42,6 +57,7 @@ struct odb_source_packed *odb_source_packed_new(struct odb_source_files *parent)
|
||||
strmap_init(&packed->packs_by_path);
|
||||
|
||||
packed->base.free = odb_source_packed_free;
|
||||
packed->base.close = odb_source_packed_close;
|
||||
|
||||
if (!is_absolute_path(parent->base.path))
|
||||
chdir_notify_register(NULL, odb_source_packed_reparent, packed);
|
||||
|
||||
12
packfile.c
12
packfile.c
@@ -2749,18 +2749,6 @@ int parse_pack_header_option(const char *in, unsigned char *out, unsigned int *l
|
||||
return 0;
|
||||
}
|
||||
|
||||
void packfile_store_close(struct odb_source_packed *store)
|
||||
{
|
||||
for (struct packfile_list_entry *e = store->packs.head; e; e = e->next) {
|
||||
if (e->pack->do_not_close)
|
||||
BUG("want to close pack marked 'do-not-close'");
|
||||
close_pack(e->pack);
|
||||
}
|
||||
if (store->midx)
|
||||
close_midx(store->midx);
|
||||
store->midx = NULL;
|
||||
}
|
||||
|
||||
struct odb_packed_read_stream {
|
||||
struct odb_read_stream base;
|
||||
struct packed_git *pack;
|
||||
|
||||
@@ -55,12 +55,6 @@ struct packed_git {
|
||||
char pack_name[FLEX_ARRAY]; /* more */
|
||||
};
|
||||
|
||||
/*
|
||||
* Close all packfiles associated with this store. The packfiles won't be
|
||||
* free'd, so they can be re-opened at a later point in time.
|
||||
*/
|
||||
void packfile_store_close(struct odb_source_packed *store);
|
||||
|
||||
/*
|
||||
* Prepare the packfile store by loading packfiles and multi-pack indices for
|
||||
* all alternates. This becomes a no-op if the store is already prepared.
|
||||
|
||||
Reference in New Issue
Block a user