Commit 19f86ec1 authored by Brad King's avatar Brad King
Browse files

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.
parent f83a32fe
......@@ -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]*$".
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment