File: pre-commit.sample

package info (click to toggle)
dlt-daemon 2.18.11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,712 kB
  • sloc: ansic: 43,562; cpp: 14,157; sh: 1,211; xml: 1,123; python: 256; makefile: 32
file content (28 lines) | stat: -rwxr-xr-x 544 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

gitclangformat=$(which git-clang-format)

if [ "$gitclangformat" == "" ]
then
    gitclangformat=$(find /usr/bin/ -name "git-clang-format*")
fi

against=`git rev-parse --verify HEAD 2>&1`

if [ $against == "" ]
then
    # Initial commit: diff against an empty tree object
    against=5394c6fa5bf40d9bc8619026cbc4c306211a8499
fi

$gitclangformat $against -f -q

if [ $? != 0 ]
then
    echo "Format error!"
    echo "Use git clang-format"
    exit 1
fi

# Now update format changes and commit
git add $(git diff --name-only --cached)