From: Mike Crowe <mac@mcrowe.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: git status reports file modified when only line-endings have changed (was git diff --quiet exits with 1 on clean tree with CRLF conversions)
Date: Thu, 2 Mar 2017 15:38:17 +0000 [thread overview]
Message-ID: <20170302153817.GC7821@mcrowe.com> (raw)
In-Reply-To: <d98aa589-3e08-249d-0c88-72dbcee1a568@web.de>
On Tuesday 28 February 2017 at 19:06:44 +0100, Torsten Bögershausen wrote:
> 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().
Does the same apply to "git status"?
If so, then whilst investigating the "git diff --quiet" problems in this
thread I've found a similar bug with "git status". It reports the file has
modifications even if only the line-endings have changed, and issuing "git
add" causes the perceived modification to disappear.
It can be very confusing for users if "git status" reports a modification
but for "git diff" to claim that the files are identical.
This bug is still reproducible even with the fix from
https://public-inbox.org/git/xmqqshmyhtnu.fsf@gitster.mtv.corp.google.com/T/#m67cbfad1f2efe721f0c2afac2a1523b743bb57ca
Here's the test case. Test 3 is the part that currently fails:
commit de5f3f1d9161cdd46342689abe38a046fc71850e
Author: Mike Crowe <mac@mcrowe.com>
Date: Sat Feb 25 09:28:37 2017 +0000
status: Add tests for status output when file line endings change
diff --git a/t/t7518-status-eol-change.sh b/t/t7518-status-eol-change.sh
new file mode 100755
index 0000000..e18186f
--- /dev/null
+++ b/t/t7518-status-eol-change.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (c) 2017 Mike Crowe
+#
+
+test_description='git status with files that require CRLF conversion'
+
+. ./test-lib.sh
+
+cat >expected_no_change <<EOF
+On branch master
+nothing to commit, working tree clean
+EOF
+
+test_expect_success setup '
+ echo "* text=auto" > .gitattributes &&
+ printf "Hello\r\nWorld\r\n" > crlf.txt &&
+ printf "expected_no_change\nactual\n" > .gitignore &&
+ git add .gitignore .gitattributes crlf.txt &&
+ git commit -m "initial"
+'
+test_expect_success 'git status reports no change if file regenerated' '
+ printf "Hello\r\nWorld\r\n" > crlf.txt &&
+ git status >actual &&
+ test_cmp expected_no_change actual
+'
+test_expect_success 'git status reports no change if line endings change' '
+ printf "Hello\nWorld\n" > crlf.txt &&
+ git status >actual &&
+ test_cmp expected_no_change actual
+'
+test_expect_success 'git status reports no change if line ending change is staged' '
+ git add crlf.txt &&
+ git status >actual &&
+ test_cmp expected_no_change actual
+'
+test_done
prev parent reply other threads:[~2017-03-02 15:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 21:26 git diff --quiet exits with 1 on clean tree with CRLF conversions Mike Crowe
2017-02-17 22:05 ` Junio C Hamano
2017-02-17 22:19 ` Mike Crowe
2017-02-20 15:33 ` Mike Crowe
2017-02-20 21:25 ` Junio C Hamano
2017-02-25 15:32 ` Mike Crowe
2017-02-27 20:17 ` Junio C Hamano
2017-02-28 18:06 ` Torsten Bögershausen
2017-02-28 21:50 ` Junio C Hamano
2017-03-01 17:04 ` [PATCH v1 1/1] " tboegi
2017-03-01 21:14 ` Junio C Hamano
2017-03-01 21:54 ` Junio C Hamano
2017-03-02 8:53 ` Jeff King
2017-03-02 17:52 ` Junio C Hamano
2017-03-02 19:12 ` Jeff King
2017-03-02 18:51 ` [PATCH v2] diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec() Junio C Hamano
2017-03-02 14:20 ` [PATCH v1 1/1] git diff --quiet exits with 1 on clean tree with CRLF conversions Mike Crowe
2017-03-02 18:20 ` Torsten Bögershausen
2017-03-02 18:33 ` Junio C Hamano
2017-03-02 20:03 ` Mike Crowe
2017-03-03 17:02 ` Torsten Bögershausen
2017-03-03 17:47 ` Junio C Hamano
2017-03-04 6:25 ` Torsten Bögershausen
2017-03-04 19:59 ` Junio C Hamano
2017-03-01 21:25 ` Mike Crowe
2017-03-01 23:29 ` Junio C Hamano
2017-03-02 18:17 ` Torsten Bögershausen
2017-03-03 17:01 ` Mike Crowe
2017-03-02 15:38 ` Mike Crowe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170302153817.GC7821@mcrowe.com \
--to=mac@mcrowe.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tboegi@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.