Struct git2::Reference [−][src]
pub struct Reference<'repo> { /* fields omitted */ }
A structure to represent a git reference.
Methods
impl<'repo> Reference<'repo>
[src]
impl<'repo> Reference<'repo>
pub fn is_valid_name(refname: &str) -> bool
[src]
pub fn is_valid_name(refname: &str) -> bool
Ensure the reference name is well-formed.
pub fn raw(&self) -> *mut git_reference
[src]
pub fn raw(&self) -> *mut git_reference
Get access to the underlying raw pointer.
pub fn delete(&mut self) -> Result<(), Error>
[src]
pub fn delete(&mut self) -> Result<(), Error>
Delete an existing reference.
This method works for both direct and symbolic references. The reference will be immediately removed on disk.
This function will return an error if the reference has changed from the time it was looked up.
pub fn is_branch(&self) -> bool
[src]
pub fn is_branch(&self) -> bool
Check if a reference is a local branch.
pub fn is_note(&self) -> bool
[src]
pub fn is_note(&self) -> bool
Check if a reference is a note.
pub fn is_remote(&self) -> bool
[src]
pub fn is_remote(&self) -> bool
Check if a reference is a remote tracking branch
pub fn is_tag(&self) -> bool
[src]
pub fn is_tag(&self) -> bool
Check if a reference is a tag
pub fn kind(&self) -> Option<ReferenceType>
[src]
pub fn kind(&self) -> Option<ReferenceType>
Get the reference type of a reference.
If the type is unknown, then None
is returned.
pub fn name(&self) -> Option<&str>
[src]
pub fn name(&self) -> Option<&str>
Get the full name of a reference.
Returns None
if the name is not valid utf-8.
pub fn name_bytes(&self) -> &[u8]
[src]
pub fn name_bytes(&self) -> &[u8]
Get the full name of a reference.
pub fn shorthand(&self) -> Option<&str>
[src]
pub fn shorthand(&self) -> Option<&str>
Get the full shorthand of a reference.
This will transform the reference name into a name "human-readable" version. If no shortname is appropriate, it will return the full name.
Returns None
if the shorthand is not valid utf-8.
pub fn shorthand_bytes(&self) -> &[u8]
[src]
pub fn shorthand_bytes(&self) -> &[u8]
Get the full shorthand of a reference.
pub fn target(&self) -> Option<Oid>
[src]
pub fn target(&self) -> Option<Oid>
Get the OID pointed to by a direct reference.
Only available if the reference is direct (i.e. an object id reference, not a symbolic one).
pub fn target_peel(&self) -> Option<Oid>
[src]
pub fn target_peel(&self) -> Option<Oid>
Return the peeled OID target of this reference.
This peeled OID only applies to direct references that point to a hard Tag object: it is the result of peeling such Tag.
pub fn symbolic_target(&self) -> Option<&str>
[src]
pub fn symbolic_target(&self) -> Option<&str>
Get full name to the reference pointed to by a symbolic reference.
May return None
if the reference is either not symbolic or not a
valid utf-8 string.
pub fn symbolic_target_bytes(&self) -> Option<&[u8]>
[src]
pub fn symbolic_target_bytes(&self) -> Option<&[u8]>
Get full name to the reference pointed to by a symbolic reference.
Only available if the reference is symbolic.
pub fn resolve(&self) -> Result<Reference<'repo>, Error>
[src]
pub fn resolve(&self) -> Result<Reference<'repo>, Error>
Resolve a symbolic reference to a direct reference.
This method iteratively peels a symbolic reference until it resolves to a direct reference to an OID.
If a direct reference is passed as an argument, a copy of that reference is returned.
pub fn peel(&self, kind: ObjectType) -> Result<Object<'repo>, Error>
[src]
pub fn peel(&self, kind: ObjectType) -> Result<Object<'repo>, Error>
Peel a reference to an object
This method recursively peels the reference until it reaches an object of the specified type.
pub fn peel_to_blob(&self) -> Result<Blob<'repo>, Error>
[src]
pub fn peel_to_blob(&self) -> Result<Blob<'repo>, Error>
Peel a reference to a blob
This method recursively peels the reference until it reaches a blob.
pub fn peel_to_commit(&self) -> Result<Commit<'repo>, Error>
[src]
pub fn peel_to_commit(&self) -> Result<Commit<'repo>, Error>
Peel a reference to a commit
This method recursively peels the reference until it reaches a blob.
pub fn peel_to_tree(&self) -> Result<Tree<'repo>, Error>
[src]
pub fn peel_to_tree(&self) -> Result<Tree<'repo>, Error>
Peel a reference to a tree
This method recursively peels the reference until it reaches a blob.
pub fn peel_to_tag(&self) -> Result<Tag<'repo>, Error>
[src]
pub fn peel_to_tag(&self) -> Result<Tag<'repo>, Error>
Peel a reference to a tag
This method recursively peels the reference until it reaches a tag.
pub fn rename(
&mut self,
new_name: &str,
force: bool,
msg: &str
) -> Result<Reference<'repo>, Error>
[src]
pub fn rename(
&mut self,
new_name: &str,
force: bool,
msg: &str
) -> Result<Reference<'repo>, Error>
Rename an existing reference.
This method works for both direct and symbolic references.
If the force flag is not enabled, and there's already a reference with the given name, the renaming will fail.
pub fn set_target(
&mut self,
id: Oid,
reflog_msg: &str
) -> Result<Reference<'repo>, Error>
[src]
pub fn set_target(
&mut self,
id: Oid,
reflog_msg: &str
) -> Result<Reference<'repo>, Error>
Conditionally create a new reference with the same name as the given reference but a different OID target. The reference must be a direct reference, otherwise this will fail.
The new reference will be written to disk, overwriting the given reference.
Trait Implementations
impl<'repo> PartialOrd for Reference<'repo>
[src]
impl<'repo> PartialOrd for Reference<'repo>
fn partial_cmp(&self, other: &Reference<'repo>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Reference<'repo>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'repo> Ord for Reference<'repo>
[src]
impl<'repo> Ord for Reference<'repo>
fn cmp(&self, other: &Reference<'repo>) -> Ordering
[src]
fn cmp(&self, other: &Reference<'repo>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<'repo> PartialEq for Reference<'repo>
[src]
impl<'repo> PartialEq for Reference<'repo>
fn eq(&self, other: &Reference<'repo>) -> bool
[src]
fn eq(&self, other: &Reference<'repo>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'repo> Eq for Reference<'repo>
[src]
impl<'repo> Eq for Reference<'repo>
impl<'repo> Drop for Reference<'repo>
[src]
impl<'repo> Drop for Reference<'repo>