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

Re: git diff --quiet exits with 1 on clean tree with CRLF conversions

From
Torsten Bögershausen <tboegi@web.de>
Date
Feb 28, 2017, 18:06 UTC
Message-ID
<d98aa589-3e08-249d-0c88-72dbcee1a568@web.de>
In-Reply-To
<xmqqefyjwfql.fsf@gitster.mtv.corp.google.com>
On 2017-02-27 21:17, Junio C Hamano wrote:
Show 5 quoted lines
> Torsten, you've been quite active in fixing various glitches around
> the EOL conversion in the latter half of last year.  Have any
> thoughts to share on this topic?
> 
> Thanks.

Sorry for the delay, being too busy with other things. I followed the discussion, but didn't have good things to contribute. I am not an expert in diff.c, but there seems to be a bug, thanks everybody for digging.

Back to business:

My understanding is that git diff --quiet should be quiet, when git add will not do anything (but the file is "touched". The touched means that Git will detect e.g a new mtime or inode or file size when doing lstat().

mtime is tricky, inodes are problematic under Windows. What is easy to change is the file length. I don't thing that we need a test file with LF, nor do we need the sleep, touch or anything. Would the the following work ? (This is copy-paste, so the TABs may be corrupted)

#!/bin/sh # # Copyright (c) 2017 Mike Crowe # # These tests ensure that files changing line endings in the presence # of .gitattributes to indicate that line endings should be ignored # don't cause 'git diff' or 'git diff --quiet' to think that they have # been changed.

test_description='git diff with files that require CRLF conversion'
. ./test-lib.sh
test_expect_success setup '
	echo "* text=auto" > .gitattributes &&
	printf "Hello\r\nWorld\r\n" >crlf.txt &&
	git add .gitattributes crlf.txt lf.txt &&
	git commit -m "initial"
'
test_expect_success 'quiet diff works on file with line-ending change that has
no effect on repository' '
	printf "Hello\r\nWorld\n" >crlf.txt &&
	git status &&
	git diff --quiet
'
test_done
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 29 in “git diff --quiet exits with 1 on clean tree with CRLF conversions”
  1. Mike CroweFeb 17, 2017
  2. Junio C HamanoFeb 17, 2017
  3. Mike CroweFeb 17, 2017
  4. Mike CroweFeb 20, 2017
  5. Junio C HamanoFeb 20, 2017
  6. Mike CroweFeb 25, 2017
  7. Junio C HamanoFeb 27, 2017
  8. Torsten BögershausenFeb 28, 2017
  9. Junio C HamanoFeb 28, 2017
  10. 1/1 git diff --quiet exits with 1 on clean tree with CRLF conversionstboegi@web.de, Mar 1, 2017
  11. Junio C HamanoMar 1, 2017
  12. Junio C HamanoMar 1, 2017
  13. Jeff KingMar 2, 2017
  14. Junio C HamanoMar 2, 2017
  15. Jeff KingMar 2, 2017
  16. diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()Junio C Hamano, Mar 2, 2017
  17. Mike CroweMar 2, 2017
  18. Junio C HamanoMar 2, 2017
  19. Mike CroweMar 2, 2017
  20. Torsten BögershausenMar 3, 2017
  21. Junio C HamanoMar 3, 2017
  22. Torsten BögershausenMar 4, 2017
  23. Junio C HamanoMar 4, 2017
  24. Torsten BögershausenMar 2, 2017
  25. Mike CroweMar 1, 2017
  26. Junio C HamanoMar 1, 2017
  27. Torsten BögershausenMar 2, 2017
  28. Mike CroweMar 3, 2017
  29. git status reports file modified when only line-endings have changed (was git diff --quiet exits with 1 on clean tree with CRLF conversions)Mike Crowe, Mar 2, 2017

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.