]> code.delx.au - gnu-emacs/blob - build-aux/git-hooks/pre-commit
Generate a ChangeLog file from commit logs
[gnu-emacs] / build-aux / git-hooks / pre-commit
1 #!/bin/sh
2 # Check file names in git commits for GNU Emacs.
3
4 # Copyright 2014-2015 Free Software Foundation, Inc.
5
6 # This file is part of GNU Emacs.
7
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.
12
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.
17
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/>.
20
21 LC_ALL=C
22 export LC_ALL
23
24 exec >&2
25
26 . git-sh-setup
27
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`
31
32 if test "$nbadchars" -ne 0; then
33 echo "File name does not consist of -+./_ or ASCII letters or digits."
34 exit 1
35 fi
36
37 for new_name in `$git_diff HEAD`; do
38 case $new_name in
39 -* | */-*)
40 echo "$new_name: File name component begins with '-'."
41 exit 1;;
42 ChangeLog | */ChangeLog)
43 echo "$new_name: Please use git commit messages, not ChangeLog files."
44 exit 1;;
45 esac
46 done
47
48 exec git diff-index --check --cached HEAD --