pub struct Reference<'r> {
pub inner: Reference,
/* private fields */
}
Expand description
A reference that points to an object or reference, with access to its source repository.
Note that these are snapshots and won’t recognize if they are stale.
Fields§
§inner: Reference
The actual reference data
Implementations§
source§impl<'repo> Reference<'repo>
impl<'repo> Reference<'repo>
Remotes
sourcepub fn remote_name(&self, direction: Direction) -> Option<Name<'repo>>
pub fn remote_name(&self, direction: Direction) -> Option<Name<'repo>>
Find the name of our remote for direction
as configured in branch.<name>.remote|pushRemote
respectively.
Return None
if no remote is configured.
See also Repository::branch_remote_name()
for more details.
sourcepub fn remote(
&self,
direction: Direction
) -> Option<Result<Remote<'repo>, Error>>
pub fn remote( &self, direction: Direction ) -> Option<Result<Remote<'repo>, Error>>
Find the remote along with all configuration associated with it suitable for handling this reference.
See also Repository::branch_remote()
for more details.
sourcepub fn remote_ref_name(
&self,
direction: Direction
) -> Option<Result<Cow<'_, FullNameRef>, Error>>
pub fn remote_ref_name( &self, direction: Direction ) -> Option<Result<Cow<'_, FullNameRef>, Error>>
Return the name of this reference on the remote side.
See Repository::branch_remote_ref_name()
for details.
sourcepub fn remote_tracking_ref_name(
&self,
direction: Direction
) -> Option<Result<Cow<'_, FullNameRef>, Error>>
pub fn remote_tracking_ref_name( &self, direction: Direction ) -> Option<Result<Cow<'_, FullNameRef>, Error>>
Return the name of the reference that tracks this reference on the remote side.
See Repository::branch_remote_tracking_ref_name()
for details.
source§impl<'repo> Reference<'repo>
impl<'repo> Reference<'repo>
sourcepub fn set_target_id(
&mut self,
id: impl Into<ObjectId>,
reflog_message: impl Into<BString>
) -> Result<(), Error>
pub fn set_target_id( &mut self, id: impl Into<ObjectId>, reflog_message: impl Into<BString> ) -> Result<(), Error>
Set the id of this direct reference to id
and use reflog_message
for the reflog (if enabled in the repository).
Note that the operation will fail on symbolic references, to change their type use the lower level reference database,
or if the reference was deleted or changed in the mean time.
Furthermore, refrain from using this method for more than a one-off change as it creates a transaction for each invocation.
If multiple reference should be changed, use Repository::edit_references()
or the lower level reference database instead.
source§impl<'repo> Reference<'repo>
impl<'repo> Reference<'repo>
Access
sourcepub fn try_id(&self) -> Option<Id<'repo>>
pub fn try_id(&self) -> Option<Id<'repo>>
Returns the attached id we point to, or None
if this is a symbolic ref.
sourcepub fn id(&self) -> Id<'repo>
pub fn id(&self) -> Id<'repo>
Returns the attached id we point to, or panic if this is a symbolic ref.
sourcepub fn name(&self) -> &FullNameRef
pub fn name(&self) -> &FullNameRef
Return the reference’s full name.
source§impl<'repo> Reference<'repo>
impl<'repo> Reference<'repo>
Peeling
sourcepub fn peel_to_id_in_place(&mut self) -> Result<Id<'repo>, Error>
pub fn peel_to_id_in_place(&mut self) -> Result<Id<'repo>, Error>
Follow all symbolic targets this reference might point to and peel the underlying object to the end of the chain, and return it.
This is useful to learn where this reference is ultimately pointing to.
sourcepub fn into_fully_peeled_id(self) -> Result<Id<'repo>, Error>
pub fn into_fully_peeled_id(self) -> Result<Id<'repo>, Error>
Similar to peel_to_id_in_place()
, but consumes this instance.