how to avoid git-apply changing line endings

后端 未结 3 1825
忘了有多久
忘了有多久 2021-02-08 03:56

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

When I apply a patch from another crlf<

3条回答
  •  没有蜡笔的小新
    2021-02-08 04:48

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

    See commit c24f3ab (19 Aug 2017), and commit 2fea9de (13 Aug 2017) by Torsten Bögershausen (tboegi).
    (Merged by Junio C Hamano -- gitster -- in commit a17483f, 27 Aug 2017)

    apply: file committed with CRLF should roundtrip diff and apply

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

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

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

提交回复
热议问题