From 2f9d423ac8869b05e95f580eadec9a7faaf5ce22 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Thu, 25 Dec 2025 12:05:23 -0800 Subject: [PATCH] fix: Prevent bd sync from committing non-.beads files (bd-trgb) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gitCommit() was adding the JSONL file but then committing ALL staged changes (no pathspec). If other files were staged (e.g., deletions from git add -A), they would be swept into the bd sync commit. Fixed by adding pathspec to both gitCommit() and commitToExternalBeadsRepo() so they only commit what they explicitly staged. This was the root cause of PR #722 files being deleted - they were staged for deletion in the working tree and got committed by bd sync. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cmd/bd/sync.go | 4 +++- cmd/bd/sync_branch.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index ab7e6701..2ea2912a 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -893,7 +893,9 @@ func gitCommit(ctx context.Context, filePath string, message string) error { } // Commit from repo root context with config-based author and signing options - commitArgs := buildGitCommitArgs(repoRoot, message) + // Use pathspec to commit ONLY this file (bd-trgb fix) + // This prevents accidentally committing other staged files + commitArgs := buildGitCommitArgs(repoRoot, message, "--", relPath) commitCmd := exec.CommandContext(ctx, "git", commitArgs...) output, err := commitCmd.CombinedOutput() if err != nil { diff --git a/cmd/bd/sync_branch.go b/cmd/bd/sync_branch.go index e54a8ae4..d632ce56 100644 --- a/cmd/bd/sync_branch.go +++ b/cmd/bd/sync_branch.go @@ -240,10 +240,12 @@ func commitToExternalBeadsRepo(ctx context.Context, beadsDir, message string, pu } // Commit with config-based author and signing options + // Use pathspec to commit ONLY beads files (bd-trgb fix) + // This prevents accidentally committing other staged files if message == "" { message = fmt.Sprintf("bd sync: %s", time.Now().Format("2006-01-02 15:04:05")) } - commitArgs := buildGitCommitArgs(repoRoot, message) + commitArgs := buildGitCommitArgs(repoRoot, message, "--", relBeadsDir) commitCmd := exec.CommandContext(ctx, "git", commitArgs...) //nolint:gosec // args from buildGitCommitArgs if output, err := commitCmd.CombinedOutput(); err != nil { return false, fmt.Errorf("git commit failed: %w\n%s", err, output)