You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
514 B
24 lines
514 B
#!/bin/bash
|
|
|
|
# Runs clang-format on the files changed between HEAD and $1, which defaults to
|
|
# origin/master.
|
|
|
|
# to pick up git-clang-format from scripts/
|
|
export PATH=$(dirname $0):$PATH
|
|
|
|
CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
|
|
GITREF=${1:-origin/master}
|
|
|
|
if ! hash $CLANG_FORMAT 2> /dev/null; then
|
|
echo "Could not find clang-format tool" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
cmd="git clang-format $GITREF --binary $CLANG_FORMAT --diff --extensions h,c,cc"
|
|
|
|
n=$($cmd --quiet | wc -l)
|
|
if [ $n -gt 0 ]; then
|
|
$cmd -v
|
|
exit 1
|
|
fi
|