xref: /xnu-10063.121.3/tools/pre-commit.sh (revision 2c2f96dc2b9a4408a43d3150ae9c105355ca3daa)
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