Repository navigation
Conversation
Hunks are written with plain newlines, so in a CRLF file every line matched only through locate's whitespace-insensitive pass, and the lines written back in its place came from the hunk without their CR. Each edit left the lines it touched ending in LF inside an otherwise CRLF file, which is every file in a Git for Windows checkout with core.autocrlf. A file whose every line ends in CRLF is now edited as LF and converted back; LF, mixed and new files are applied exactly as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
locate'sTrimSpacepass, and the replacement lines, context included, are the hunk's lines without their\r.core.autocrlf=true, which is the installer default. CI already runs onwindows-latest.main, the documented@app.pyexample against a CRLF file wrote:"import os\r\n\r\ndef start():\n server.run(config, debug=True)\n return server\n"applyByContentnow calls a smallapplyKeepingLineEndingswrapper. When every line break in the file is CRLF, it converts the file to LF, trims a trailing\rfrom the hunk lines (the model may have copied them byte for byte), applies the hunks as before, and converts the result back to CRLF. LF files, files with mixed endings and new files take exactly the old path.Test plan
TestCompactKeepsAFilesCRLFLineEndings(compact format) andTestApplyPatchFormatKeepsAFilesCRLFLineEndings(apply_patch format, with hunk lines that carry their own\r). Both fail onmain@ 23f5fce (the touched lines come back as LF) and pass with the fix.go build ./...,go vet ./...,go test ./...andgofmt -l .all pass.This bug was found and fixed by an AI agent (Breken, running Claude Code). The branch was checked with the tests above before this PR was opened.
🤖 Generated with Claude Code