Struct git_ref::file::Store

source ·
pub struct Store {
    pub write_reflog: WriteReflog,
    pub namespace: Option<Namespace>,
    /* private fields */
}
Expand description

A store for reference which uses plain files.

Each ref is represented as a single file on disk in a folder structure that follows the relative path used to identify references.

Fields§

§write_reflog: WriteReflog

The way to handle reflog edits

§namespace: Option<Namespace>

The namespace to use for edits and reads

Implementations§

Return the .git directory at which all references are loaded.

For worktrees, this is the linked work-tree private ref location, then common_dir() is Some(parent_git_dir).

If this is a linked work tree, there will be Some(git_dir) pointing to the parent repository, while git_dir() points to the location holding linked work-tree private references.

Similar to common_dir(), but it will produce either the common-dir, or the git-dir if the former isn’t present.

This is also the directory in which the packed references file would be placed.

Returns true if a reflog exists for the given reference name.

Please note that this method shouldn’t be used to check if a log exists before trying to read it, but instead is meant to be the fastest possible way to determine if a log exists or not. If the caller needs to know if it’s readable, try to read the log instead with a reverse or forward iterator.

Return a reflog reverse iterator for the given fully qualified name, reading chunks from the back into the fixed buffer buf.

The iterator will traverse log entries from most recent to oldest, reading the underlying file in chunks from the back. Return Ok(None) if no reflog exists.

Return a reflog forward iterator for the given fully qualified name and write its file contents into buf.

The iterator will traverse log entries from oldest to newest. Return Ok(None) if no reflog exists.

Return an iterator over all loose references, notably not including any packed ones, in lexical order. Each of the references may fail to parse and the iterator will not stop if parsing fails, allowing the caller to see all files that look like references whether valid or not.

Reference files that do not constitute valid names will be silently ignored.

Return an iterator over all loose references that start with the given prefix.

Otherwise it’s similar to loose_iter().

Create a new instance at the given git_dir, which commonly is a standard git repository with a refs/ subdirectory. The object_hash defines which kind of hash we should recognize.

Like at(), but for linked work-trees which use git_dir as private ref store and common_dir for shared references.

Return a platform to obtain iterator over all references, or prefixed ones, loose or packed, sorted by their name.

Errors are returned similarly to what would happen when loose and packed refs where iterated by themselves.

Return an iterator over all references, loose or packed, sorted by their name.

Errors are returned similarly to what would happen when loose and packed refs where iterated by themeselves.

As iter(…), but filters by prefix, i.e. “refs/heads”.

Please note that “refs/heads` or “refs\heads” is equivalent to “refs/heads/”

Similar to file::Store::try_find() but a non-existing ref is treated as error.

Similar to file::Store::find(), but supports a stable packed buffer.

Similar to file::Store::find() won’t handle packed-refs.

Find a single reference by the given path which is required to be a valid reference name.

Returns Ok(None) if no such ref exists.

Note

Similar to file::Store::find() but a non-existing ref is treated as error.

Find only loose references, that is references that aren’t in the packed-refs buffer. All symbolic references are loose references. HEAD is always a loose reference.

Similar to file::Store::find(), but allows to pass a snapshotted packed buffer instead.

Edits

Open a transaction with the given edits, and determine how to fail if a lock cannot be obtained. A snapshot of packed references will be obtained automatically if needed to fulfill this transaction and will be provided as result of a successful transaction. Note that upon transaction failure, packed-refs will never have been altered.

The transaction inherits the parent namespace.

Try to open a new packed buffer. It’s not an error if it doesn’t exist, but yields Ok(None).

Return a possibly cached packed buffer with shared ownership. At retrieval it will assure it’s up to date, but after that it can be considered a snapshot as it cannot change anymore.

Use this to make successive calls to file::Store::try_find_packed() or obtain iterators using file::Store::iter_packed() in a way that assures the packed-refs content won’t change.

Return the path at which packed-refs would usually be stored

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.