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.
This commit is contained in:
Wilhelm Uschtrin
2026-01-20 22:04:51 +00:00
committed by GitHub
parent 521239cfdc
commit f7134954b9

View File

@@ -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