Avoiding git line feeds

I have a git repository with core.eol=crlf , core.autocrlf=true and core.safecrlf=true .

When I apply a patch from another crlf relay, and for my repo, all line endings for the processed file change to lf . I am currently applying the patch like this:

 git apply --ignore-whitespace mychanges.patch 

(It seems I should use --ignore-whitespace in order to get the fix for a successful application.)

My current job is to run unix2dos in a file. Is there a better way to get an application to fit my eol settings?

+6
source share
3 answers

I would not allow my version control system to control my line endings. Auto crlf is false and shows the difference without annoying ^ M, by setting core.whitespace to cr-at-eol. Now diff output will be better read.

+2
source

Check if the problem persists with Git 2.14.x / 2.15 (Q3 2015)

See commit c24f3ab (August 19, 2017) and commit 2fea9de (August 13, 2017) Torsten Begershausen ( tboegi ) .
(Combined by Junio ​​C Hamano - gitster - to commit to a17483f , August 27, 2017)

apply : file enclosed with CRLF should round diff and apply

When the file was committed with CRLF, but now .gitattributes says " * text=auto " (or core.autocrlf is true ), the following is not roundtrip, git apply does not work:

 printf "Added line\r\n" >>file && git diff >patch && git checkout -- . && git apply patch 

Before applying the patch, the file from the working tree is converted to the index format (clean filter, CRLF conversion, ...).
Here, when it is associated with CRLF, line endings should not be converted.

+1
source

Try creating a clean working directory:

 git apply mychanges.patch git diff -w > mychangesnows.patch git reset --hard git apply mychangesnows.patch 
0
source

Source: https://habr.com/ru/post/890236/


All Articles