node: Run git fetch without any user config

This commit is contained in:
Alexis Sellier 2023-01-30 12:35:08 +01:00
parent 258d2d35e4
commit 0726c553da
No known key found for this signature in database
3 changed files with 12 additions and 0 deletions

View File

@ -235,6 +235,7 @@ pub mod daemon {
let child = Command::new("git")
.env_clear()
.envs(env::vars().filter(|(k, _)| k == "PATH" || k.starts_with("GIT")))
.envs(radicle::git::env::GIT_RESET)
.env("GIT_PROTOCOL", "version=2")
.current_dir(storage)
.arg("daemon")

View File

@ -153,6 +153,7 @@ impl<G: Signer + EcSign + 'static> Worker<G> {
cmd.current_dir(repo.path())
.env_clear()
.envs(env::vars().filter(|(k, _)| k == "PATH" || k.starts_with("GIT_TRACE")))
.envs(git::env::GIT_RESET)
.args(["-c", "protocol.version=2"])
.arg("fetch")
.arg("--verbose");

View File

@ -507,6 +507,16 @@ pub mod url {
}
}
/// Git environment variables.
pub mod env {
/// Set of environment vars to reset git's configuration to default.
pub const GIT_RESET: [(&str, &str); 3] = [
("GIT_CONFIG", "/dev/null"),
("GIT_CONFIG_GLOBAL", "/dev/null"),
("GIT_CONFIG_NOSYSTEM", "1"),
];
}
#[cfg(test)]
mod test {
use super::*;