Skip to content

Commit 0e37671

Browse files
use gix_path::env::shell() to get the shell in git2-hooks (#2612)
Co-authored-by: Johannes Agricola <[email protected]>
1 parent 7f88934 commit 0e37671

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

Diff for: Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: git2-hooks/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ keywords = ["git"]
1414

1515
[dependencies]
1616
git2 = ">=0.17"
17+
gix-path = "0.10"
1718
log = "0.4"
1819
shellexpand = "3.1"
1920
thiserror = "2.0"

Diff for: git2-hooks/src/hookspath.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl HookPaths {
225225
}
226226

227227
fn sh_command() -> Command {
228-
let mut command = Command::new(sh_path());
228+
let mut command = Command::new(gix_path::env::shell());
229229

230230
if cfg!(windows) {
231231
// This call forces Command to handle the Path environment correctly on windows,
@@ -243,30 +243,6 @@ fn sh_command() -> Command {
243243
command
244244
}
245245

246-
/// Get the path to the sh executable.
247-
/// On Windows get the sh.exe bundled with Git for Windows
248-
pub fn sh_path() -> PathBuf {
249-
if cfg!(windows) {
250-
Command::new("where.exe")
251-
.arg("git")
252-
.output()
253-
.ok()
254-
.map(|out| {
255-
PathBuf::from(Into::<String>::into(
256-
String::from_utf8_lossy(&out.stdout),
257-
))
258-
})
259-
.as_deref()
260-
.and_then(Path::parent)
261-
.and_then(Path::parent)
262-
.map(|p| p.join("usr/bin/sh.exe"))
263-
.filter(|p| p.exists())
264-
.unwrap_or_else(|| "sh".into())
265-
} else {
266-
"sh".into()
267-
}
268-
}
269-
270246
#[cfg(unix)]
271247
fn is_executable(path: &Path) -> bool {
272248
use std::os::unix::fs::PermissionsExt;

0 commit comments

Comments
 (0)