summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-09-15 09:22:03 -0400
committerBrad King <brad.king@kitware.com>2010-09-15 09:22:03 -0400
commit19f86ec15cc36f3edd30210724b0d11b080d9961 (patch)
tree77f70f798dfc16e70ce8103f4b29f0bfcaf72e64
parentf83a32feb68c5b6ee2e98f54f016daed86a7fd8f (diff)
downloadcmake-19f86ec15cc36f3edd30210724b0d11b080d9961.tar.gz
pre-commit: Allow submodule check to be disabled
If hooks.submodule is 'false' disable all checks. If an individual hooks.<module>.update is 'true' then accept any update for that module. Leave these options out of the hints printed. Developers that know what they are doing will be able to find them by reading the hook source.
-rwxr-xr-xpre-commit10
1 files changed, 9 insertions, 1 deletions
diff --git a/pre-commit b/pre-commit
index afaba6cc78..bee9c90274 100755
--- a/pre-commit
+++ b/pre-commit
@@ -175,16 +175,24 @@ short_commit() {
}
lookup_config_module_update() {
+ update=$(git config "hooks.$1.update")
+
+ # Special-case "true" to accept any update.
+ test "{$update}" = "{true}" && echo '.' && return
+
# Format is "aaaaaa..bbbbbb" for update aaaaaa => bbbbbb.
# Convert to regex "^aaaaaa[a-z0-9]* bbbbbb[a-z0-9]*$".
sha1ex='[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]*'
regex='^\('"$sha1ex"'\)\.\.\('"$sha1ex"'\)$'
- git config "hooks.$1.update" |
+ echo "$update" |
sed -n "/$regex/ {s/$regex/"'^\1[a-z0-9]* \2[a-z0-9]*$/;p;}' |
grep '.' # Return false if result is empty.
}
check_module() {
+ enabled=$(git config --get --bool hooks.submodule) || enabled=true
+ test "$enabled" = "false" && return
+
# Allow module-only commits without extra work.
test -z "$diffs_normal" && return