Skip to content

Commit a40541e

Browse files
committed
feat(gix): support diff.ignoreSubmodules overrides in status
1 parent 04a18f3 commit a40541e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

gix/src/status/index_worktree.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ mod submodule_status {
247247
SubmoduleStatus(#[from] crate::submodule::status::Error),
248248
#[error(transparent)]
249249
IgnoreConfig(#[from] crate::submodule::config::Error),
250+
#[error("The value of 'diff.submoduleIgnore' was invalid: '{actual}'")]
251+
DiffSubmoduleIgnoreConfig { actual: BString },
250252
}
251253

252254
impl gix_status::index_as_worktree::traits::SubmoduleStatus for BuiltinSubmoduleStatus {
@@ -275,7 +277,20 @@ mod submodule_status {
275277
return Ok(None);
276278
};
277279
let (ignore, check_dirty) = match self.mode {
278-
Submodule::AsConfigured { check_dirty } => (sm.ignore()?.unwrap_or_default(), check_dirty),
280+
Submodule::AsConfigured { check_dirty } => {
281+
// diff.ignoreSubmodules is the global setting, and if it exists, it overrides the submodule's own ignore setting.
282+
let global_ignore = repo.config_snapshot().string("diff.ignoreSubmodules");
283+
if let Some(ignore_str) = global_ignore {
284+
let ignore = ignore_str.as_ref().try_into().map_err(|_| Error::DiffSubmoduleIgnoreConfig {
285+
actual: ignore_str.into_owned(),
286+
})?;
287+
(ignore, check_dirty)
288+
} else {
289+
// If no global ignore is set, use the submodule's ignore setting.
290+
let ignore = sm.ignore()?.unwrap_or_default();
291+
(ignore, check_dirty)
292+
}
293+
}
279294
Submodule::Given { ignore, check_dirty } => (ignore, check_dirty),
280295
};
281296
let status = sm.status(ignore, check_dirty)?;

gix/src/status/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ where
2020
/// How to obtain a submodule's status.
2121
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
2222
pub enum Submodule {
23-
/// Use the ['ignore' value](crate::Submodule::ignore) to determine which submodules
24-
/// participate in the status query, and to which extent.
23+
/// Use the `diff.submoduleIgnore` configuration to determine, or if not set,
24+
/// use the submodule's own ['ignore' value](crate::Submodule::ignore) to determine
25+
/// which submodules participate in the status query, and to which extent.
2526
AsConfigured {
2627
/// If `true`, default `false`, the computation will stop once the first in a ladder operations
2728
/// ordered from cheap to expensive shows that the submodule is dirty.

0 commit comments

Comments
 (0)