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