#!/bin/bash

set -ue

echo "Clang-format:"
if [ -e .git/MERGE_HEAD ]; then
    echo "  Merge commit"
    exit 0
fi

if ! command -v git-clang-format > /dev/null 2>&1; then
    echo "  No git-clang-format checking"
    exit 0
fi
if ! command -v clang-format > /dev/null 2>&1; then
    echo "  No clang-format checking"
    exit 0
fi

# Check version of clang-format, and print a helpful message if it's too old.  If the right version
# is not found then exit.
./site_scons/site_tools/extra/extra.py || exit 0

git-clang-format --staged src
