diff options
Diffstat (limited to 'makima/src/daemon/worktree/manager.rs')
| -rw-r--r-- | makima/src/daemon/worktree/manager.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/makima/src/daemon/worktree/manager.rs b/makima/src/daemon/worktree/manager.rs index 04180b8..5df9a73 100644 --- a/makima/src/daemon/worktree/manager.rs +++ b/makima/src/daemon/worktree/manager.rs @@ -864,15 +864,25 @@ impl WorktreeManager { if git_file.is_file() { let content = tokio::fs::read_to_string(&git_file).await?; - // Format: "gitdir: /path/to/repo/.git/worktrees/name" + // Format varies by repo type: + // Non-bare: "gitdir: /path/to/repo/.git/worktrees/name" + // Bare: "gitdir: /path/to/bare-repo/worktrees/name" if let Some(gitdir) = content.strip_prefix("gitdir: ") { let gitdir = gitdir.trim(); - // Navigate from worktrees/name back to the main repo let path = PathBuf::from(gitdir); + // Navigate up from worktrees/name to the git directory if let Some(worktrees_dir) = path.parent() { if let Some(git_dir) = worktrees_dir.parent() { - if let Some(repo_dir) = git_dir.parent() { - return Ok(repo_dir.to_path_buf()); + // For bare repos, git_dir IS the repo (e.g. ~/.makima/repos/foo/) + // For non-bare repos, git_dir is <repo>/.git/, need one more parent + if git_dir.file_name() == Some(std::ffi::OsStr::new(".git")) { + // Non-bare: go up from .git/ to the repo root + if let Some(repo_dir) = git_dir.parent() { + return Ok(repo_dir.to_path_buf()); + } + } else { + // Bare repo: git_dir is already the repo + return Ok(git_dir.to_path_buf()); } } } |
