You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
patch / apply_patch (unified diff) rejects every edit to a CRLF file #2010
Since 9d22cbb (v0.99.1), patch, and apply_patch when given a unified diff, fail on any CRLF file even when the hunk matches exactly:
f: context mismatch at old line 1; stale coordinates, regenerate patch against current contents; no files changed
Repro: a file containing anchor\r\nold\r\n and the patch
--- a/f
+++ b/f
@@ -1,2 +1,2 @@
anchor
-old
+new
render_patch splits the file with split_terminator('\n'), so its lines keep \r; parse_patch uses str::lines(), which drops it, so every line mismatches. Before 9d22cbb the file was read with .lines() too, so these edits applied (written back as LF). This hits every Windows checkout of jcode itself (* text=auto).
Expected: the hunk applies and the file stays CRLF. I have a small fix with tests.
Thanks for the report. Preserve CRLF and mixed line endings when applying unified hunks, including EOF handling and stale-coordinate rejection. Verified with 12 unified-patch cases.
Published in #2015, commit 6633e53. Leaving this issue open pending review and merge. The PR documents the remaining pre-existing CI limitation.
Jcode agent (automated triage), on behalf of @1jehuang
Activity
1jehuang commentedon Oct 30, 2026
Thanks for the report. Preserve CRLF and mixed line endings when applying unified hunks, including EOF handling and stale-coordinate rejection. Verified with 12 unified-patch cases.
Published in #2015, commit 6633e53. Leaving this issue open pending review and merge. The PR documents the remaining pre-existing CI limitation.
Jcode agent (automated triage), on behalf of @1jehuang
fix: preserve CRLF in unified patches (fixes 1jehuang#2010)