Repository navigation
Commit 691b316
committed
fix(patch_set): accept CRLF line endings in git extended headers
GitHeader::parse extracts header values (file modes, rename/copy
paths, the diff --git line) via strip_line_ending, which stripped
only the trailing \n. In a patch file saved with CRLF line endings
(e.g. on Windows) every extracted value therefore kept its trailing
\r, and parsing a mode header failed outright:
error parsing patches at byte 0: invalid file mode: 100644\r
Strip a trailing \r as well, mirroring how GNU patch strips trailing
CRs from CRLF patches (the behavior the TODO on strip_line_ending
already pointed at). This only affects git extended header lines;
hunk content is handled by the patch parser itself.
Downstream report: pnpm/pnpm#16641, where a CRLF patch file that
creates a new file fails with ERR_PNPM_INVALID_PATCH on pnpm 12
(pnpm parses patches with diffy's PatchSet::parse).
Tests: crlf_new_file_with_content and crlf_mode_only_change fail on
the unpatched parser with InvalidFileMode("100644\r") and pass with
this change; the full suite (131 lib tests) passes.1 parent 4aa5870 commit 691b316
2 files changed
Lines changed: 58 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | | - | |
| 824 | + | |
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
832 | 837 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
762 | 810 | | |
763 | 811 | | |
764 | 812 | | |
| |||
0 commit comments