diff options
| author | Paul Eggert | 2014-11-22 15:46:17 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-11-22 16:41:10 -0800 |
| commit | 00981cbdfff391d858d262083d24b685217a8353 (patch) | |
| tree | 0d33bcdd109acfb640f24e146cc4b9f40a636612 /build-aux/git-hooks/pre-commit | |
| parent | 238c052fdb9da3b1f96c09809461b70813c5bebc (diff) | |
| download | emacs-00981cbdfff391d858d262083d24b685217a8353.tar.gz emacs-00981cbdfff391d858d262083d24b685217a8353.zip | |
Add git commit hooks that do some simple checks on commits.
* autogen.sh: Install Git hooks, if using Git.
* build-aux/git-hooks/commit-msg, build-aux/git-hooks/pre-commit:
New files, which are Git hooks that check for portable file names, and
do some simple checks for commit message format.
Diffstat (limited to 'build-aux/git-hooks/pre-commit')
| -rwxr-xr-x | build-aux/git-hooks/pre-commit | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit new file mode 100755 index 00000000000..c24f9bb48d3 --- /dev/null +++ b/build-aux/git-hooks/pre-commit | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Check file names in git commits for GNU Emacs. | ||
| 3 | |||
| 4 | # Copyright 2014 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 | 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 | ||
| 45 | |||
| 46 | exec git diff-index --check --cached HEAD -- | ||