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

Re: Explanation of `eol` attribute doesn't seem correct for Windows machines

From
Torsten Bögershausen <tboegi@web.de>
Date
Nov 6, 2023, 16:21 UTC
Message-ID
<20231106162125.GA31375@tb-raspi4>
In-Reply-To
<AS4P195MB15272FE283D0CF606A8B074EE2AAA@AS4P195MB1527.EURP195.PROD.OUTLOOK.COM>
On Mon, Nov 06, 2023 at 03:11:54PM +0000, Hans Meiser wrote:
Show 16 quoted lines
> https://git-scm.com/docs/gitattributes#_eol
>
> claims that:
>
> ---
> Set to string value "crlf"
>
>     This setting converts the file’s line endings in the working directory to CRLF when the file is checked out.
> Set to string value "lf"
>
>     This setting uses the same line endings in the working directory as in the index when the file is checked out.
> ---
>
> I don't think this explanation is sufficient for files stored on Windows machines.
> A file might be stored with CRLF in the index.
> What happens then?
  >This setting uses the same line endings in the working directory
  >as in the index when the file is checked out.
  If you have a file commited with CRLF into the index, it will have CRLF in the working tree.
  If the file had been commited with LF into the index, it will have LF in the working tree.
  That is what the documentation tries to say, I think.
However, the above discussion is only valid, when the "text" attribute is defined.
Otherwise the eol attribute has no effect.
So you need something like
* text=auto
and/or
*.txt text
in your .gitattributes file
> And what happens when a file is added to the index with `core.autocrlf=input` on Windows machines?

Do you have a .gitattributes file ? Or not ? Is the file a new one, or does it exist ?

In any way, git ls-files --eol may help to find out, what is in the index and what is in the workingtree.

Previous: Hans MeiserNext: Hans Meiser
Message 2 of 4 in “Explanation of `eol` attribute doesn't seem correct for Windows machines”
  1. Hans MeiserNov 6, 2023
  2. Torsten BögershausenNov 6, 2023
  3. Hans MeiserNov 7, 2023
  4. Torsten BögershausenNov 7, 2023

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.