Struct gix::Submodule

source ·
pub struct Submodule<'repo> { /* private fields */ }
Available on crate feature attributes only.
Expand description

A stand-in for the submodule of a particular name.

Implementations§

source§

impl<'repo> Submodule<'repo>

Access

source

pub fn name(&self) -> &BStr

Return the submodule’s name.

source

pub fn path(&self) -> Result<Cow<'_, BStr>, Error>

Return the path at which the submodule can be found, relative to the repository.

For details, see gix_submodule::File::path().

source

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

Return the url from which to clone or update the submodule.

source

pub fn update(&self) -> Result<Option<Update>, Error>

Return the update field from this submodule’s configuration, if present, or None.

source

pub fn branch(&self) -> Result<Option<Branch>, Error>

Return the branch field from this submodule’s configuration, if present, or None.

source

pub fn fetch_recurse(&self) -> Result<Option<FetchRecurse>, Error>

Return the fetchRecurseSubmodules field from this submodule’s configuration, or retrieve the value from fetch.recurseSubmodules if unset.

source

pub fn ignore(&self) -> Result<Option<Ignore>, Error>

Return the ignore field from this submodule’s configuration, if present, or None.

source

pub fn shallow(&self) -> Result<Option<bool>, Error>

Return the shallow field from this submodule’s configuration, if present, or None.

If true, the submodule will be checked out with depth = 1. If unset, false is assumed.

source

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

Returns true if this submodule is considered active and can thus participate in an operation.

Please see the plumbing crate documentation for details.

source

pub fn index_id(&self) -> Result<Option<ObjectId>, Error>

Return the object id of the submodule as stored in the index of the superproject, or None if it was deleted from the index.

If None, but Some() when calling Self::head_id(), then the submodule was just deleted but the change wasn’t yet committed. Note that None is also returned if the entry at the submodule path isn’t a submodule. If Some(), but None when calling Self::head_id(), then the submodule was just added without having committed the change.

source

pub fn head_id(&self) -> Result<Option<ObjectId>, Error>

Return the object id of the submodule as stored in HEAD^{tree} of the superproject, or None if it wasn’t yet committed.

If Some(), but None when calling Self::index_id(), then the submodule was just deleted but the change wasn’t yet committed. Note that None is also returned if the entry at the submodule path isn’t a submodule. If None, but Some() when calling Self::index_id(), then the submodule was just added without having committed the change.

source

pub fn git_dir(&self) -> PathBuf

Return the path at which the repository of the submodule should be located.

The directory might not exist yet.

source

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

Return the path to the location at which the workdir would be checked out.

Note that it may be a path relative to the repository if, for some reason, the parent directory doesn’t have a working dir set.

source

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

Return the path at which the repository of the submodule should be located, or the path inside of the superproject’s worktree where it actually is located if the submodule in the ‘old-form’, thus is a directory inside of the superproject’s work-tree.

Note that ‘old-form’ paths returned aren’t verified, i.e. the .git repository might be corrupt or otherwise invalid - it’s left to the caller to try to open it.

Also note that the returned path may not actually exist.

source

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

Query various parts of the submodule and assemble it into state information.

source

pub fn open(&self) -> Result<Option<Repository>, Error>

Open the submodule as repository, or None if the submodule wasn’t initialized yet.

More states can be derived here:

  • initialized - a repository exists, i.e. Some(repo) and the working tree is present.
  • uninitialized - a repository does not exist, i.e. None
  • deinitialized - a repository does exist, i.e. Some(repo), but its working tree is empty.

Also see the state() method for learning about the submodule. The repository can also be used to learn about the submodule HEAD, i.e. where its working tree is at, which may differ compared to the superproject’s index or HEAD commit.

Trait Implementations§

source§

impl<'repo> Clone for Submodule<'repo>

source§

fn clone(&self) -> Submodule<'repo>

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

Auto Trait Implementations§

§

impl<'repo> !RefUnwindSafe for Submodule<'repo>

§

impl<'repo> !Send for Submodule<'repo>

§

impl<'repo> !Sync for Submodule<'repo>

§

impl<'repo> Unpin for Submodule<'repo>

§

impl<'repo> !UnwindSafe for Submodule<'repo>

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.