File: pre-commit

package info (click to toggle)
nghttp2 1.64.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,844 kB
  • sloc: cpp: 55,820; ansic: 52,049; python: 2,927; makefile: 1,371; sh: 200; ruby: 66; lisp: 2
file content (27 lines) | stat: -rwxr-xr-x 872 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
20
21
22
23
24
25
26
27
#!/bin/sh -e
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.  The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#

CLANGFORMATDIFF=`git config --get clangformatdiff.binary`

if [ -z "$CLANGFORMATDIFF" ]; then
    CLANGFORMATDIFF=clang-format-diff.py
fi

errors=`git diff-index --cached --diff-filter=ACMR -p HEAD lib src examples tests | $CLANGFORMATDIFF -p1`

if [ -n "$errors" ]; then
    echo "$errors"
    echo "--"
    echo "[ERROR] We have detected the difference between the code to commit"
    echo "and clang-format style rules.  Please fix this problem in either:"
    echo "1) Apply patch above."
    echo "2) Use clang-format to format lines."
    echo "3) Reformat these lines manually."
    echo "Aborting commit."
    exit 1
fi