Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Breaking Changes

#### Shell
* use default shell instead of bash on Unix-like OS [[@yerke](https://github.com/yerke)] ([#2343](https://github.com/extrawurst/gitui/pull/2343))

### Fixes
* respect env vars like `GIT_CONFIG_GLOBAL` ([#2298](https://github.com/extrawurst/gitui/issues/2298))

Expand Down
14 changes: 10 additions & 4 deletions git2-hooks/src/hookspath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use git2::Repository;
use crate::{error::Result, HookResult, HooksError};

use std::{
path::Path, path::PathBuf, process::Command, str::FromStr,
env, path::Path, path::PathBuf, process::Command, str::FromStr,
};

pub struct HookPaths {
Expand Down Expand Up @@ -113,9 +113,10 @@ impl HookPaths {

log::trace!("run hook '{:?}' in '{:?}'", hook, self.pwd);

let git_bash = find_bash_executable()
.unwrap_or_else(|| PathBuf::from("bash"));
let output = Command::new(git_bash)
let git_shell = find_bash_executable()
.or_else(find_default_unix_shell)
.unwrap_or_else(|| "bash".into());
let output = Command::new(git_shell)
.args(bash_args)
.current_dir(&self.pwd)
// This call forces Command to handle the Path environment correctly on windows,
Expand Down Expand Up @@ -191,3 +192,8 @@ fn find_bash_executable() -> Option<PathBuf> {
None
}
}

// Find default shell on Unix-like OS.
fn find_default_unix_shell() -> Option<PathBuf> {
env::var_os("SHELL").map(PathBuf::from)
}