Merge pull request #9925 from Kilo-Org/chore/zdiff3-conflict-style

chore: enforce zdiff3 conflict style via postinstall
This commit is contained in:
Mark IJbema
2026-05-05 17:37:01 +02:00
committed by GitHub
4 changed files with 32 additions and 6 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bun
// kilocode_change - new file
/**
* Configures repo-local git settings for all contributors.
*
* `merge.conflictStyle=zdiff3` makes conflict markers include the common
* ancestor (|||||||) alongside ours/theirs. That base section is what
* mergiraf's syntax-aware resolution feeds on during upstream opencode
* merges (see script/upstream/merge.ts) and it makes manual resolution
* dramatically easier than the default 2-way `merge` markers.
*
* Runs from `postinstall`. Safe to re-run — `git config` is idempotent.
* Guarded so tarball / docker installs without a `.git` don't fail.
*/
import { $ } from "bun"
const inside = await $`git rev-parse --is-inside-work-tree`.nothrow().quiet()
if (inside.exitCode !== 0) process.exit(0)
await $`git config --local merge.conflictStyle zdiff3`.quiet()
+5 -5
View File
@@ -122,11 +122,11 @@ export async function commit(message: string): Promise<void> {
}
export async function merge(branch: string): Promise<{ success: boolean; conflicts: string[] }> {
// Use zdiff3 markers so conflicts carry the base version (|||||||) alongside
// ours/theirs. This gives mergiraf the base it needs for structural heuristics
// and makes any remaining manual resolution dramatically easier (you can see
// what both sides changed relative to the common ancestor instead of
// reverse-engineering it from a 2-way marker).
// Force zdiff3 markers even if the contributor's local config has drifted:
// conflicts carry the base version (|||||||) alongside ours/theirs so mergiraf
// has the common ancestor for structural heuristics and any remaining manual
// resolution is dramatically easier. `postinstall` (script/setup-git.ts) sets
// this repo-wide as well; the `-c` override here is belt-and-suspenders.
const result = await $`git -c merge.conflictStyle=zdiff3 merge ${branch}`.nothrow()
if (result.exitCode === 0) {