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