Skip to content

Commit 2762724

Browse files
committed
feat: add gitoxide.core.externalCommandStderr to allow enabling stderr to the enclosing terminal.
Previously, this was enabled by default, now it can additionally be disabled by the caller.
1 parent ceb8826 commit 2762724

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

gix/src/config/cache/init.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ fn apply_environment_overrides(
441441
let key = &gitoxide::Core::REFS_NAMESPACE;
442442
(env(key), key.name)
443443
},
444+
{
445+
let key = &gitoxide::Core::EXTERNAL_COMMAND_STDERR;
446+
(env(key), key.name)
447+
},
444448
],
445449
),
446450
(

gix/src/config/tree/sections/gitoxide.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ mod subsections {
116116
pub const FILTER_PROCESS_DELAY: keys::Boolean =
117117
keys::Boolean::new_boolean("filterProcessDelay", &Gitoxide::CORE);
118118

119+
/// The `gitoxide.core.externalCommandStderr` key (default `true`).
120+
///
121+
/// If `true`, the default, `stderr` of worktree filter programs, or any other git-context bearing command
122+
/// invoked will be inherited.
123+
/// If `false`, it will be suppressed completely.
124+
pub const EXTERNAL_COMMAND_STDERR: keys::Boolean =
125+
keys::Boolean::new_boolean("externalCommandStderr", &Gitoxide::CORE)
126+
.with_environment_override("GIX_EXTERNAL_COMMAND_STDERR");
127+
119128
/// The `gitoxide.core.refsNamespace` key.
120129
pub const REFS_NAMESPACE: RefsNamespace =
121130
keys::Any::new_with_validate("refsNamespace", &Gitoxide::CORE, super::validate::RefsNamespace)
@@ -134,6 +143,7 @@ mod subsections {
134143
&Self::USE_STDEV,
135144
&Self::SHALLOW_FILE,
136145
&Self::FILTER_PROCESS_DELAY,
146+
&Self::EXTERNAL_COMMAND_STDERR,
137147
&Self::REFS_NAMESPACE,
138148
]
139149
}

gix/src/repository/config/mod.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,27 @@ impl crate::Repository {
8888
tree::{gitoxide, Key},
8989
};
9090

91-
let boolean = |key: &dyn Key| {
91+
let pathspec_boolean = |key: &'static config::tree::keys::Boolean| {
9292
self.config
9393
.resolved
9494
.boolean("gitoxide", Some("pathspec".into()), key.name())
95+
.map(|value| key.enrich_error(value))
9596
.transpose()
9697
.with_leniency(self.config.lenient_config)
9798
};
9899

99100
Ok(gix_command::Context {
101+
stderr: {
102+
let key = &gitoxide::Core::EXTERNAL_COMMAND_STDERR;
103+
self.config
104+
.resolved
105+
.boolean("gitoxide", Some("core".into()), key.name())
106+
.map(|value| key.enrich_error(value))
107+
.transpose()
108+
.with_leniency(self.config.lenient_config)?
109+
.unwrap_or(true)
110+
.into()
111+
},
100112
git_dir: self.git_dir().to_owned().into(),
101113
worktree_dir: self.work_dir().map(ToOwned::to_owned),
102114
no_replace_objects: config::shared::is_replace_refs_enabled(
@@ -106,9 +118,10 @@ impl crate::Repository {
106118
)?
107119
.map(|enabled| !enabled),
108120
ref_namespace: self.refs.namespace.as_ref().map(|ns| ns.as_bstr().to_owned()),
109-
literal_pathspecs: boolean(&gitoxide::Pathspec::LITERAL)?,
110-
glob_pathspecs: boolean(&gitoxide::Pathspec::GLOB)?.or(boolean(&gitoxide::Pathspec::NOGLOB)?),
111-
icase_pathspecs: boolean(&gitoxide::Pathspec::ICASE)?,
121+
literal_pathspecs: pathspec_boolean(&gitoxide::Pathspec::LITERAL)?,
122+
glob_pathspecs: pathspec_boolean(&gitoxide::Pathspec::GLOB)?
123+
.or(pathspec_boolean(&gitoxide::Pathspec::NOGLOB)?),
124+
icase_pathspecs: pathspec_boolean(&gitoxide::Pathspec::ICASE)?,
112125
})
113126
}
114127

gix/tests/gix-init.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ mod with_overrides {
4141
.set("GIX_PACK_CACHE_MEMORY", "0")
4242
.set("GIX_OBJECT_CACHE_MEMORY", "5m")
4343
.set("GIX_CREDENTIALS_HELPER_STDERR", "creds-stderr")
44+
.set("GIX_EXTERNAL_COMMAND_STDERR", "filter-stderr")
4445
.set("GIT_SSL_CAINFO", "./env.pem")
4546
.set("GIT_SSL_VERSION", "tlsv1.3")
4647
.set("GIT_SSH_VARIANT", "ssh-variant-env")
@@ -256,6 +257,7 @@ mod with_overrides {
256257
("gitoxide.pathspec.literal", "pathspecs-literal"),
257258
("gitoxide.credentials.terminalPrompt", "42"),
258259
("gitoxide.credentials.helperStderr", "creds-stderr"),
260+
("gitoxide.core.externalCommandStderr", "filter-stderr"),
259261
] {
260262
assert_eq!(
261263
config

0 commit comments

Comments
 (0)