From 5e8a834b3858b54b267a2f2e17c19e682519e854 Mon Sep 17 00:00:00 2001 From: beads/crew/fang Date: Wed, 31 Dec 2025 13:32:17 -0800 Subject: [PATCH] fix: bd sync now follows .beads/redirect for worktree path (bd-e2q9, bd-kvus) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When .beads/redirect exists, bd sync was using GetRepoRoot(cwd) to find the git worktree location. This failed because the worktree should be in the same repo as the beads directory, not the current working directory. Fix: Use getRepoRootFromPath(beadsDir) to derive the repo root from the actual beads location after following the redirect. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cmd/bd/sync.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index 5df2992b..cac40dc8 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -380,7 +380,13 @@ Use --merge to merge the sync branch back to main branch.`, if err := ensureStoreActive(); err == nil && store != nil { syncBranchName, _ = syncbranch.Get(ctx, store) if syncBranchName != "" && syncbranch.HasGitRemote(ctx) { - repoRoot, err = syncbranch.GetRepoRoot(ctx) + // GH#829/bd-e2q9/bd-kvus: Get repo root from beads location, not cwd. + // When .beads/redirect exists, jsonlPath points to the redirected location + // (e.g., mayor/rig/.beads/issues.jsonl), but cwd is in a different repo + // (e.g., crew/gus). The worktree for sync-branch must be in the same + // repo as the beads directory. + beadsDir := filepath.Dir(jsonlPath) + repoRoot, err = getRepoRootFromPath(ctx, beadsDir) if err != nil { fmt.Fprintf(os.Stderr, "Warning: sync.branch configured but failed to get repo root: %v\n", err) fmt.Fprintf(os.Stderr, "Falling back to current branch commits\n")