Trait git_repository::prelude::ReferenceAccessExt [−][src]
pub trait ReferenceAccessExt: Access + Sized {
fn tag_reference(
&self,
name: impl AsRef<str>,
target: impl Into<ObjectId>,
constraint: PreviousValue
) -> Result<Reference<'_, Self>, Error> { ... }
fn namespace(&self) -> Option<&Namespace> { ... }
fn clear_namespace(&mut self) -> Option<Namespace> { ... }
fn set_namespace<'a, Name, E>(
&mut self,
namespace: Name
) -> Result<Option<Namespace>, Error>
where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
{ ... }
fn reference<Name, E>(
&self,
name: Name,
target: impl Into<ObjectId>,
constraint: PreviousValue,
log_message: impl Into<BString>
) -> Result<Reference<'_, Self>, Error>
where
Name: TryInto<FullName, Error = E>,
Error: From<E>,
{ ... }
fn edit_reference(
&self,
edit: RefEdit,
lock_mode: Fail,
log_committer: Option<&Signature>
) -> Result<Vec<RefEdit>, Error> { ... }
fn edit_references(
&self,
edits: impl IntoIterator<Item = RefEdit>,
lock_mode: Fail,
log_committer: Option<&Signature>
) -> Result<Vec<RefEdit>, Error> { ... }
fn head(&self) -> Result<Head<'_, Self>, Error> { ... }
fn find_reference<'a, Name, E>(
&self,
name: Name
) -> Result<Reference<'_, Self>, Error>
where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
{ ... }
fn references(&self) -> Result<Platform<'_, Self>, Error> { ... }
fn try_find_reference<'a, Name, E>(
&self,
name: Name
) -> Result<Option<Reference<'_, Self>>, Error>
where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
{ ... }
}
Expand description
Obtain and alter references comfortably
Provided methods
fn tag_reference(
&self,
name: impl AsRef<str>,
target: impl Into<ObjectId>,
constraint: PreviousValue
) -> Result<Reference<'_, Self>, Error>
fn tag_reference(
&self,
name: impl AsRef<str>,
target: impl Into<ObjectId>,
constraint: PreviousValue
) -> Result<Reference<'_, Self>, Error>
Create a lightweight tag with given name
(and without refs/tags/
prefix) pointing to the given target
, and return it as reference.
It will be created with constraint
which is most commonly to only create it
or to force overwriting a possibly existing tag.
Returns the currently set namespace for references, or None
if it is not set.
Namespaces allow to partition references, and is configured per Easy
.
fn clear_namespace(&mut self) -> Option<Namespace>
fn clear_namespace(&mut self) -> Option<Namespace>
Remove the currently set reference namespace and return it, affecting only this Easy
.
fn set_namespace<'a, Name, E>(
&mut self,
namespace: Name
) -> Result<Option<Namespace>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
fn set_namespace<'a, Name, E>(
&mut self,
namespace: Name
) -> Result<Option<Namespace>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
Set the reference namespace to the given value, like "foo"
or "foo/bar"
.
Note that this value is shared across all Easy…
instances as the value is stored in the shared Repository
.
Create a new reference with name
, like refs/heads/branch
, pointing to target
, adhering to constraint
during creation and writing log_message
into the reflog. Note that a ref-log will be written even if log_message
is empty.
The newly created Reference is returned.
Edit a single reference as described in edit
, handle locks via lock_mode
and write reference logs as log_committer
.
One or more RefEdit
s are returned - symbolic reference splits can cause more edits to be performed. All edits have the previous
reference values set to the ones encountered at rest after acquiring the respective reference’s lock.
Edit one or more references as described by their edits
, with lock_mode
deciding on how to handle competing
transactions. log_committer
is the name appearing in reference logs.
Returns all reference edits, which might be more than where provided due the splitting of symbolic references, and whose previous (old) values are the ones seen on in storage after the reference was locked.
Return the repository head, an abstraction to help dealing with the HEAD
reference.
The HEAD
reference can be in various states, for more information, the documentation of Head
.
fn find_reference<'a, Name, E>(
&self,
name: Name
) -> Result<Reference<'_, Self>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
fn find_reference<'a, Name, E>(
&self,
name: Name
) -> Result<Reference<'_, Self>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
Find the reference with the given partial or full name
, like main
, HEAD
, heads/branch
or origin/other
,
or return an error if it wasn’t found.
Consider try_find_reference(…)
if the reference might not exist
without that being considered an error.
fn references(&self) -> Result<Platform<'_, Self>, Error>
fn references(&self) -> Result<Platform<'_, Self>, Error>
fn try_find_reference<'a, Name, E>(
&self,
name: Name
) -> Result<Option<Reference<'_, Self>>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
fn try_find_reference<'a, Name, E>(
&self,
name: Name
) -> Result<Option<Reference<'_, Self>>, Error> where
Name: TryInto<PartialNameRef<'a>, Error = E>,
Error: From<E>,
Try to find the reference named name
, like main
, heads/branch
, HEAD
or origin/other
, and return it.
Otherwise return None
if the reference wasn’t found.
If the reference is expected to exist, use find_reference()
.