diff --git a/crates/prek/src/cli/run/keeper.rs b/crates/prek/src/cli/run/keeper.rs
index 4484bbe95..fd326a5e7 100644
--- a/crates/prek/src/cli/run/keeper.rs
+++ b/crates/prek/src/cli/run/keeper.rs
@@ -59,7 +59,8 @@ impl IntentToAddRestorer {
fn restore(&self) -> Result<()> {
// Restore the intent-to-add changes.
if !self.0.is_empty() {
- Command::new(GIT.as_ref()?)
+ let mut cmd = Command::new(GIT.as_ref()?);
+ git::apply_git_work_tree(&mut cmd)
.arg("add")
.arg("--intent-to-add")
.arg("--")
@@ -154,7 +155,8 @@ impl UnstagedChangesRestorer {
}
fn checkout_working_tree(root: &Path) -> Result<()> {
- let output = Command::new(GIT.as_ref()?)
+ let mut cmd = Command::new(GIT.as_ref()?);
+ let output = git::apply_git_work_tree(&mut cmd)
.arg("-c")
.arg("submodule.recurse=0")
.arg("checkout")
@@ -173,7 +175,8 @@ impl UnstagedChangesRestorer {
}
fn git_apply(patch: &Path) -> Result<()> {
- let output = Command::new(GIT.as_ref()?)
+ let mut cmd = Command::new(GIT.as_ref()?);
+ let output = git::apply_git_work_tree(&mut cmd)
.arg("apply")
.arg("--whitespace=nowarn")
.arg(patch)
diff --git a/crates/prek/src/cli/update/repository.rs b/crates/prek/src/cli/update/repository.rs
index 3a6cdae5c..1bef19323 100644
--- a/crates/prek/src/cli/update/repository.rs
+++ b/crates/prek/src/cli/update/repository.rs
@@ -14,6 +14,7 @@ use semver::Version;
use tracing::{debug, trace};
use crate::cli::update::{CommitPresence, RevisionSelection, SkippedDowngrade, TagTimestamp};
+use crate::git::GitCommandExt;
use crate::{config, git};
/// Initializes a temporary git repo and fetches the remote HEAD plus tags.
@@ -27,7 +28,7 @@ pub(super) async fn setup_and_fetch_repo(repo_url: &str, repo_path: &Path) -> Re
.arg("--filter=blob:none")
.arg("--tags")
.current_dir(repo_path)
- .remove_git_envs()
+ .isolate_from_git_env()
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
@@ -43,7 +44,7 @@ pub(super) async fn resolve_revision_to_commit(repo_path: &Path, rev: &str) -> R
.arg(format!("{rev}^{{}}"))
.check(true)
.current_dir(repo_path)
- .remove_git_envs()
+ .isolate_from_git_env()
.output()
.await?;
@@ -83,7 +84,7 @@ pub(super) async fn is_commit_present(repo_path: &Path, commit: &str) -> Result<
.env(EnvVars::LC_ALL, "C")
.check(false)
.current_dir(repo_path)
- .remove_git_envs()
+ .isolate_from_git_env()
.stdout(Stdio::null())
.output()
.await?;
@@ -127,7 +128,7 @@ pub(super) async fn resolve_bleeding_edge(repo_path: &Path) -> Result