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