| ... | ... |
@@ -2,7 +2,16 @@ |
| 2 | 2 |
|
| 3 | 3 |
A [Git hook][] that prevents you from committing unintended content. |
| 4 | 4 |
|
| 5 |
+`git-hook-nocommit` is intended to be used as a [pre-commit][] hook and will |
|
| 6 |
+refuse to commit any files with content that matches (case insensitively) the |
|
| 7 |
+[extended regex][] `$GIT_HOOK_NOCOMMIT_REGEX` (or `nocommit|nocheckin` if it is |
|
| 8 |
+empty) unless `$GIT_HOOK_NOCOMMIT_DISABLE` is non-empty (or `git commit` is run |
|
| 9 |
+with the [`-n,--no-verify`][] flag). |
|
| 10 |
+ |
|
| 5 | 11 |
[Git hook]: https://git-scm.com/docs/githooks |
| 12 |
+[pre-commit]: https://git-scm.com/docs/githooks#_pre_commit |
|
| 13 |
+[extended regex]: https://en.wikipedia.org/wiki/Regular_expression#POSIX_basic_and_extended |
|
| 14 |
+[`-n,--no-verify`]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--n |
|
| 6 | 15 |
|
| 7 | 16 |
## License |
| 8 | 17 |
|
| 9 | 18 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,10 @@ |
| 1 |
+#!/bin/sh |
|
| 2 |
+set -euC |
|
| 3 |
+ |
|
| 4 |
+# Redirect output to stderr. |
|
| 5 |
+exec 1>&2 |
|
| 6 |
+ |
|
| 7 |
+! [ "${GIT_HOOK_NOCOMMIT_DISABLE:-}" ] || exit 0
|
|
| 8 |
+ |
|
| 9 |
+! git grep --cached --line-number --ignore-case --extended-regexp \ |
|
| 10 |
+ "${GIT_HOOK_NOCOMMIT_REGEX:="nocommit|nocheckin"}"
|