git/list[1] front-page[2] threads[3] people[4] search[5] about
 

EOL conversion on checkout for text files only

From
BBBorek Bernard <borekb@gmail.com>
Date
Apr 6, 2015, 18:05 UTC
Message-ID
<CAHNoia06Q-jsskQn6TBkT8zPY7m14qmEL70HBm18CA-SaMrWtg@mail.gmail.com>
Hi,

I'd like to propose a new behavior around EOL normalization / forcing using gitattributes.

My use case is this: I want to ensure that LF line endings are used in the repo *and* in all working directories, on all platforms (in our case, the text files MUST be LF even on Windows).

The first part is easy to achieve using this in a .gitattributes file:
    * text=auto

This will correctly normalize *text files* in the repo. However, the second part (LF forcing on checkout) cannot be achieved easily today because adding `eol=lf` will unfortunately process binary files too. The only solution today is to mark certain types for conversion (e.g., `*.txt eol=lf`) or, inversely, mark certain types as binary (e.g., `*.png binary`).

Both of these suffer from the same issue: the specific file types must be listed explicitly in the .gitattributes file, which means that either the types must be known ahead of time or all developers must remember to update the .gitattributes file every time a new file type appears in the project. Which they won't.

The simplest solution in my eyes would be just to change the behavior of
    * text=auto eol=lf

to do both the checkin and checkout EOL conversions on *text files only*, using the same text/binary detection algorithm that is already in place for the checkin direction. This feels the most intuitive to me and I think it would not be a breaking change.

Related IRC discussion: http://colabti.org/irclogger/irclogger_log/git?date=2015-04-04#l1143

Thoughts?

Thanks, Borek

Next: Torsten Bögershausen
Message 1 of 2 in “EOL conversion on checkout for text files only”
  1. Borek BernardApr 6, 2015
  2. Torsten BögershausenApr 7, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.