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

Re: [PATCH/RFC] blame: CRLF in the working tree and LF in the repo

From
Stepan Kasal <kasal@ucw.cz>
Date
Apr 28, 2015, 21:58 UTC
Message-ID
<20150428215807.GE1433@camelia.ucw.cz>
In-Reply-To
<553FEB4F.7050409@kdbg.org>
Hello Hannes,
let me correct my previous statement:
On Mon, Apr 27, 2015 at 08:58:05PM +0200, Johannes Sixt wrote:
> When I commit my C source code files with CRLF into the repository  
> (because I do not set any line ending options or configurations or any  
> 'text' attributes or similar), do I then commit binary files or text  
> files? Should I expect not to see any diffs?

Of course, you can see diffs. The files are not binary in that sense.

Johannes Sixt <j6t@kdbg.org> writes:
> I set none of these. But I do commit CRLF and expect to get CRLF
> back. [...]

That works. You will not encounter any problem. (Supposing you do not change the line ending options, of course.)

Finally, let me explain my previous statement:
> Am 27.04.2015 um 08:11 schrieb Stepan Kasal:
>> Git does not support CRLF as the internal line separator.

I'm often asked: "How do I set up git so that it uses CRLF in text files in the repository and checks them out with CRLF on Windows and with LF on unixy systems?"

My answer to that question always was that you cannot configure the internal line separator in git repo, it is always LF. Your only chance to support both line endings is to have LF in the repo and configure the Windows client to do the conversion.

>> If you commit file in binary mode with CRLF, you are on your own.

OK, scratch the word "binary". The files in the repo are actually text files. But each text line is contains one more char than you would think. From time to time, this lurks:

1) Does "git grep ';$' HEAD" find anything?
2) What about "git grep ';.$' HEAD" ?
   Or "git grep `printf ';\r$' HEAD"  ?
3) If you try things like
       git diff HEAD^^..HEAD^ >outfile.diff
   and then open outfile.diff with a suitable editor (e.g. vim), you
   can see an extra ^M at the end of some lines (the content ones).

This is why I tell users that they are on their own if they decide to use the setup you described.

Have a nice day,
	Stepan
Previous: Johannes SixtNext: Junio C Hamano
Message 11 of 16 in “blame: CRLF in the working tree and LF in the repo”
  1. blame: CRLF in the working tree and LF in the repoTorsten Bögershausen, Apr 26, 2015
  2. Eric SunshineApr 26, 2015
  3. Stepan KasalApr 27, 2015
  4. Junio C HamanoApr 27, 2015
  5. Stepan KasalApr 27, 2015
  6. Johannes SixtApr 27, 2015
  7. Torsten BögershausenApr 27, 2015
  8. Johannes SixtApr 28, 2015
  9. Junio C HamanoApr 28, 2015
  10. Johannes SixtApr 28, 2015
  11. Stepan KasalApr 28, 2015
  12. Junio C HamanoApr 27, 2015
  13. Torsten BögershausenApr 27, 2015
  14. Junio C HamanoApr 28, 2015
  15. Torsten BögershausenApr 28, 2015
  16. brian m. carlsonApr 28, 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.