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

Another core.safecrlf behavor with git diff/git status

From
Yann Droneaud <ydroneaud@opteya.com>
Date
Jun 24, 2013, 16:37 UTC
Message-ID
<866f886ef5e48ba22eec0f67203666bb@meuh.org>
Hi,

I'm still trying to use .gitattributes "text" flag with CRLF line ending files under Linux.

I'm surprised about the interaction between the index and the working directory, more specificaly about the interaction between git diff and git status:

   $ git init
   Initialized empty Git repository in /home/ydroneaud/tmp/.git/
   $ echo "test text" > .gitattributes
   $ git add .gitattributes
   $ git commit -m ".gitattributes"
   [master (root-commit) 67c2a06] attrib
    1 file changed, 1 insertion(+)
    create mode 100644 .gitattributes
   $ printf "One\r\nLine\r\n" > test
   $ git add test
   warning: CRLF will be replaced by LF in test.
   The file will have its original line endings in your working 
directory.
   $ git commit -m "test"
   [master 8b06aed] test
   warning: CRLF will be replaced by LF in test.
   The file will have its original line endings in your working 
directory.
    1 file changed, 2 insertions(+)
    create mode 100644 test
   $ git diff
   # <git diff report nothing>
   $ touch test
   $ git diff
   warning: CRLF will be replaced by LF in test.
   The file will have its original line endings in your working 
directory.
   $ git diff                                    # <= twice
   warning: CRLF will be replaced by LF in test.
   The file will have its original line endings in your working 
directory.
   $ git status
   # On branch master
   nothing to commit, working directory clean
   $ git diff
   # <git diff report nothing>
- Why git diff does not always report the CRLF/LF mismatch ?
- Why git status does not report about the CRLF/LF mismatch before 
updating the index:
   it silently hide the CRLF/LF warning.
   git add, git commit report the warning. git status should probably do 
the same.
Regards.
-- 
Yann Droneaud
OPTEYA
Next: Yann Droneaud
Message 1 of 5 in “Another core.safecrlf behavor with git diff/git status”
  1. Yann DroneaudJun 24, 2013
  2. Yann DroneaudJun 24, 2013
  3. Junio C HamanoJun 24, 2013
  4. Yann DroneaudJun 25, 2013
  5. Yann DroneaudJun 24, 2013

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.