| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com> |
| 4 | # |
| 5 | # This program is free software; you can redistribute it and/or modify it |
| 6 | # under the terms of the GNU General Public License, version 2 only, as |
| 7 | # published by the Free Software Foundation. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | # more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License along with |
| 15 | # this program; if not, write to the Free Software Foundation, Inc., 51 |
| 16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | |
| 18 | # Install the checkpatch pre-commit hook. |
| 19 | |
| 20 | DIR="$( cd "$( dirname "$0" )" && pwd )" |
| 21 | |
| 22 | PRECOMMIT_HOOK="../.git/hooks/pre-commit" |
| 23 | PRECOMMIT_SCRIPT="checkpatch-hook" |
| 24 | CHECKPATCH_CONF=".checkpatch.conf" |
| 25 | |
| 26 | if [ -f $PRECOMMIT_HOOK ]; |
| 27 | then |
| 28 | echo "File $PRECOMMIT_HOOK already exists. Aborting." |
| 29 | exit 1 |
| 30 | else |
| 31 | ln -s $DIR/$PRECOMMIT_SCRIPT $PRECOMMIT_HOOK |
| 32 | fi |
| 33 | |
| 34 | if [ -f ../$CHECKPATCH_CONF ]; |
| 35 | then |
| 36 | echo "File ../$CHECKPATCH_CONF already exists. Aborting." |
| 37 | exit 1 |
| 38 | else |
| 39 | ln -s $DIR/$CHECKPATCH_CONF ../$CHECKPATCH_CONF |
| 40 | fi |
| 41 | |
| 42 | echo "Checkpatch pre-commit hook successfully installed!" |