bootstrap/specs/clang/template/.githooks/pre-commit

12 lines
216 B
Plaintext
Raw Normal View History

2023-11-26 21:51:41 +00:00
#!/usr/bin/env bash
set -e
2023-12-03 18:24:45 +00:00
FORMAT_FILES=$(
2023-11-26 21:51:41 +00:00
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.c$|\.h$/ {print $NF}'
)
2023-12-03 18:24:45 +00:00
clang-format -i "$FORMAT_FILES"
git add "$FORMAT_FILES"