Update copyright year to 2015
[emacs.git] / build-aux / git-hooks / pre-commit
blobd050c40a2e68e81754fa2d2fc523a27ca17d0c90
1 #!/bin/sh
2 # Check file names in git commits for GNU Emacs.
4 # Copyright 2014-2015 Free Software Foundation, Inc.
6 # This file is part of GNU Emacs.
8 # GNU Emacs is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU Emacs is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21 LC_ALL=C
22 export LC_ALL
24 exec >&2
26 . git-sh-setup
28 git_diff='git diff --cached --name-only --diff-filter=A'
29 ok_chars='\0+[=-=]./0-9A-Z_a-z'
30 nbadchars=`$git_diff -z HEAD | tr -d "$ok_chars" | wc -c`
32 if test "$nbadchars" -ne 0; then
33 echo "File name does not consist of -+./_ or ASCII letters or digits."
34 exit 1
37 new_names=`$git_diff HEAD` || exit
38 case "
39 $new_names" in
40 */-* | *'
41 '-*)
42 echo "File name component begins with '-'."
43 exit 1;;
44 esac
46 exec git diff-index --check --cached HEAD --