From ed4ecd4dca066a1a7d961bd22fe482198ef8ed10 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 28 Jul 2020 17:20:59 +0900 Subject: [PATCH] switching to pre-commit hook --- .githooks/pre-commit | 19 +++++++++++++++++++ .githooks/update | 10 ---------- 2 files changed, 19 insertions(+), 10 deletions(-) create mode 100755 .githooks/pre-commit delete mode 100755 .githooks/update diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..22a39f77 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,19 @@ +#!/bin/bash + +# fail if we add any new lines to C or Scheme source containing a tab +if git diff --name-only | egrep '\.(cpp|h|scm|sld|stub)$' | xargs -d'\n' git diff -U0 -- | grep -q $'^+ *\t'; then + echo "Error: Attempting to add a source file using tabs for indentation." + echo + echo -n " " + git diff --name-only |\ + egrep '\.(cpp|h|scm|sld|stub)$' |\ + xargs -d'\n' git diff -U0 -- |\ + grep $'^+ *\t' | head -1 + echo + cat <