pub struct Submodule<'repo> { /* private fields */ }
attributes
only.Expand description
A stand-in for the submodule of a particular name.
Implementations§
source§impl<'repo> Submodule<'repo>
impl<'repo> Submodule<'repo>
Access
sourcepub fn path(&self) -> Result<Cow<'_, BStr>, Error>
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().
sourcepub fn url(&self) -> Result<Url, Error>
pub fn url(&self) -> Result<Url, Error>
Return the url from which to clone or update the submodule.
sourcepub fn update(&self) -> Result<Option<Update>, Error>
pub fn update(&self) -> Result<Option<Update>, Error>
Return the update
field from this submodule’s configuration, if present, or None
.
sourcepub fn branch(&self) -> Result<Option<Branch>, Error>
pub fn branch(&self) -> Result<Option<Branch>, Error>
Return the branch
field from this submodule’s configuration, if present, or None
.
sourcepub fn fetch_recurse(&self) -> Result<Option<FetchRecurse>, Error>
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.
sourcepub fn ignore(&self) -> Result<Option<Ignore>, Error>
pub fn ignore(&self) -> Result<Option<Ignore>, Error>
Return the ignore
field from this submodule’s configuration, if present, or None
.
sourcepub fn shallow(&self) -> Result<Option<bool>, Error>
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.
sourcepub fn is_active(&self) -> Result<bool, Error>
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.
sourcepub fn index_id(&self) -> Result<Option<ObjectId>, Error>
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.
sourcepub fn head_id(&self) -> Result<Option<ObjectId>, Error>
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.
sourcepub fn git_dir(&self) -> PathBuf
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.
sourcepub fn work_dir(&self) -> Result<PathBuf, Error>
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.
sourcepub fn git_dir_try_old_form(&self) -> Result<PathBuf, Error>
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.
sourcepub fn state(&self) -> Result<State, Error>
pub fn state(&self) -> Result<State, Error>
Query various parts of the submodule and assemble it into state information.
sourcepub fn open(&self) -> Result<Option<Repository>, Error>
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.