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

Re: Another core.safecrlf behavor with git diff/git status

From
Yann Droneaud <ydroneaud@opteya.com>
Date
Jun 24, 2013, 17:02 UTC
Message-ID
<400f1e3599efcbdcad82c2da89a3875c@meuh.org>
In-Reply-To
<866f886ef5e48ba22eec0f67203666bb@meuh.org>
Le 24.06.2013 18:37, Yann Droneaud a écrit :
Show 7 quoted lines
> 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:
[...]
Show 8 quoted lines
> - 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.
> 
One last try for today, still under Linux, with git 1.8.1.4:
   $ git init
   Initialized empty Git repository in 
/home/ydroneaud/src/tmp/onemore/work1/.git/
   $ git commit --allow-empty -m "root"
   [master (root-commit) 89c2ff9] root
   $ CRLF="\r\n"
   $ printf "Hello World 1${CRLF}Hello World 2${CRLF}Hello World 
3${CRLF}Hello World 4" > test
   $ git add test
   $ git commit -m "test"
   [master 36d4628] test
    1 file changed, 4 insertions(+)
    create mode 100644 test
   $ echo "test text" > .gitattributes
   $ git add .gitattributes
   $ git commit -m ".gitattributes"
   [master 3b9f3cc] .gitattributes
    1 file changed, 1 insertion(+)
    create mode 100644 .gitattributes
   $ git diff                      # print nothing
   $ git status
   # On branch master
   nothing to commit, working directory clean
   $ 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.
   diff --git a/test b/test
   index b043836..63ba10f 100644
   --- a/test
   +++ b/test
   @@ -1,4 +1,4 @@
   -Hello World 1
   -Hello World 2
   -Hello World 3
   +Hello World 1
   +Hello World 2
   +Hello World 3
    Hello World 4
   \ No newline at end of file
- commiting .gitattributes should have trigger a warning about CRLF 
conversion
- doing git diff after commiting .gitattributes should have reported the 
warning about CRLF/LF.

I dislike complaining all the time about such unusual corner cases, I apologize not having patches to provides to Git to try to "fix"/improve this.

Regards.
-- 
Yann Droneaud
OPTEYA
Previous: Yann Droneaud
Message 5 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.