From d3fd8bf746a8818cc936e33e541b191fef1010c0 Mon Sep 17 00:00:00 2001 From: Joshix Date: Tue, 15 Apr 2025 13:00:00 +0000 Subject: [PATCH 1/2] use gix_path::env::shell() to get the shell --- Cargo.lock | 1 + git2-hooks/Cargo.toml | 1 + git2-hooks/src/hookspath.rs | 26 +------------------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b2a3bedd1..3f22c2ca6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1138,6 +1138,7 @@ version = "0.4.0" dependencies = [ "git2", "git2-testing", + "gix-path", "log", "pretty_assertions", "shellexpand", diff --git a/git2-hooks/Cargo.toml b/git2-hooks/Cargo.toml index 3fab403cd2..72099348b2 100644 --- a/git2-hooks/Cargo.toml +++ b/git2-hooks/Cargo.toml @@ -14,6 +14,7 @@ keywords = ["git"] [dependencies] git2 = ">=0.17" +gix-path = "0.10.15" log = "0.4" shellexpand = "3.1" thiserror = "2.0" diff --git a/git2-hooks/src/hookspath.rs b/git2-hooks/src/hookspath.rs index 1518bfd76f..eabf575ca8 100644 --- a/git2-hooks/src/hookspath.rs +++ b/git2-hooks/src/hookspath.rs @@ -225,7 +225,7 @@ impl HookPaths { } fn sh_command() -> Command { - let mut command = Command::new(sh_path()); + let mut command = Command::new(gix_path::env::shell()); if cfg!(windows) { // This call forces Command to handle the Path environment correctly on windows, @@ -243,30 +243,6 @@ fn sh_command() -> Command { command } -/// Get the path to the sh executable. -/// On Windows get the sh.exe bundled with Git for Windows -pub fn sh_path() -> PathBuf { - if cfg!(windows) { - Command::new("where.exe") - .arg("git") - .output() - .ok() - .map(|out| { - PathBuf::from(Into::::into( - String::from_utf8_lossy(&out.stdout), - )) - }) - .as_deref() - .and_then(Path::parent) - .and_then(Path::parent) - .map(|p| p.join("usr/bin/sh.exe")) - .filter(|p| p.exists()) - .unwrap_or_else(|| "sh".into()) - } else { - "sh".into() - } -} - #[cfg(unix)] fn is_executable(path: &Path) -> bool { use std::os::unix::fs::PermissionsExt; From 674055c08916de9fd56d81ac11e86320737f02b4 Mon Sep 17 00:00:00 2001 From: Joshix-1 <57299889+Joshix-1@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:07:00 +0200 Subject: [PATCH 2/2] Update git2-hooks/Cargo.toml Co-authored-by: Johannes Agricola --- git2-hooks/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git2-hooks/Cargo.toml b/git2-hooks/Cargo.toml index 72099348b2..6bdd0497a9 100644 --- a/git2-hooks/Cargo.toml +++ b/git2-hooks/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["git"] [dependencies] git2 = ">=0.17" -gix-path = "0.10.15" +gix-path = "0.10" log = "0.4" shellexpand = "3.1" thiserror = "2.0"