From 20ef4e99149ef8a1255d02d8e60ff30c90fd9bff Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 15 Aug 2024 04:39:30 -0700 Subject: [PATCH 1/2] run `git config -l` in temp dir when looking up system config Commit a9a3545db2b2 made `gix::config::File::from_globals()` try to find the system config (typically `/etc/config`) by subprocessing to `git config -l --show-origin`. That command takes about 500 ms when run in certain directories in our VFS at Google. Since we don't need anything but the system config, let's run the command in the system's temporary directory instead. I also added `--system` for good measure. I've confirmed that just adding `--system` is not enough, however - `git config -l --system --show-origin` is still slow in our VFS. --- gix-path/src/env/git/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gix-path/src/env/git/mod.rs b/gix-path/src/env/git/mod.rs index a24e26ecb47..677a9011d5d 100644 --- a/gix-path/src/env/git/mod.rs +++ b/gix-path/src/env/git/mod.rs @@ -1,3 +1,4 @@ +use std::env; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; @@ -88,7 +89,8 @@ pub(super) static EXE_INFO: Lazy> = Lazy::new(|| { const CREATE_NO_WINDOW: u32 = 0x08000000; cmd.creation_flags(CREATE_NO_WINDOW); } - cmd.args(["config", "-l", "--show-origin"]) + cmd.args(["config", "-l", "--system", "--show-origin"]) + .current_dir(env::temp_dir()) .stdin(Stdio::null()) .stderr(Stdio::null()); cmd From 6b1c2432f096b3de770a77694a23b93b8d29dc8d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 15 Aug 2024 17:15:52 +0200 Subject: [PATCH 2/2] remove `--system` from `git config` call as it fails on MacOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` ❯ which git /usr/bin/git gitbutler ( missing-project) [$] via  ❯ git --version git version 2.39.3 (Apple Git-146) gitbutler ( missing-project) [$] via  ❯ git config -l --system --show-origin fatal: unable to read config file '/etc/gitconfig': No such file or directory ``` --- gix-path/src/env/git/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gix-path/src/env/git/mod.rs b/gix-path/src/env/git/mod.rs index 677a9011d5d..f99c3ba871c 100644 --- a/gix-path/src/env/git/mod.rs +++ b/gix-path/src/env/git/mod.rs @@ -89,7 +89,7 @@ pub(super) static EXE_INFO: Lazy> = Lazy::new(|| { const CREATE_NO_WINDOW: u32 = 0x08000000; cmd.creation_flags(CREATE_NO_WINDOW); } - cmd.args(["config", "-l", "--system", "--show-origin"]) + cmd.args(["config", "-l", "--show-origin"]) .current_dir(env::temp_dir()) .stdin(Stdio::null()) .stderr(Stdio::null());