Skip to content

Preserve binary markers when formatting Git patches - #738

Open
liugedragon wants to merge 1 commit into
kpdecker:masterfrom
liugedragon:fix/preserve-binary-patch-format
Open

liugedragon wants to merge 1 commit into
kpdecker:masterfrom
liugedragon:fix/preserve-binary-patch-format

Conversation

@liugedragon

@liugedragon liugedragon commented Nov 10, 2026 •

Copy link
Copy Markdown

Formatting a parsed Git binary diff currently drops its isBinary flag on the next parse. The formatted output contains only the diff --git line and any mode/rename headers, so consumers lose the indication that the file content needs separate handling.

Emit a Binary files ... differ summary for Git patches marked isBinary, using the existing filename quoting and /dev/null for creations/deletions. Document that this preserves the marker rather than binary file data.

Seven regressions cover modifications, creations, deletions, renames, copies, quoted filenames, and mixed text/binary multi-file patches. All seven fail before the fix and pass afterward. Actual git diff --no-index output for synthetic binary modification/creation/deletion cases also retains its flag after the round trip.

Validation on Windows / Node 22.18.0:

  • yarn build: passed, including lint, CJS/ESM generation, type checks, and bundles (one existing TODO warning).
  • yarn mocha 'test/patch/**/*.js': 194 passing.
  • yarn test: 323 passing, with the same two async timing failures present on the unchanged baseline (316 passing): should not wait for a timer between iterations in async mode and does not starve timers while it runs. No test timeouts or async implementation were changed.
  • Coverage: 99.20% lines, 96.82% branches, 100% functions.
  • Independent Git 2.34.1 corpus: 40 real binary modification/creation/deletion/rename/copy diffs, each mixed with a text change, passed through CJS and ESM (80 round trips). Filenames include spaces, quotes, tabs, newlines, backslashes, and non-ASCII characters; all parsed metadata and text application results were preserved.
  • git diff --check: passed.

Additional validation on Ubuntu 22.04 (WSL x86_64), Node 22.18.0 and Yarn 4.18.1: a clean source export with yarn install --immutable and the full yarn test command passed, including build, type checks, bundles, coverage and all 325 tests. The unchanged upstream base passed all 318 tests in the same environment.

This branch has not been deployed

No deployments
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.

1 participant