Files
git/odb/source-loose.h
Patrick Steinhardt f211a3f0b5 odb/source: drop local flag
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>
2026-10-15 07:23:46 -07:00

53 lines
1.5 KiB
C

#ifndef ODB_SOURCE_LOOSE_H
#define ODB_SOURCE_LOOSE_H
#include "odb/source.h"
struct odb_source_files;
struct object_database;
struct oidtree;
/*
* An object database source that stores its objects in loose format, one
* file per object.
*/
struct odb_source_loose {
struct odb_source base;
/*
* Used to store the results of readdir(3) calls when we are OK
* sacrificing accuracy due to races for speed. That includes
* object existence with OBJECT_INFO_QUICK, as well as
* our search for unique abbreviated hashes. Don't use it for tasks
* requiring greater accuracy!
*
* Be sure to call odb_load_loose_cache() before using.
*/
uint32_t subdir_seen[8]; /* 256 bits */
struct oidtree *cache;
/* Map between object IDs for loose objects. */
struct loose_object_map *map;
/* Whether this is a source that will never be committed to disk. */
int will_destroy;
};
struct odb_source_loose *odb_source_loose_new(struct object_database *odb,
const char *path);
/*
* Cast the given object database source to the loose backend. This will cause
* a BUG in case the source doesn't use this backend.
*/
static inline struct odb_source_loose *odb_source_loose_downcast(struct odb_source *source)
{
if (source->type != ODB_SOURCE_LOOSE)
BUG("trying to downcast source of type '%s' to '%s'",
odb_source_type_to_name(source->type),
odb_source_type_to_name(ODB_SOURCE_LOOSE));
return container_of(source, struct odb_source_loose, base);
}
#endif