mirror of
https://github.com/git/git.git
synced 2026-10-22 13:15:36 +02:00
The `local` flag indicates whether a given `struct odb_source` is a local source or not, where "local" is defined as being the object directory that is directly attached to the current repository. But now that alternates are handled in the "files" backend, this property is not something that even makes sense anymore to have on the generic source. In fact, we already have a partial replacement for this field in `struct odb_files_dir`. The only other site that requires it is the packed object database source, because it propagates the bit into the packfiles it is opening. Drop the flag from `struct odb_source` and instead move it into the packed source. Note that we stop considering the `local` bit when iterating through all loose objects with the `ODB_FOR_EACH_OBJECT_LOCAL_ONLY` flag. This is fine though, as we already handle the flag in the "files" backend itself, where we skip over any object directory that is not marked as local. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
95 lines
2.7 KiB
C
95 lines
2.7 KiB
C
#ifndef ODB_SOURCE_PACKED_H
|
|
#define ODB_SOURCE_PACKED_H
|
|
|
|
#include "odb/source.h"
|
|
#include "packfile-list.h"
|
|
#include "strmap.h"
|
|
|
|
/*
|
|
* A store that manages packfiles for a given object database.
|
|
*/
|
|
struct odb_source_packed {
|
|
struct odb_source base;
|
|
|
|
/*
|
|
* The list of packfiles in the order in which they have been most
|
|
* recently used.
|
|
*/
|
|
struct packfile_list packs;
|
|
|
|
/*
|
|
* Cache of packfiles which are marked as "kept", either because there
|
|
* is an on-disk ".keep" file or because they are marked as "kept" in
|
|
* memory.
|
|
*
|
|
* Should not be accessed directly, but via
|
|
* `packfile_store_get_kept_pack_cache()`. The list of packs gets
|
|
* invalidated when the stored flags and the flags passed to
|
|
* `packfile_store_get_kept_pack_cache()` mismatch.
|
|
*/
|
|
struct {
|
|
struct packed_git **packs;
|
|
unsigned flags;
|
|
} kept_cache;
|
|
|
|
/* The multi-pack index that belongs to this specific packfile store. */
|
|
struct multi_pack_index *midx;
|
|
|
|
/*
|
|
* A map of packfile names to packed_git structs for tracking which
|
|
* packs have been loaded already.
|
|
*/
|
|
struct strmap packs_by_path;
|
|
|
|
/*
|
|
* Whether this store is part of the local object directory of the
|
|
* owning repository. Packfiles loaded via this store inherit this
|
|
* flag via `pack_local`. Stores for alternates are not local.
|
|
*/
|
|
bool local;
|
|
|
|
/*
|
|
* Whether packfiles have already been populated with this store's
|
|
* packs.
|
|
*/
|
|
bool initialized;
|
|
|
|
/*
|
|
* Usually, packfiles will be reordered to the front of the `packs`
|
|
* list whenever an object is looked up via them. This has the effect
|
|
* that packs that contain a lot of accessed objects will be located
|
|
* towards the front.
|
|
*
|
|
* This is usually desirable, but there are exceptions. One exception
|
|
* is when the looking up multiple objects in a loop for each packfile.
|
|
* In that case, we may easily end up with an infinite loop as the
|
|
* packfiles get reordered to the front repeatedly.
|
|
*
|
|
* Setting this field to `true` thus disables these reorderings.
|
|
*/
|
|
bool skip_mru_updates;
|
|
};
|
|
|
|
/*
|
|
* Allocate and initialize a new empty packfile store for the given object
|
|
* database.
|
|
*/
|
|
struct odb_source_packed *odb_source_packed_new(struct object_database *odb,
|
|
const char *path,
|
|
bool local);
|
|
|
|
/*
|
|
* Cast the given object database source to the packed backend. This will cause
|
|
* a BUG in case the source doesn't use this backend.
|
|
*/
|
|
static inline struct odb_source_packed *odb_source_packed_downcast(struct odb_source *source)
|
|
{
|
|
if (source->type != ODB_SOURCE_PACKED)
|
|
BUG("trying to downcast source of type '%s' to '%s'",
|
|
odb_source_type_to_name(source->type),
|
|
odb_source_type_to_name(ODB_SOURCE_PACKED));
|
|
return container_of(source, struct odb_source_packed, base);
|
|
}
|
|
|
|
#endif
|