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
impl Submodule
Sourcepub fn list(repo: &Repository) -> Result<Vec<SubmoduleEntry>>
pub fn list(repo: &Repository) -> Result<Vec<SubmoduleEntry>>
Every configured submodule, in the order git lists them.
Equivalent to git submodule status.
Sourcepub fn add(repo: &Repository, url: &str, path: &str) -> Result<()>
pub fn add(repo: &Repository, url: &str, path: &str) -> Result<()>
Add a submodule at path from url.
Equivalent to git submodule add <url> <path>.
Sourcepub fn update(repo: &Repository, path: Option<&str>) -> Result<()>
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.
Sourcepub fn sync(repo: &Repository, path: Option<&str>) -> Result<()>
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.
Sourcepub fn remove(repo: &Repository, path: &str) -> Result<()>
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.