File: pre-commit

package info (click to toggle)
libcuckoo 0.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,036 kB
  • sloc: cpp: 16,538; ansic: 72; python: 34; sh: 15; makefile: 9
file content (19 lines) | stat: -rwxr-xr-x 521 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# clang-format pre-commit hook
#
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
#
# This script does not handle file names that contain spaces.

cfiles=$(git diff --name-only HEAD --diff-filter=d | grep '\.\(cc\|hh\|c\|h\)$')
numerrors=0
for f in $cfiles; do
	diffoutput=$(clang-format $f | diff $f -)
	if [ -n "$diffoutput" ]; then
		[ $numerrors -eq 0 ] && echo >&2 "Unformatted files:";
		echo >&2 "$f";
		((numerrors++))
	fi
done
exit $numerrors