From 7ed5d42696e338b76b24a583e213bb6390f18316 Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Thu, 11 Dec 2025 11:17:13 +0800 Subject: [PATCH] git: Fix git hook hang with `prek` (#44212) Fix git hook hang when using with `prek`. Can see [comments](https://github.com/zed-industries/zed/issues/44057#issuecomment-3606837089), this is easy test, should using release build, debug build sometimes not hang. The issue existing long time, see issue #37293 , and then in commit #42239 this issue had fixed. but in commit #43285 broken again. So I reference the implementation in #42239, then this code work. I MUST CLAIM, I really don't known what happend, and why this code work. But it worked. Release Notes: - N/A --------- Co-authored-by: Cole Miller --- crates/git/src/repository.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 6477917dcdc485a5f2d23f16f3a5b3d7f94e9597..9f77ddc7cfc8e9e8d4ebca836e12f86496dc7c0b 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -2318,6 +2318,7 @@ impl GitRepository for RealGitRepository { let executor = self.executor.clone(); let help_output = self.any_git_binary_help_output(); + // Note: Do not spawn these commands on the background thread, as this causes some git hooks to hang. async move { let working_directory = working_directory?; if !help_output @@ -2327,14 +2328,10 @@ impl GitRepository for RealGitRepository { { let hook_abs_path = repository.lock().path().join("hooks").join(hook.as_str()); if hook_abs_path.is_file() { - let output = self - .executor - .spawn( - new_smol_command(&hook_abs_path) - .envs(env.iter()) - .current_dir(&working_directory) - .output(), - ) + let output = new_smol_command(&hook_abs_path) + .envs(env.iter()) + .current_dir(&working_directory) + .output() .await?; if !output.status.success() {