268 lines
9.8 KiB
C
268 lines
9.8 KiB
C
#ifndef REFS_REF_CACHE_H
|
|
#define REFS_REF_CACHE_H
|
|
|
|
struct ref_dir;
|
|
|
|
/*
|
|
* If this ref_cache is filled lazily, this function is used to load
|
|
* information into the specified ref_dir (shallow or deep, at the
|
|
* option of the ref_store). dirname includes a trailing slash.
|
|
*/
|
|
typedef void fill_ref_dir_fn(struct ref_store *ref_store,
|
|
struct ref_dir *dir, const char *dirname);
|
|
|
|
struct ref_cache {
|
|
struct ref_entry *root;
|
|
|
|
/* A pointer to the ref_store whose cache this is: */
|
|
struct ref_store *ref_store;
|
|
|
|
/*
|
|
* Function used (if necessary) to lazily-fill cache. May be
|
|
* NULL.
|
|
*/
|
|
fill_ref_dir_fn *fill_ref_dir;
|
|
};
|
|
|
|
/*
|
|
* Information used (along with the information in ref_entry) to
|
|
* describe a single cached reference. This data structure only
|
|
* occurs embedded in a union in struct ref_entry, and only when
|
|
* (ref_entry->flag & REF_DIR) is zero.
|
|
*/
|
|
struct ref_value {
|
|
/*
|
|
* The name of the object to which this reference resolves
|
|
* (which may be a tag object). If REF_ISBROKEN, this is
|
|
* null. If REF_ISSYMREF, then this is the name of the object
|
|
* referred to by the last reference in the symlink chain.
|
|
*/
|
|
struct object_id oid;
|
|
|
|
/*
|
|
* If REF_KNOWS_PEELED, then this field holds the peeled value
|
|
* of this reference, or null if the reference is known not to
|
|
* be peelable. See the documentation for peel_ref() for an
|
|
* exact definition of "peelable".
|
|
*/
|
|
struct object_id peeled;
|
|
};
|
|
|
|
/*
|
|
* Information used (along with the information in ref_entry) to
|
|
* describe a level in the hierarchy of references. This data
|
|
* structure only occurs embedded in a union in struct ref_entry, and
|
|
* only when (ref_entry.flag & REF_DIR) is set. In that case,
|
|
* (ref_entry.flag & REF_INCOMPLETE) determines whether the references
|
|
* in the directory have already been read:
|
|
*
|
|
* (ref_entry.flag & REF_INCOMPLETE) unset -- a directory of loose
|
|
* or packed references, already read.
|
|
*
|
|
* (ref_entry.flag & REF_INCOMPLETE) set -- a directory of loose
|
|
* references that hasn't been read yet (nor has any of its
|
|
* subdirectories).
|
|
*
|
|
* Entries within a directory are stored within a growable array of
|
|
* pointers to ref_entries (entries, nr, alloc). Entries 0 <= i <
|
|
* sorted are sorted by their component name in strcmp() order and the
|
|
* remaining entries are unsorted.
|
|
*
|
|
* Loose references are read lazily, one directory at a time. When a
|
|
* directory of loose references is read, then all of the references
|
|
* in that directory are stored, and REF_INCOMPLETE stubs are created
|
|
* for any subdirectories, but the subdirectories themselves are not
|
|
* read. The reading is triggered by get_ref_dir().
|
|
*/
|
|
struct ref_dir {
|
|
int nr, alloc;
|
|
|
|
/*
|
|
* Entries with index 0 <= i < sorted are sorted by name. New
|
|
* entries are appended to the list unsorted, and are sorted
|
|
* only when required; thus we avoid the need to sort the list
|
|
* after the addition of every reference.
|
|
*/
|
|
int sorted;
|
|
|
|
/* The ref_cache containing this entry: */
|
|
struct ref_cache *cache;
|
|
|
|
struct ref_entry **entries;
|
|
};
|
|
|
|
/*
|
|
* Bit values for ref_entry::flag. REF_ISSYMREF=0x01,
|
|
* REF_ISPACKED=0x02, REF_ISBROKEN=0x04 and REF_BAD_NAME=0x08 are
|
|
* public values; see refs.h.
|
|
*/
|
|
|
|
/*
|
|
* The field ref_entry->u.value.peeled of this value entry contains
|
|
* the correct peeled value for the reference, which might be
|
|
* null_sha1 if the reference is not a tag or if it is broken.
|
|
*/
|
|
#define REF_KNOWS_PEELED 0x10
|
|
|
|
/* ref_entry represents a directory of references */
|
|
#define REF_DIR 0x20
|
|
|
|
/*
|
|