Struct git_ref::file::Store [−][src]
pub struct Store {
pub base: PathBuf,
pub write_reflog: WriteReflog,
pub namespace: Option<Namespace>,
}
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
base: PathBuf
The location at which loose references can be found as per conventions of a typical git repository.
Typical base paths are .git
repository folders.
write_reflog: WriteReflog
The way to handle reflog edits
namespace: Option<Namespace>
The namespace to use for edits and reads
Implementations
pub fn reflog_exists<'a, Name, E>(&self, name: Name) -> Result<bool, E> where
Name: TryInto<FullNameRef<'a>, Error = E>,
Error: From<E>,
pub fn reflog_exists<'a, Name, E>(&self, name: Name) -> Result<bool, E> where
Name: TryInto<FullNameRef<'a>, Error = E>,
Error: From<E>,
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 file system 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.
Note
There is no namespace support in loose file iterators. It can be emulated using loose_iter_prefixed(…)
.
See Store::packed()
for interacting with packed references.
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.
Return an iterator over all references, loose or packed
, sorted by their name.
Note that the caller is responsible for the freshness of the packed
references buffer.
If a reference cannot be parsed or read, the error will be visible to the caller and the iteration
continues.
Errors are returned similarly to what would happen when loose and packed refs where iterated by themeselves.
pub fn iter_prefixed<'p, 's>(
&'s self,
packed: Option<&'p Buffer>,
prefix: impl AsRef<Path>
) -> Result<LooseThenPacked<'p, 's>>
pub fn iter_prefixed<'p, 's>(
&'s self,
packed: Option<&'p Buffer>,
prefix: impl AsRef<Path>
) -> Result<LooseThenPacked<'p, 's>>
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::find()
but a non-existing ref is treated as error.
pub fn find_loose<'a, Name, E>(&self, partial: Name) -> Result<Reference, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
pub fn find_loose<'a, Name, E>(&self, partial: Name) -> Result<Reference, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
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.
If packed
is provided, the reference search will extend to the packed buffer created with packed()
.
Note that the caller is responsible for its freshness, i.e. assuring it wasn’t modified since it was read.
Returns Ok(None)
if no such ref exists.
Note
- The lookup algorithm follows the one in the git documentation.
- Namespaced names will only be found if they are fully qualified. They can, however, be found during iteration.
This shortcoming can be fixed if there is demand by introducing
try_find_in_namespace(…)
or by lettingPartialNameRef
have a namespace reference, too.
pub fn try_find_loose<'a, Name, E>(
&self,
partial: Name
) -> Result<Option<Reference>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
pub fn try_find_loose<'a, Name, E>(
&self,
partial: Name
) -> Result<Option<Reference>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
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.
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.
Return a buffer for the packed file
Return the path at which packed-refs would usually be stored
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Store
impl UnwindSafe for Store
Blanket Implementations
Mutably borrows from an owned value. Read more