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