From f7134954b9762c016e99635f7a882c12e60e5ba1 Mon Sep 17 00:00:00 2001 From: Wilhelm Uschtrin Date: Tue, 20 Jan 2026 22:04:51 +0000 Subject: [PATCH] fix(worktree): correct redirect path computation in bd worktree create (#1217) Computes the relative path from the worktree root instead of the .beads directory. This ensures that FollowRedirect resolves paths correctly relative to the parent of .beads. --- cmd/bd/worktree_cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/bd/worktree_cmd.go b/cmd/bd/worktree_cmd.go index 8a217a06..71f40e95 100644 --- a/cmd/bd/worktree_cmd.go +++ b/cmd/bd/worktree_cmd.go @@ -207,7 +207,10 @@ func runWorktreeCreate(cmd *cobra.Command, args []string) error { // Ensure mainBeadsDir is absolute for correct filepath.Rel() computation (GH#1098) // beads.FindBeadsDir() may return a relative path in some contexts absMainBeadsDir := utils.CanonicalizeIfRelative(mainBeadsDir) - relPath, err := filepath.Rel(worktreeBeadsDir, absMainBeadsDir) + // Compute relative path from worktree root (not .beads dir) because + // FollowRedirect resolves paths relative to the parent of .beads + worktreeRoot := filepath.Dir(worktreeBeadsDir) + relPath, err := filepath.Rel(worktreeRoot, absMainBeadsDir) if err != nil { // Fall back to absolute path relPath = absMainBeadsDir