mirror of
https://github.com/git/git.git
synced 2026-10-26 16:15:26 +01: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>
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#include "git-compat-util.h"
|
|
#include "object-file.h"
|
|
#include "odb/source-files.h"
|
|
#include "odb/source.h"
|
|
#include "packfile.h"
|
|
|
|
static const char * const odb_source_names_by_type[] = {
|
|
[ODB_SOURCE_UNKNOWN] = "unknown",
|
|
[ODB_SOURCE_FILES] = "files",
|
|
[ODB_SOURCE_LOOSE] = "loose",
|
|
[ODB_SOURCE_PACKED] = "packed",
|
|
[ODB_SOURCE_INMEMORY] = "in-memory",
|
|
};
|
|
|
|
const char *odb_source_type_to_name(enum odb_source_type type)
|
|
{
|
|
const char *name;
|
|
if (type < 0 || type >= ARRAY_SIZE(odb_source_names_by_type))
|
|
type = ODB_SOURCE_UNKNOWN;
|
|
name = odb_source_names_by_type[type];
|
|
if (!name)
|
|
BUG("name missing in `odb_source_names_by_type` for '%d'", type);
|
|
return name;
|
|
}
|
|
|
|
struct odb_source *odb_source_new(struct object_database *odb,
|
|
enum odb_new_flags flags)
|
|
{
|
|
return &odb_source_files_new(odb, flags)->base;
|
|
}
|
|
|
|
void odb_source_init(struct odb_source *source,
|
|
struct object_database *odb,
|
|
enum odb_source_type type,
|
|
const char *path)
|
|
{
|
|
source->odb = odb;
|
|
source->type = type;
|
|
source->path = xstrdup(path);
|
|
}
|
|
|
|
void odb_source_free(struct odb_source *source)
|
|
{
|
|
if (!source)
|
|
return;
|
|
source->free(source);
|
|
}
|
|
|
|
void odb_source_release(struct odb_source *source)
|
|
{
|
|
if (!source)
|
|
return;
|
|
free(source->path);
|
|
}
|