fix: Correct git merge driver placeholders from %L/%R to %A/%B
Git merge drivers only support three placeholders: - %O (ancestor/base) - %A (current version) - %B (other branch's version) The code was incorrectly using %L and %R, which don't exist in git, causing them to be passed through literally and breaking JSONL merges. Changes: - Fixed merge driver config in init.go, merge.go, README.md, docs - Added detection in bd doctor with clear error messages - Added auto-fix in bd doctor --fix - Added proactive warning in bd sync before git pull - Added reactive error detection after merge failures - Updated all tests to use correct placeholders Now users get helpful guidance at every step: 1. bd doctor detects the issue 2. bd doctor --fix auto-corrects it 3. bd sync warns before pulling if misconfigured 4. Error messages suggest bd doctor --fix when merge fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
25
cmd/bd/doctor/fix/merge_driver.go
Normal file
25
cmd/bd/doctor/fix/merge_driver.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package fix
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// MergeDriver fixes the git merge driver configuration to use correct placeholders.
|
||||
// Git only supports %O (base), %A (current), %B (other) - not %L/%R.
|
||||
func MergeDriver(path string) error {
|
||||
if err := validateBeadsWorkspace(path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Update git config to use correct placeholders
|
||||
// #nosec G204 -- path is validated by validateBeadsWorkspace
|
||||
cmd := exec.Command("git", "config", "merge.beads.driver", "bd merge %A %O %A %B")
|
||||
cmd.Dir = path
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update git merge driver config: %w\nOutput: %s", err, output)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user