1*2c2f96dcSApple OSS Distributions#!/bin/sh 2*2c2f96dcSApple OSS Distributionsset -e 3*2c2f96dcSApple OSS Distributions 4*2c2f96dcSApple OSS Distributions# Abort a commit if the code style is incorrect. 5*2c2f96dcSApple OSS Distributions 6*2c2f96dcSApple OSS Distributions# Get a list of paths with staged changes. 7*2c2f96dcSApple OSS DistributionsFILES=$(git diff --staged --name-only --diff-filter=d) 8*2c2f96dcSApple OSS Distributions# Check the paths for style issues. 9*2c2f96dcSApple OSS DistributionsRESULT=0 10*2c2f96dcSApple OSS Distributionsif [ ! -z "$FILES" ]; then 11*2c2f96dcSApple OSS Distributions # Stash any unstaged changes. 12*2c2f96dcSApple OSS Distributions git stash --quiet --keep-index 13*2c2f96dcSApple OSS Distributions ./tools/uncrustify.sh $FILES || RESULT=$? 14*2c2f96dcSApple OSS Distributions # Restore the unstaged changes. 15*2c2f96dcSApple OSS Distributions git stash pop --quiet 16*2c2f96dcSApple OSS Distributionsfi 17*2c2f96dcSApple OSS Distributionsexit $RESULT 18