From ceb8826f0a5acf8a23a40a6af6d172ee164edb24 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 6 Dec 2023 13:52:15 +0100 Subject: [PATCH] feat!: add `Context::stderr` to configure whether or not to supress `stderr`. --- gix-command/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gix-command/src/lib.rs b/gix-command/src/lib.rs index b5baec40842..e23275e738e 100644 --- a/gix-command/src/lib.rs +++ b/gix-command/src/lib.rs @@ -68,6 +68,10 @@ pub struct Context { /// If `true`, set `GIT_ICASE_PATHSPECS` to `1`, to let patterns match case-insensitively, or `0` otherwise. /// If `None`, the variable won't be set. pub icase_pathspecs: Option, + /// If `true`, inherit `stderr` just like it's the default when spawning processes. + /// If `false`, suppress all stderr output. + /// If not `None`, this will override any value set with [`Prepare::stderr()`]. + pub stderr: Option, } mod prepare { @@ -237,6 +241,9 @@ mod prepare { if let Some(value) = ctx.icase_pathspecs { cmd.env("GIT_ICASE_PATHSPECS", usize::from(value).to_string()); } + if let Some(stderr) = ctx.stderr { + cmd.stderr(if stderr { Stdio::inherit() } else { Stdio::null() }); + } } cmd }