xref: /freebsd/contrib/libcbor/misc/hooks/pre-commit (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1#!/bin/sh
2
3set -e
4
5# Run clang-format and add modified files
6MODIFIED_UNSTAGED=$(git -C . diff --name-only)
7MODIFIED_STAGED=$(git -C . diff --name-only --cached --diff-filter=d)
8
9./clang-format.sh
10
11git add ${MODIFIED_STAGED}
12
13if [[ ${MODIFIED_UNSTAGED} != $(git -C . diff --name-only) ]]; then
14  echo "WARNING: Non-staged files were reformatted. Please review and/or add" \
15    "them"
16fi
17
18
19