Skip to content

Commit

Permalink
Merge pull request #23 from dlenski/respect_gitattributes
Browse files Browse the repository at this point in the history
use git-check-attr to skip files marked +binary or -text
  • Loading branch information
dlenski authored Nov 9, 2020
2 parents 136bacb + 6299d8c commit fe5618a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pre-commit.careful
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fe5618a

Please sign in to comment.