Struct git_repository::Reference
source · [−]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
sourceimpl<'repo> Reference<'repo>
impl<'repo> Reference<'repo>
Remotes
sourcepub fn remote_name(&self, direction: Direction) -> Option<Cow<'repo, str>>
pub fn remote_name(&self, direction: Direction) -> Option<Cow<'repo, str>>
Find the 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
.
sourceimpl<'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.
sourceimpl<'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.
sourceimpl<'repo> Reference<'repo>
impl<'repo> Reference<'repo>
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 ulitmately 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.
Trait Implementations
Auto Trait Implementations
impl<'r> !RefUnwindSafe for Reference<'r>
impl<'r> !Send for Reference<'r>
impl<'r> !Sync for Reference<'r>
impl<'r> Unpin for Reference<'r>
impl<'r> !UnwindSafe for Reference<'r>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more