Skip to content

Commit

Permalink
fix: stdout from hooks
Browse files Browse the repository at this point in the history
This repairs a regression that appeared in StGit 2.4.3 where the stdout from hooks would
not be output into the user's terminal.

This was due to gix_command::prepare() piping stdout by default.

Fixes: #418
  • Loading branch information
jpgrayson committed Feb 17, 2024
1 parent be50a99 commit a3637ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ pub(crate) fn run_pre_commit_hook(repo: &gix::Repository, use_editor: bool) -> R

let work_dir = repo.work_dir().expect("not a bare repo");

let mut hook_command = std::process::Command::from(gix_command::prepare(hook_path));
let mut hook_command = std::process::Command::from(
gix_command::prepare(hook_path).stdout(std::process::Stdio::inherit()),
);
hook_command.current_dir(work_dir);
if !use_editor {
hook_command.env("GIT_EDITOR", ":");
Expand Down Expand Up @@ -117,7 +119,9 @@ pub(crate) fn run_commit_msg_hook<'repo>(

// TODO: when git runs this hook, it only sets GIT_INDEX_FILE and sometimes
// GIT_EDITOR. So author and committer vars are not clearly required.
let mut hook_command = std::process::Command::from(gix_command::prepare(hook_path));
let mut hook_command = std::process::Command::from(
gix_command::prepare(hook_path).stdout(std::process::Stdio::inherit()),
);
hook_command.current_dir(work_dir);
hook_command.env("GIT_INDEX_FILE", &index_path);
if !use_editor {
Expand Down

0 comments on commit a3637ba

Please sign in to comment.