Skip to main content

Submodule

Struct Submodule 

Source
pub struct Submodule;
Expand description

Submodule operations — list, add, update, sync, remove.

Uses the git CLI. update and add reach the network; the rest are local.

Implementations§

Source§

impl Submodule

Source

pub fn list(repo: &Repository) -> Result<Vec<SubmoduleEntry>>

Every configured submodule, in the order git lists them.

Equivalent to git submodule status.

Source

pub fn add(repo: &Repository, url: &str, path: &str) -> Result<()>

Add a submodule at path from url.

Equivalent to git submodule add <url> <path>.

Source

pub fn update(repo: &Repository, path: Option<&str>) -> Result<()>

Initialise and check out a submodule at the recorded commit (None = all of them).

Equivalent to git submodule update --init --recursive [<path>] — magit’s p populate, r register and u update collapsed into the one that subsumes them. Reaches the network for a submodule that has never been cloned.

Source

pub fn sync(repo: &Repository, path: Option<&str>) -> Result<()>

Re-copy the configured URLs into the submodules’ own git config (None = all of them).

Equivalent to git submodule sync --recursive [<path>]. What you run after the superproject’s .gitmodules URLs changed.

Source

pub fn remove(repo: &Repository, path: &str) -> Result<()>

Remove a submodule: deinit it, then drop it from the index and the working tree.

git submodule deinit -f followed by git rm -f. This deletes the submodule’s working tree, including anything uncommitted inside it, which is why callers confirm first.

The deinit runs first and its failure is fatal: git rm on a still-populated submodule leaves the checkout orphaned in .git/modules with nothing in the index pointing at it.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.