From f93d0f6ac1ccf57727e95421c1dc154351458c4c Mon Sep 17 00:00:00 2001 From: Vladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com> Date: Tue, 19 Mar 2019 02:47:07 +0700 Subject: [PATCH] Unify line ending rules in '.editorconfig' and '.gitattributes' (#5231) * Unify line ending rules in '.editorconfig' and '.gitattributes' * Revert '.gitattributes' - fix invalid comments in the check-source.py --- .editorconfig | 6 +++--- .gitattributes | 1 + .travis/check-sources.sh.py | 11 +++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.editorconfig b/.editorconfig index be31d8c05..6c549666e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,7 @@ root = true -[*.{cpp,cc,h,sh}] -end_of_line = LF +# Don't set line endings to avoid conflict with core.autocrlf flag. +# Line endings on checkout/checkin are controlled by .gitattributes file. +[*] indent_style = space indent_size = 2 insert_final_newline = true - diff --git a/.gitattributes b/.gitattributes index 176a458f9..4cab1f4d2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ +# Set the default behavior, in case people don't have core.autocrlf set. * text=auto diff --git a/.travis/check-sources.sh.py b/.travis/check-sources.sh.py index 5ad060cd2..2b001d763 100644 --- a/.travis/check-sources.sh.py +++ b/.travis/check-sources.sh.py @@ -18,12 +18,11 @@ def check_encoding(encoding, scan_dir, regex_pattern): btext.decode(encoding=encoding, errors="strict") if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'): raise ValueError("unexpected BOM in file") - # check strict CRLF line-ending - LF = btext.count(b'\r') - CRLF = btext.count(b'\r\n') - assert LF >= CRLF, "CRLF logic error" - if CRLF != LF: - raise ValueError("CRLF violation: found {} LF characters".format(LF - CRLF)) + # check LF line endings + LF = btext.count(b'\n') + CR = btext.count(b'\r') + if CR!=0: + raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR)) except Exception as err: print("ERROR with [{}]: {}".format(fname, err)) return -1