From 419f43707ab87b64ff109aa6ca6a7de15ad6d453 Mon Sep 17 00:00:00 2001 From: Jonatan Dahl Date: Fri, 13 Feb 2026 16:03:30 -0500 Subject: [PATCH] fix(git): resolve incorrect repo name when running from worktree GetRepoName() used `git rev-parse --show-toplevel` which returns the worktree directory when run from inside a worktree, causing new worktrees to be created under the wrong path. Switch to `--git-common-dir` which always returns the main repo's .git directory regardless of which worktree you're in. Co-Authored-By: Claude Opus 4.6 --- internal/git/git.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/git/git.go b/internal/git/git.go index 7c5f9bf..b5fb205 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -59,13 +59,14 @@ func (c *gitClient) GetRepoRoot() (string, error) { return c.runCmd("rev-parse", "--show-toplevel") } -// GetRepoName returns the name of the git repository (directory name) +// GetRepoName returns the name of the git repository (directory name). +// Uses --git-common-dir to get the correct repo name even from worktrees. func (c *gitClient) GetRepoName() (string, error) { - repoRoot, err := c.GetRepoRoot() + gitCommonDir, err := c.runCmd("rev-parse", "--path-format=absolute", "--git-common-dir") if err != nil { return "", err } - return filepath.Base(repoRoot), nil + return filepath.Base(filepath.Dir(gitCommonDir)), nil } // GetCurrentBranch returns the name of the currently checked out branch