fix(sync): handle diverged histories with content-based merge (bd-3s8)
When multiple clones commit to beads-sync branch and histories diverge, git merge would fail. This replaces git's commit-level merge with a content-based merge that extracts JSONL from base/local/remote and merges at the semantic level. Key changes: - Add divergence detection using git rev-list --left-right - Extract JSONL content from specific commits for 3-way merge - Reset to remote's history then commit merged content on top - Pre-emptive fetch before commit to reduce divergence likelihood - Deletions.jsonl merged by union (keeps all deletions) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -384,7 +384,14 @@ Use --merge to merge the sync branch back to main branch.`,
|
||||
os.Exit(1)
|
||||
}
|
||||
if pullResult.Pulled {
|
||||
fmt.Printf("✓ Pulled from %s\n", syncBranchName)
|
||||
if pullResult.Merged {
|
||||
// bd-3s8 fix: divergent histories were merged at content level
|
||||
fmt.Printf("✓ Merged divergent histories from %s\n", syncBranchName)
|
||||
} else if pullResult.FastForwarded {
|
||||
fmt.Printf("✓ Fast-forwarded from %s\n", syncBranchName)
|
||||
} else {
|
||||
fmt.Printf("✓ Pulled from %s\n", syncBranchName)
|
||||
}
|
||||
}
|
||||
// JSONL is already copied to main repo by PullFromSyncBranch
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user