Subject: Re: bug#65049: Minor update to the repro steps

From: Eli Zaretskii <[email-masked]>
Date: Mon, 07 Aug 2023 19:24:19 +0300

> From: Maxim Kim <[email-masked]>
> Date: Mon, 07 Aug 2023 11:09:09 +1000
> 
> 
> It looks like line ending issue, I have tried generated patch in a terminal:
> 
>     PS C:\Users\maxim.kim\.emacs.d> git --no-pager apply --cached ..\AppData\Local\Temp\git-patchyYAcN5
>     error: patch failed: init.el:1
>     error: init.el: patch does not apply
> 
> Then added --ignore-space-change (found in
> https://www.delftstack.com/howto/git/git-patch-does-not-apply/#troubleshoot-git-patch-error-patch-does-not-apply
> and in magit issues https://github.com/magit/magit/issues/1139 plus
> linked https://github.com/magit/magit/issues/487#issuecomment-31727377)
> 
>     PS C:\Users\maxim.kim\.emacs.d> git --no-pager apply --ignore-space-change --cached ..\AppData\Local\Temp\git-patchyYAcN5
>     PS C:\Users\maxim.kim\.emacs.d>
> 
> and git apply worked out.

Yes, but where did the file git-patchyYAcN5 come from in the first
place?  It's that file that is the problem, not how we apply the
diffs in that file.

If you invoke "git diff SOME-FILE > diffs", from the shell prompt,
where SOME-FILE is a file that is modified wrt the repository's state,
does the file 'diffs' created by this command have DOS CRLF EOL
format, or does it have Unix Newline-only EOL format?  Try this with a
file that has Unix EOLs in the repository.

If Git produces DOS CRLF EOLs when it generates diffs, then that is
your problem, and it can only be fixed in Git itself: you need to
configure Git to never perform any EOL conversions:

  $ git config --global core.autocrlf false

This is the only sane setting for multiplatform Git repositories,
especially if you are using Emacs as your editor, because Emacs always
preserves the EOL format of a file you edit, even if the EOL format is
not the "native" one on the platform where you edit the file.

(In general, when you install Git on Windows, select the "as-is"
option of EOL conversions, then you will not need to perform the above
"git config" command manually, as this will be set up for you from the
get-go.)

I'm guessing that I don't see the problem you report because I have
disabled EOL conversion in Git years ago.