fix(agent): handled already-applied patch merges
Use git apply --3way for patch-mode isolated merge checks and applies so diff-tree patches that are already present are accepted as no-ops. Added regression coverage for a clean already-applied binary/full-index patch. Fixes #4135
This commit is contained in:
@@ -291,11 +291,11 @@ export async function mergeIsolatedChanges(opts: IsolationMergeOptions): Promise
|
||||
hadAnyChanges = false;
|
||||
} else {
|
||||
const normalized = patchText.endsWith("\n") ? patchText : `${patchText}\n`;
|
||||
changesApplied = await git.patch.canApplyText(repoRoot, normalized);
|
||||
changesApplied = await git.patch.canApplyText(repoRoot, normalized, { threeWay: true });
|
||||
hadAnyChanges = false;
|
||||
if (changesApplied) {
|
||||
try {
|
||||
await git.patch.applyText(repoRoot, normalized);
|
||||
await git.patch.applyText(repoRoot, normalized, { threeWay: true });
|
||||
hadAnyChanges = true;
|
||||
} catch {
|
||||
changesApplied = false;
|
||||
|
||||
Reference in New Issue
Block a user