From bef128892d621ac56e215963086056a464aae46b Mon Sep 17 00:00:00 2001 From: Jo <10510431+j178@users.noreply.github.com> Date: Sat, 24 May 2025 23:05:38 +0800 Subject: [PATCH] Set `LC_ALL=C` for git when checking git worktree (#13637) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Closes #13612 We check if the git error message includes `not a git repository` to figure out if the path isn't a Git repo or if Git's broken. This PR sets `LC_ALL=C` when invoking `git rev-parse --is-inside-work-tree` so that the error message doesn’t change based on the user’s locale settings. --- crates/uv/src/commands/project/init.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index 91e2fdc0c..376e8e007 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -24,6 +24,7 @@ use uv_python::{ use uv_resolver::RequiresPython; use uv_scripts::{Pep723Script, ScriptTag}; use uv_settings::PythonInstallMirrors; +use uv_static::EnvVars; use uv_warnings::warn_user_once; use uv_workspace::pyproject_mut::{DependencyTarget, PyProjectTomlMut}; use uv_workspace::{DiscoveryOptions, MemberDiscovery, Workspace, WorkspaceCache, WorkspaceError}; @@ -1235,6 +1236,7 @@ fn detect_git_repository(path: &Path) -> GitDiscoveryResult { let Ok(output) = Command::new(git) .arg("rev-parse") .arg("--is-inside-work-tree") + .env(EnvVars::LC_ALL, "C") .current_dir(path) .output() else {