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