From: Torsten Bögershausen Date: Sun, 26 Nov 2017 12:20:52 +0000 (+0100) Subject: convert: tighten the safe autocrlf handling X-Git-Tag: v2.16.0-rc0~36^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/86ff70a0f0d3917205e1aa82dba08db92d357cc0?ds=inline;hp=86ff70a0f0d3917205e1aa82dba08db92d357cc0 convert: tighten the safe autocrlf handling When a text file had been commited with CRLF and the file is commited again, the CRLF are kept if .gitattributs has "text=auto". This is done by analyzing the content of the blob stored in the index: If a '\r' is found, Git assumes that the blob was commited with CRLF. The simple search for a '\r' does not always work as expected: A file is encoded in UTF-16 with CRLF and commited. Git treats it as binary. Now the content is converted into UTF-8. At the next commit Git treats the file as text, the CRLF should be converted into LF, but isn't. Replace has_cr_in_index() with has_crlf_in_index(). When no '\r' is found, 0 is returned directly, this is the most common case. If a '\r' is found, the content is analyzed more deeply. Reported-By: Ashish Negi Signed-off-by: Torsten Bögershausen Signed-off-by: Junio C Hamano ---