From 23dccff03a738c787a2bab5e0fc4aef9ad70cfa9 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Tue, 30 Dec 2025 21:05:27 -0800 Subject: [PATCH] fix: bypass external direct-commit when sync.branch is configured (bd-n663) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When .beads/redirect points to another location that crosses directory boundaries, isExternalBeadsDir() can return true even when both paths are in the same git repo. Previously, this would trigger the direct commit mode, bypassing the configured sync.branch workflow. Now we check hasSyncBranchConfig before entering the external path. When sync.branch is configured, we skip direct-commit mode and use the sync.branch worktree workflow instead, which properly handles copying JSONL files regardless of where the source .beads lives. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cmd/bd/sync.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index 493cbbec..5df2992b 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -305,7 +305,12 @@ Use --merge to merge the sync branch back to main branch.`, beadsDir := filepath.Dir(jsonlPath) isExternal := isExternalBeadsDir(ctx, beadsDir) - if isExternal { + // GH#812/bd-n663: When sync.branch is configured, skip external direct-commit mode. + // The redirect may point to another clone/worktree in the same repo, but cross + // directory boundaries that trigger isExternalBeadsDir=true. When sync.branch is + // configured, we should use the sync.branch workflow which properly handles copying + // JSONL files to the sync branch worktree, regardless of where the source .beads lives. + if isExternal && !hasSyncBranchConfig { // External BEADS_DIR: commit/pull directly to the beads repo fmt.Println("→ External BEADS_DIR detected, using direct commit...")