Skip to content

Implement #280 for fewer spurious merge conflicts in Dafny backend - #296

Merged
namin merged 3 commits into
mainfrom
diff-minimal
Nov 14, 2026
Merged

namin merged 3 commits into
mainfrom
diff-minimal

Conversation

@namin

@namin namin commented Nov 13, 2026

Copy link
Copy Markdown
Member

No description provided.

@namin

namin commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

@Sequela02 -- do you have a better idea how to go about this? I find this PR a bit messy. I think even the test could be cleaner. Maybe overall it works well enough? Would appreciate a second opinion. Thanks.

@Sequela02

Copy link
Copy Markdown
Contributor

The approach looks right to me. The fixture conflicts on main and merges cleanly with this branch, and I checked the fallback on a real Git 2.43. I'd be fine merging it as is.

Most of the mess comes from merge-file writing into the .dfy. Because Git can leave a partial result there, the PR needs savedDfy, a restore before the retry, and the try/finally around the copy, and the tests have to simulate partial output. With -p, Git prints the merge to stdout, so we write the .dfy only when the merge is clean:

const merge = (flags: string[]) => execFileSync("git", ["merge-file", "-p", ...flags, "--", dfyPath, basePath, genPath],
  { stdio: ["ignore", "pipe", "pipe"], maxBuffer: Infinity });

Exit 0 writes the output to the .dfy. Exits 1 to 127 write it to .dfy.merged. Anything else is an error.

The arguments are fixed, so exit 129 can only mean that Git rejected the option. Checking the status is enough, without LC_ALL or the regex. The error message could use the same format as dafnyCheckDiff.

For the tests, a small sh script as the fake git is enough, like the fake dafny that the tests already use. I'd keep the large-proof test and add one test each for old Git, a non-conflict exit, and git missing from PATH. The existing conflict test already covers real conflicts. That comes to about 74 added lines instead of 169.

I tried this locally. On Git 2.43 the regen tests pass, with the large-proof test skipped as designed, and the new tests fail on main. On Git 2.56 the #280 fixture merges byte for byte.

Two smaller things. The large-proof test skips without a word on Git before 2.44, so it could fail instead when CI is set. A .gitattributes with eol=lf for the fixture folder would enforce what its README asks.

None of this is a bug in your version. These are code-quality changes. If they sound better to you, I can open a PR against diff-minimal.

@Sequela02

Copy link
Copy Markdown
Contributor

Separately from my comment above, and unrelated to this PR: the additions-only check runs git diff with Node's default 1 MiB maxBuffer, so a proof whose diff is larger fails with "could not run git diff … (git exited null)". I hit it with a 1.7 MB synthetic proof, not a real one. Do you expect proofs that large? If so, I can open an issue.

@namin

namin commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review! Yes, please open a PR. I'd like the clean change in one merge.

@namin
namin merged commit 796ef52 into main Nov 14, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants