summaryrefslogtreecommitdiff
path: root/scripts/githooks/pre-commit
blob: fec7128f4e2e22e0ef97a51b152b43718314647b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
#
# pre-commit hook to fix whitespace errors
#
# Uses the core.whitespace or .gitattributes whitespace=... settings.
#
# see also: "man git-config" under core.whitespace
# see also: "man gitattributes"
#

PATCH=P.diff

if ! git diff --cached --check --quiet
then
	git diff --cached > $PATCH
	git apply --cached --whitespace=fix -R $PATCH
	git apply --cached --whitespace=fix $PATCH
	rm $PATCH
fi