From 6299d8c655e2fd99f7bf76cd49b79d427c4a9ed9 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Fri, 6 Nov 2020 19:27:38 -0800 Subject: [PATCH] use git-check-attr to skip files marked +binary or -text ping #22 --- pre-commit.careful | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pre-commit.careful b/pre-commit.careful index e9f4a5e..111ca0e 100755 --- a/pre-commit.careful +++ b/pre-commit.careful @@ -10,6 +10,9 @@ while read -d '' _ MODE _ SHA1 _ && read -d '' FILE do if [ "$MODE" == 120000 ]; then true # ignore symlinks + elif git check-attr -a -- "$FILE" | grep -Eq ': (binary: set|text: unset)$'; then + # ignore files marked as binary or non-text; see gitattributes(5) and git-check-attr(1) + echo "No whitespace checking for file '$FILE'; marked +binary or -text" elif ! ( git cat-file blob $SHA1 | wtf $wtf_options > $tmp ); then if [ -s $tmp ]; then git update-index --cacheinfo $MODE $(git hash-object -w $tmp) "$FILE"