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

Re: [RFH] eol=lf on existing mixed line-ending files

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Apr 9, 2011, 20:09 UTC
Message-ID
<BANLkTi=qBeT=09YFng1gyt+SuN2v0g+kDg@mail.gmail.com>
In-Reply-To
<20110409192941.GB31579@sigill.intra.peff.net>
On Sat, Apr 9, 2011 at 11:32 PM, Jeff King <peff@github.com> wrote:
Show 7 quoted lines
>
> I just wonder if git can do better. But the only options I could think
> of are:
>
>  1. Set the working tree file to have just LF's. But that doesn't help,
>     since it is the conversion _to_ linefeeds that make it look like
>     the file is changed. So we'd still see unstaged changes.

Well, eol=crlf _does_ set the working tree file to have only CRLF, but you still have the same race as before. Just because git converts file, it does not think about it as "dirty". It becomes "dirty" when git tries to convert it back and gets a different result, and whether it tries or not depend on timestamp. So, you still have the same race.

Show 7 quoted lines
>> > So we get two different outcomes, depending on the index raciness. Which
>> > one is right, or is it right for it to be non-deterministic?
>>
>> I like everything being deterministic, but in this case I do not see
>> how it is possible without making the normal case much slower.
>
> I think if you took my (1) suggestion above, it would be deterministic.

Replace "eol=lf" with "eol=crlf" in your script, and you will see that it does not help with the race.

Show 5 quoted lines
>
> I absolutely agree, and my first advice upon seeing this jquery repo was
> to fix those line endings. But they went for over a year with the broken
> setup, so clearly it wasn't bothering them. I wonder what git could do
> better to provoke them to fix it sooner.

I believe git should consider all files as "dirty" if .gitattributes is changed. So, you cannot accidentally commit changes to .gitattributes without fixing line endings. Currently, you can provoke git to consider all files as dirty by doing:

  touch -d 2000-1-1 .git/index
but we should not expect users to do that after editing .gitattributes.
Dmitry
Previous: Jeff KingNext: Jay Soffian
Message 6 of 7 in “[RFH] eol=lf on existing mixed line-ending files”
  1. Jeff KingApr 7, 2011
  2. Michael J GruberApr 8, 2011
  3. Jeff KingApr 8, 2011
  4. Dmitry PotapovApr 9, 2011
  5. Jeff KingApr 9, 2011
  6. Dmitry PotapovApr 9, 2011
  7. Jay SoffianApr 12, 2011

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.