mirror of
https://github.com/git/git.git
synced 2026-10-03 20:57:21 +02:00
The `struct odb_source::will_destroy` flag tracks whether a source is part of a transaction that we know we'll destruct anyway. If so, the backend can optimize for that particular case, for example by not flushing any data to disk. While the intent is sensible, it assumes that transactions are backed by a separate source that's being linked into the object database. But that may or may not be true, as backends may have significantly better ways to achieve the same. So the assumption doesn't make much sense in the first place, as we're now tracking backend-specific details on the generic `struct odb_source` level. Move the field from the generic source into the "loose" source, as this is the only source that ever makes use of it anyway. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
54 lines
1.5 KiB
C
54 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,
|
|
bool local);
|
|
|
|
/*
|
|
* 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
|