summaryrefslogtreecommitdiff
path: root/scripts/githooks/pre-commit
blob: 3a47af969774b6f994e38bbfd40560a7975fa63d (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 -R $PATCH
	git apply --cached --whitespace=fix $PATCH
	rm $PATCH
fi