Skip to content

Commit 6582499

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

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

gix/src/status/index_worktree.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ pub struct BuiltinSubmoduleStatus {
204204

205205
///
206206
mod submodule_status {
207+
use crate::bstr::BString;
207208
use std::borrow::Cow;
208209

209210
use crate::{
@@ -247,6 +248,8 @@ mod submodule_status {
247248
SubmoduleStatus(#[from] crate::submodule::status::Error),
248249
#[error(transparent)]
249250
IgnoreConfig(#[from] crate::submodule::config::Error),
251+
#[error("The value of 'diff.submoduleIgnore' was invalid: '{actual}'")]
252+
DiffSubmoduleIgnoreConfig { actual: BString },
250253
}
251254

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