2 #=============================================================================
3 # CMake - Cross Platform Makefile Generator
4 # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
6 # Distributed under the OSI-approved BSD License (the "License");
7 # see accompanying file Copyright.txt for details.
9 # This software is distributed WITHOUT ANY WARRANTY; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the License for more information.
12 #=============================================================================
15 echo 'pre-commit hook failure' 1>&2
16 echo '-----------------------' 1>&2
22 #-------------------------------------------------------------------------------
24 bad=$(regex=".{$line_too_long}" &&
25 git diff-index --cached HEAD --name-only --diff-filter=AM \
26 --pickaxe-regex -S"$regex" -- 'Source/*.h' 'Source/*.cxx' |
28 lines_too_long=$(git diff-index -p --cached HEAD \
29 --pickaxe-regex -S"$regex" -- "$file")
30 if echo "$lines_too_long" | egrep -q '^\+'"$regex"; then
31 echo "$lines_too_long"
35 die 'The following changes add lines too long for our C++ style:
39 Use lines strictly less than '"$line_too_long"' characters in C++ code.'
41 #-------------------------------------------------------------------------------
42 if test -z "$HOOKS_ALLOW_KWSYS"; then
43 # Disallow changes to KWSys
44 files=$(git diff-index --name-only --cached HEAD -- Source/kwsys) &&
45 if test -n "$files"; then
46 die 'Changes to KWSys files
48 '"$(echo "$files" | sed 's/^/ /')"'
50 should not be made directly in CMake. KWSys is kept in its own Git
51 repository and shared by several projects. Please visit
53 http://public.kitware.com/Wiki/KWSys/Git
55 to contribute changes directly to KWSys. Run
57 git reset HEAD -- Source/kwsys
59 to unstage these changes. Alternatively, set environment variable
63 to disable this check and commit the changes locally.'