From 8ab30d25b5ffc6a56e9ca41f446504bba4a726ad Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Tue, 16 Jan 2018 18:12:55 +0100 Subject: Have the pre-commit hook also fix end-of-file nl --- dev/tools/pre-commit | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'dev/tools/pre-commit') diff --git a/dev/tools/pre-commit b/dev/tools/pre-commit index 59cc84856d..0cd0a0b705 100755 --- a/dev/tools/pre-commit +++ b/dev/tools/pre-commit @@ -5,6 +5,17 @@ set -e +CODE=0 +git diff --cached --name-only -z | xargs -0 dev/tools/check-eof-newline.sh --fix || CODE=1 + +if [ $CODE -ne 0 ] +then + 1>&2 echo "Some files had newline errors; they have been fixed in the working tree." + 1>&2 echo "Make sure to add them before committing." + 1>&2 echo "This may fix itself if you were using git commit -a, and you try again." + exit 1 +fi + if git diff-index --check --cached HEAD >/dev/null 2>&1 ; then : -- cgit v1.2.3