xref: /freebsd/contrib/libcbor/misc/hooks/pre-commit (revision 7ef62cebc2f965b0f640263e179276928885e33d)
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