aboutsummaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-27 11:16:21 -0800
committerJunio C Hamano <gitster@pobox.com>2017-12-27 11:16:21 -0800
commit720b1764def1cfd67004d917ec954df20983e6bb (patch)
treecee0a7e37fe847cc8b50eeeb9ca2c8d472abc362 /convert.c
parent61061abba7d60f555e97a22ab5775a9d53db1660 (diff)
parent649f1f0948a4ba7efbaa00f2cb0ff3ddec08a423 (diff)
downloadgit-720b1764def1cfd67004d917ec954df20983e6bb.tar.gz
git-720b1764def1cfd67004d917ec954df20983e6bb.tar.xz
Merge branch 'tb/check-crlf-for-safe-crlf'
The "safe crlf" check incorrectly triggered for contents that does not use CRLF as line endings, which has been corrected. * tb/check-crlf-for-safe-crlf: t0027: Adapt the new MIX tests to Windows convert: tighten the safe autocrlf handling
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/convert.c b/convert.c
index 20d7ab67b..1a41a48e1 100644
--- a/convert.c
+++ b/convert.c
@@ -220,18 +220,27 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,
}
}
-static int has_cr_in_index(const struct index_state *istate, const char *path)
+static int has_crlf_in_index(const struct index_state *istate, const char *path)
{
unsigned long sz;
void *data;
- int has_cr;
+ const char *crp;
+ int has_crlf = 0;
data = read_blob_data_from_index(istate, path, &sz);
if (!data)
return 0;
- has_cr = memchr(data, '\r', sz) != NULL;
+
+ crp = memchr(data, '\r', sz);
+ if (crp) {
+ unsigned int ret_stats;
+ ret_stats = gather_convert_stats(data, sz);
+ if (!(ret_stats & CONVERT_STAT_BITS_BIN) &&
+ (ret_stats & CONVERT_STAT_BITS_TXT_CRLF))
+ has_crlf = 1;
+ }
free(data);
- return has_cr;
+ return has_crlf;
}
static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
@@ -290,7 +299,7 @@ static int crlf_to_git(const struct index_state *istate,
* cherry-pick.
*/
if ((checksafe != SAFE_CRLF_RENORMALIZE) &&
- has_cr_in_index(istate, path))
+ has_crlf_in_index(istate, path))
convert_crlf_into_lf = 0;
}
if ((checksafe == SAFE_CRLF_WARN ||