Skip to content

Commit 1370a14

Browse files
committed
handle ENOEXEC
1 parent 7c8b6bc commit 1370a14

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

git2-hooks/src/hookspath.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,28 @@ impl HookPaths {
109109
let hook = self.hook.clone();
110110
log::trace!("run hook '{:?}' in '{:?}'", hook, self.pwd);
111111

112-
let mut command = if cfg!(windows) {
112+
let run_command = |mut command: Command| {
113+
command
114+
.args(args)
115+
.current_dir(&self.pwd)
116+
.with_no_window()
117+
.output()
118+
};
119+
120+
let output = if cfg!(windows) {
113121
// execute hook with sh
114-
sh_command(&hook)
122+
run_command(sh_command(&hook))
115123
} else {
116124
// execute hook directly
117-
Command::new(&hook)
118-
};
119-
120-
let output = command
121-
.args(args)
122-
.current_dir(&self.pwd)
123-
.with_no_window()
124-
.output()?;
125+
match run_command(Command::new(&hook)) {
126+
Err(err) if err.raw_os_error() == Some(8) => {
127+
run_command(sh_command(&hook))
128+
}
129+
result => result,
130+
}
131+
}?;
125132

126133
if output.status.success() {
127-
eprintln!("{}", String::from_utf8_lossy(&output.stdout));
128134
Ok(HookResult::Ok { hook })
129135
} else {
130136
let stderr =

0 commit comments

Comments
 (0)