Struct gix::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§

source§

impl<'repo> Reference<'repo>

Remotes

source

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 to branch.<name>.remote.
source

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>

source

pub fn log_iter(&self) -> Platform<'_, '_>

Return a platform for obtaining iterators over reference logs.

source

pub fn log_exists(&self) -> bool

Return true if a reflog is present for this reference.

source§

impl<'repo> Reference<'repo>

source

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>

source

pub fn delete(&self) -> Result<(), Error>

Delete this reference or fail if it was changed since last observed. Note that this instance remains available in memory but probably shouldn’t be used anymore.

source§

impl<'repo> Reference<'repo>

Access

source

pub fn try_id(&self) -> Option<Id<'repo>>

Returns the attached id we point to, or None if this is a symbolic ref.

source

pub fn id(&self) -> Id<'repo>

Returns the attached id we point to, or panic if this is a symbolic ref.

source

pub fn target(&self) -> TargetRef<'_>

Return the target to which this reference points to.

source

pub fn name(&self) -> &FullNameRef

Return the reference’s full name.

source

pub fn detach(self) -> Reference

Turn this instances into a stand-alone reference.

source§

impl<'repo> Reference<'repo>

Peeling

source

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.

source

pub fn into_fully_peeled_id(self) -> Result<Id<'repo>, Error>

Similar to peel_to_id_in_place(), but consumes this instance.

source

pub fn follow(&self) -> Option<Result<Reference<'repo>, Error>>

Follow this symbolic reference one level and return the ref it refers to.

Returns None if this is not a symbolic reference, hence the leaf of the chain.

Trait Implementations§

source§

impl<'r> Clone for Reference<'r>

source§

fn clone(&self) -> Reference<'r>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'repo> Debug for Reference<'repo>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.