From 0726c553dac48490d44f67716dd398e093b68d3c Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Mon, 30 Jan 2023 12:35:08 +0100 Subject: [PATCH] node: Run git fetch without any user config --- radicle-node/src/runtime.rs | 1 + radicle-node/src/worker.rs | 1 + radicle/src/git.rs | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/radicle-node/src/runtime.rs b/radicle-node/src/runtime.rs index 41719c52..599bbea9 100644 --- a/radicle-node/src/runtime.rs +++ b/radicle-node/src/runtime.rs @@ -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") diff --git a/radicle-node/src/worker.rs b/radicle-node/src/worker.rs index 4ca00ee7..613b9341 100644 --- a/radicle-node/src/worker.rs +++ b/radicle-node/src/worker.rs @@ -153,6 +153,7 @@ impl Worker { 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"); diff --git a/radicle/src/git.rs b/radicle/src/git.rs index 4025de98..ab9e70c6 100644 --- a/radicle/src/git.rs +++ b/radicle/src/git.rs @@ -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::*;