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 unvalidated name of our remote for direction
as configured in branch.<name>.remote|pushRemote
respectively.
If Some(<name>)
it can be used in Repository::find_remote(…)
, or if None
then
Repository::remote_default_name()
could be used in its place.
Return None
if no remote is configured.
Note
- it’s recommended to use the
remote(…)
method as it will configure the remote with additional information. branch.<name>.pushRemote
falls back tobranch.<name>.remote
.
sourcepub fn remote(
&self,
direction: Direction
) -> Option<Result<Remote<'repo>, Error>>
pub fn remote( &self, direction: Direction ) -> Option<Result<Remote<'repo>, Error>>
Like remote_name(…)
, but configures the returned Remote
with additional information like
branch.<name>.merge
to know which branch on the remote side corresponds to this one for merging when pulling.
It also handles if the remote is a configured URL, which has no name.
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.