From b67fabdd62b5ecf0cf1351b9b20a4d9e194cb12a Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Tue, 21 Oct 2025 14:34:27 +0300 Subject: [PATCH] Fix git directory resolution in simulator to support worktrees sim cannot be run in a git worktree on main --- simulator/runner/bugbase.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/simulator/runner/bugbase.rs b/simulator/runner/bugbase.rs index a34847655..89ad25e71 100644 --- a/simulator/runner/bugbase.rs +++ b/simulator/runner/bugbase.rs @@ -470,12 +470,18 @@ impl BugBase { } fn find_git_dir(start_path: impl AsRef) -> Option { - // HACK ignores stuff like bare repo, worktree, etc. let mut current = start_path.as_ref().to_path_buf(); loop { let git_path = current.join(".git"); if git_path.is_dir() { return Some(git_path); + } else if git_path.is_file() { + // Handle git worktrees - .git is a file containing "gitdir: " + if let Ok(contents) = read_to_string(&git_path) { + if let Some(gitdir) = contents.strip_prefix("gitdir: ") { + return Some(PathBuf::from(gitdir)); + } + } } if !current.pop() { return None;