fix: bd sync fails to copy local changes TO beads-sync worktree (#810)
The bug: In a bare repo + worktrees setup, jsonlRelPath was calculated relative to the project root (containing all worktrees), resulting in paths like "main/.beads/issues.jsonl". But the sync branch worktree uses sparse checkout for .beads/*, so files are at ".beads/issues.jsonl". This caused SyncJSONLToWorktreeWithOptions to write to the wrong location (e.g., worktree/main/.beads/ instead of worktree/.beads/), so changes made locally never reached the sync branch worktree. #785 fixed the reverse direction (worktree → local) by adding normalizeBeadsRelPath(), but the local → worktree direction was missed. Fix: - Export NormalizeBeadsRelPath() (uppercase) for cross-package use - Apply normalization in SyncJSONLToWorktreeWithOptions for dstPath - Apply normalization in daemon_sync_branch.go for worktreeJSONLPath in both commit and pull paths - Add unit tests for the normalization function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,9 @@ func syncBranchCommitAndPushWithOptions(ctx context.Context, store storage.Stora
|
||||
}
|
||||
|
||||
// Check for changes in worktree
|
||||
worktreeJSONLPath := filepath.Join(worktreePath, jsonlRelPath)
|
||||
// GH#810: Normalize path for bare repo worktrees
|
||||
normalizedRelPath := git.NormalizeBeadsRelPath(jsonlRelPath)
|
||||
worktreeJSONLPath := filepath.Join(worktreePath, normalizedRelPath)
|
||||
hasChanges, err := gitHasChangesInWorktree(ctx, worktreePath, worktreeJSONLPath)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to check for changes in worktree: %w", err)
|
||||
@@ -304,7 +306,9 @@ func syncBranchPull(ctx context.Context, store storage.Storage, log daemonLogger
|
||||
}
|
||||
|
||||
// Copy JSONL back to main repo
|
||||
worktreeJSONLPath := filepath.Join(worktreePath, jsonlRelPath)
|
||||
// GH#810: Normalize path for bare repo worktrees
|
||||
normalizedRelPath := git.NormalizeBeadsRelPath(jsonlRelPath)
|
||||
worktreeJSONLPath := filepath.Join(worktreePath, normalizedRelPath)
|
||||
mainJSONLPath := jsonlPath
|
||||
|
||||
// Check if worktree JSONL exists
|
||||
|
||||
Reference in New Issue
Block a user