Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LF-to-CRLF conversion applied on checkout even to files marked as "-text" in .gitattributes #2237

Closed
Googulator opened this issue Jun 17, 2019 · 3 comments

Comments

@Googulator
Copy link

The "-text" attribute (and even the "binary" attribute) declaration in .gitattributes fails to completely turn off line ending conversion in Windows. Files with this attribute keep their line endings on commit, but on checkout, they get converted to CRLF. This can cause file hashes to mismatch, breaking signatures.
Additionally, when committing changes to files with this attribute on Windows, Git tries to commit the converted line endings, changing the endings in the repository itself to CRLF.

  • [ X ] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.22.0.windows.1
cpu: x86_64
built from commit: d003d728ffa6c0006da875ec6318d3f6b28a4ddb
sizeof-long: 4
sizeof-size_t: 8

  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.18362.145]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: Notepad++
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
Enable Builtin Interactive Add: Disabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?
    none

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git Bash in mintty

(on a Linux machine)
<create a text file containing LF line endings>
sha256sum lf.txt > lf.sha
echo "lf.txt -text" > .gitattributes
git add lf.txt
git add lf.sha
git add .gitattributes
git commit
git push <...>

(on this Windows machine)
git clone <...>
sha256sum -c lf.sha

  • What did you expect to occur after running these commands?

lf.txt should have been checked out with LF line endings, binary identical to how it was created

  • What actually happened instead?

A line ending conversion is applied to lf.txt, changing the LF line endings in it to CRLF. This is a problem e.g. if lf.txt is signed, or has its hash stored somewhere.
If I then edit lf.txt and try to commit it, line endings in the committed copy actually get stored as CRLF.

@PhilipOakley
Copy link

What settings do you have in the config file?

If there is a conflict, then an MVCE would be an advantage for folks debugging the issue (assuming that the priority order is as you say and that it isn't a documentation conflict)

@tboegi
Copy link

tboegi commented Jun 17, 2019

Could you do me a favorite and run
git ls-files --eol -s
on both the Linux and Windows boxes ?

@dscho
Copy link
Member

dscho commented Oct 15, 2021

Closing this stale ticket.

@dscho dscho closed this as completed Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants