pre-commit 403 Bytes
Newer Older
Caleb C. Sander's avatar
Caleb C. Sander committed
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash

if loc="$(type -p "clang-format")" && [[ -x $loc ]]; then
    for name in $(git diff --cached --name-only --diff-filter=ACM); do
        if echo $name | grep -Eq "\.[ch]$"; then
            echo "Formatting ${name}..."
            clang-format -i $name
        fi
    done
else
    echo "You do not have clang-format installed; so, we were unable to unify the formatting in your files."
fi