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

Re: [msysGit] Re: The different EOL behavior between libgit2-based software and official Git

From
Torsten Bögershausen <tboegi@web.de>
Date
Jun 22, 2014, 06:46 UTC
Message-ID
<53A67BE1.4060903@web.de>
In-Reply-To
<xmqqmwd7ee2j.fsf@gitster.dls.corp.google.com>
On 2014-06-20 18.33, Junio C Hamano wrote:
Show 17 quoted lines
> Torsten Bögershausen <tboegi@web.de> writes:
> 
> tb@Linux:~/EOL_Test/TestAutoCrlf$ t=LF.txt  &&  rm -f $t &&  git -c core.eol=CRLF checkout $t  && od -c  $t
> 0000000   L   i   n   e       1  \n   l   i   n   e       (   2   )  \n
> 0000020   l   i   n   e       3   .  \n   t   h   i   s       i   s    
> 0000040   l   i   n   e       4  \n   l       i       n       e       N
> 0000060   o   .       5  \n   L   i   n   e       N   u   m   b   e   r
> 0000100       6  \n  \n
> 
> In Documentation/config.txt, we find:
> 
>     core.eol::
>             Sets the line ending type to use in the working directory for
>             files that have the `text` property set.  Alternatives are ...
> 
> Does that file $t in your practice "have the `text` property set"?
> 

No, it hadn't, under my Linux box. (And I had a .gittatributes file on the Mac OS box, which I forgot about. I am really sorry for the confusion and saying that Git behaves different under Linux and Mac OS).

You are pointing into the right direction: Files with mixed LF CRLF in the repo are not changed by Git, when the checkout out or checked in, unless the .gitattributes say that the file is text.

And libgit2 should do the same.

However, I was confused by this https://www.kernel.org/pub/software/scm/git/docs/git-config.html (My comments inline with ##) ----------------------- core.autocrlf

    Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. 
## And is this line still valid:
Use this setting if you want to have CRLF line endings in your working directory even though the repository does not have normalized line endings. 

## In 2010 the "the new safer autocrlf handling" was introduced, ## and it looks as if commits fd6cce9e and c4805393 are involved here. ## When the file in the repo has only LF, it will have CRLF in the work tree ## When the file in the repo has mixed LF and CRLF, it will not be changed in the work tree ## and will have mixed line endings in the work tree ## When the file in the repo has only CRLF, it will not be changed in the work tree ## and will have CRLF in the work tree as well as in the repo.

##Should this line simply be dropped in the documentation ?
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 10 in “The different EOL behavior between libgit2-based software and official Git”
  1. Yue Lin HoJun 19, 2014
  2. Torsten BögershausenJun 19, 2014
  3. Yue Lin HoJun 19, 2014
  4. Torsten BögershausenJun 20, 2014
  5. Yue Lin HoJun 20, 2014
  6. Torsten BögershausenJun 20, 2014
  7. Junio C HamanoJun 20, 2014
  8. Torsten BögershausenJun 22, 2014
  9. Junio C HamanoJun 23, 2014
  10. Yue Lin HoJun 20, 2014

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.